Reviewed-by: https://github.com/apps/ansible-zuul
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

Add changelog

Co-authored-by: Suhas Bharadwaj <subharad@cisco.com>
pull/69860/head
Nilashish Chakraborty 5 years ago committed by GitHub
parent 055a24c027
commit 6967811560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Update NX-OS cliconf to accomodate MDS (https://github.com/ansible-collections/cisco.nxos/pull/78).

@ -46,6 +46,7 @@ class Cliconf(CliconfBase):
def __init__(self, *args, **kwargs):
self._module_context = {}
self._device_info = {}
super(Cliconf, self).__init__(*args, **kwargs)
def read_module_context(self, module_key):
@ -60,52 +61,55 @@ class Cliconf(CliconfBase):
return None
def get_device_info(self):
device_info = {}
if not self._device_info:
device_info = {}
device_info['network_os'] = 'nxos'
reply = self.get('show version')
platform_reply = self.get('show inventory')
device_info['network_os'] = 'nxos'
reply = self.get('show version')
platform_reply = self.get('show inventory')
match_sys_ver = re.search(r'\s+system:\s+version\s*(\S+)', reply, re.M)
if match_sys_ver:
device_info['network_os_version'] = match_sys_ver.group(1)
else:
match_kick_ver = re.search(r'\s+kickstart:\s+version\s*(\S+)', reply, re.M)
if match_kick_ver:
device_info['network_os_version'] = match_kick_ver.group(1)
if 'network_os_version' not in device_info:
match_sys_ver = re.search(r'\s+NXOS:\s+version\s*(\S+)', reply, re.M)
match_sys_ver = re.search(r'\s+system:\s+version\s*(\S+)', reply, re.M)
if match_sys_ver:
device_info['network_os_version'] = match_sys_ver.group(1)
else:
match_kick_ver = re.search(r'\s+kickstart:\s+version\s*(\S+)', reply, re.M)
if match_kick_ver:
device_info['network_os_version'] = match_kick_ver.group(1)
match_chassis_id = re.search(r'Hardware\n\s+cisco(.+)$', reply, re.M)
if match_chassis_id:
device_info['network_os_model'] = match_chassis_id.group(1).strip()
if 'network_os_version' not in device_info:
match_sys_ver = re.search(r'\s+NXOS:\s+version\s*(\S+)', reply, re.M)
if match_sys_ver:
device_info['network_os_version'] = match_sys_ver.group(1)
match_host_name = re.search(r'\s+Device name:\s*(\S+)', reply, re.M)
if match_host_name:
device_info['network_os_hostname'] = match_host_name.group(1)
match_chassis_id = re.search(r'Hardware\n\s+cisco(.+)$', reply, re.M)
if match_chassis_id:
device_info['network_os_model'] = match_chassis_id.group(1).strip()
match_isan_file_name = re.search(r'\s+system image file is:\s*(\S+)', reply, re.M)
if match_isan_file_name:
device_info['network_os_image'] = match_isan_file_name.group(1)
else:
match_kick_file_name = re.search(r'\s+kickstart image file is:\s*(\S+)', reply, re.M)
if match_kick_file_name:
device_info['network_os_image'] = match_kick_file_name.group(1)
match_host_name = re.search(r'\s+Device name:\s*(\S+)', reply, re.M)
if match_host_name:
device_info['network_os_hostname'] = match_host_name.group(1)
if 'network_os_image' not in device_info:
match_isan_file_name = re.search(r'\s+NXOS image file is:\s*(\S+)', reply, re.M)
match_isan_file_name = re.search(r'\s+system image file is:\s*(\S+)', reply, re.M)
if match_isan_file_name:
device_info['network_os_image'] = match_isan_file_name.group(1)
else:
match_kick_file_name = re.search(r'\s+kickstart image file is:\s*(\S+)', reply, re.M)
if match_kick_file_name:
device_info['network_os_image'] = match_kick_file_name.group(1)
match_os_platform = re.search(r'NAME: "Chassis",\s*DESCR:.*\n'
r'PID:\s*(\S+)', platform_reply, re.M)
if match_os_platform:
device_info['network_os_platform'] = match_os_platform.group(1)
if 'network_os_image' not in device_info:
match_isan_file_name = re.search(r'\s+NXOS image file is:\s*(\S+)', reply, re.M)
if match_isan_file_name:
device_info['network_os_image'] = match_isan_file_name.group(1)
return device_info
match_os_platform = re.search(r'NAME: "Chassis",\s*DESCR:.*\n'
r'PID:\s*(\S+)', platform_reply, re.M)
if match_os_platform:
device_info['network_os_platform'] = match_os_platform.group(1)
self._device_info = device_info
return self._device_info
def get_diff(self, candidate=None, running=None, diff_match='line', diff_ignore_lines=None, path=None, diff_replace='line'):
diff = {}
@ -282,7 +286,13 @@ class Cliconf(CliconfBase):
raise ValueError("'output' value %s is invalid. Valid values are %s" % (output, ','.join(options_values['output'])))
if output == 'json' and not command.endswith('| json'):
cmd = '%s | json' % command
device_info = self.get_device_info()
model = device_info.get("network_os_model", "")
platform = device_info.get("network_os_platform", "")
if platform.startswith("DS-") and "MDS" in model:
cmd = "%s | json native" % command
else:
cmd = "%s | json" % command
elif output == 'text' and command.endswith('| json'):
cmd = command.rsplit('|', 1)[0]
else:

Loading…
Cancel
Save