mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Add platform facts in network facts modules (#51434)
* Add platform facts in network facts modules Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add nxos Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add vyos Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add iosxr Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add junos Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix pep8 Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update unit test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix vyos_facts unittest Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix ios_facts unittest Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix iosxr unittests Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix CI failure Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix junos test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -43,6 +43,7 @@ options:
|
||||
|
||||
import json
|
||||
import time
|
||||
import re
|
||||
|
||||
from ansible.errors import AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_text
|
||||
@@ -246,6 +247,11 @@ class Cliconf(CliconfBase):
|
||||
|
||||
device_info['network_os_hostname'] = data['hostname']
|
||||
|
||||
reply = self.get('bash timeout 5 cat /mnt/flash/boot-config')
|
||||
match = re.search(r'SWI=(.+)$', reply, re.M)
|
||||
if match:
|
||||
device_info['network_os_image'] = match.group(1)
|
||||
|
||||
return device_info
|
||||
|
||||
def get_device_operations(self):
|
||||
|
||||
@@ -216,6 +216,10 @@ class Cliconf(CliconfBase):
|
||||
if match:
|
||||
device_info['network_os_hostname'] = match.group(1)
|
||||
|
||||
match = re.search(r'image file is "(.+)"', data)
|
||||
if match:
|
||||
device_info['network_os_image'] = match.group(1)
|
||||
|
||||
return device_info
|
||||
|
||||
def get_device_operations(self):
|
||||
|
||||
@@ -80,9 +80,9 @@ class Cliconf(CliconfBase):
|
||||
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(.+)$', reply, re.M)
|
||||
if match_chassis_id:
|
||||
device_info['network_os_model'] = match_chassis_id.group(1)
|
||||
device_info['network_os_model'] = match_chassis_id.group(1).strip()
|
||||
|
||||
match_host_name = re.search(r'\s+Device name:\s*(\S+)', reply, re.M)
|
||||
if match_host_name:
|
||||
|
||||
@@ -52,7 +52,7 @@ class Cliconf(CliconfBase):
|
||||
reply = self.get('show version')
|
||||
data = to_text(reply, errors='surrogate_or_strict').strip()
|
||||
|
||||
match = re.search(r'Version:\s*(\S+)', data)
|
||||
match = re.search(r'Version:\s*(.*)', data)
|
||||
if match:
|
||||
device_info['network_os_version'] = match.group(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user