get_device_info nxos zero or more whitespace regex (#43178)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2018-07-24 10:55:37 +05:30 committed by GitHub
parent c6854fde29
commit dd6ef3355f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,42 +60,42 @@ class Cliconf(CliconfBase):
reply = self.get('show version')
platform_reply = self.get('show inventory')
match_sys_ver = re.search(r'\s+system:\s+version (\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+)', reply, re.M)
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+)', reply, re.M)
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_chassis_id = re.search(r'Hardware\n\s+cisco\s+(\S+\s+\S+)', reply, re.M)
match_chassis_id = re.search(r'Hardware\n\s+cisco\s*(\S+\s+\S+)', reply, re.M)
if match_chassis_id:
device_info['network_os_model'] = match_chassis_id.group(1)
match_host_name = re.search(r'\s+Device name:\s+(\S+)', reply, re.M)
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_isan_file_name = re.search(r'\s+system 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)
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)
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+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)
match_os_platform = re.search(r'NAME: "Chassis",\s+DESCR:.*\n'
r'PID:\s+(\S+)', platform_reply, re.M)
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)