diff --git a/lib/ansible/module_utils/network/onyx/onyx.py b/lib/ansible/module_utils/network/onyx/onyx.py index ad667e74dfd..90adc665812 100644 --- a/lib/ansible/module_utils/network/onyx/onyx.py +++ b/lib/ansible/module_utils/network/onyx/onyx.py @@ -139,15 +139,27 @@ def get_interfaces_config(module, interface_type, flags=None, json_fmt=True): return show_cmd(module, cmd, json_fmt) -def show_version(module): - return show_cmd(module, "show version") - - def get_bgp_summary(module): cmd = "show running-config protocol bgp" return show_cmd(module, cmd, json_fmt=False, fail_on_error=False) +def get_capabilities(module): + """Returns platform info of the remove device + """ + if hasattr(module, '_capabilities'): + return module._capabilities + + connection = get_connection(module) + try: + capabilities = connection.get_capabilities() + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors='surrogate_then_replace')) + + module._capabilities = json.loads(capabilities) + return module._capabilities + + class BaseOnyxModule(object): ONYX_API_VERSION = "3.6.6000" @@ -168,9 +180,9 @@ class BaseOnyxModule(object): pass def _get_os_version(self): - version_data = show_version(self._module) - return self.get_config_attr( - version_data, "Product release") + capabilities = get_capabilities(self._module) + device_info = capabilities['device_info'] + return device_info['network_os_version'] # pylint: disable=unused-argument def check_declarative_intent_params(self, result): diff --git a/lib/ansible/plugins/cliconf/onyx.py b/lib/ansible/plugins/cliconf/onyx.py index 668c9d5e001..02332132942 100644 --- a/lib/ansible/plugins/cliconf/onyx.py +++ b/lib/ansible/plugins/cliconf/onyx.py @@ -36,10 +36,11 @@ class Cliconf(CliconfBase): reply = self.get(b'show version | json-print') data = json.loads(reply) device_info['network_os'] = data['Product name'] - device_info['network_os_version'] = data['Version summary'] + device_info['network_os_version'] = data['Product release'] + device_info['network_os_version_summary'] = data['Version summary'] device_info['network_os_model'] = data['Product model'] - reply = self.get(b'show version | include Hostname') + reply = self.get(b'show hosts | include Hostname') data = to_text(reply, errors='surrogate_or_strict').strip() hostname = data.split(':')[1] hostname = hostname.strip()