diff --git a/changelogs/fragments/iosxr_show_version_brief.yaml b/changelogs/fragments/iosxr_show_version_brief.yaml new file mode 100644 index 00000000000..df1234e839b --- /dev/null +++ b/changelogs/fragments/iosxr_show_version_brief.yaml @@ -0,0 +1,2 @@ +bugfixes: +- iosxr_* modules do not work with iosxr version >= 6.3.2 as cisco has deprecated 'show version brief' diff --git a/lib/ansible/modules/network/iosxr/iosxr_facts.py b/lib/ansible/modules/network/iosxr/iosxr_facts.py index 8662192fb52..ffe66a4e354 100644 --- a/lib/ansible/modules/network/iosxr/iosxr_facts.py +++ b/lib/ansible/modules/network/iosxr/iosxr_facts.py @@ -136,12 +136,12 @@ class FactsBase(object): class Default(FactsBase): def commands(self): - return(['show version brief']) + return(['show version | utility head -n 20']) def populate(self, results): - self.facts['version'] = self.parse_version(results['show version brief']) - self.facts['image'] = self.parse_image(results['show version brief']) - self.facts['hostname'] = self.parse_hostname(results['show version brief']) + self.facts['version'] = self.parse_version(results['show version | utility head -n 20']) + self.facts['image'] = self.parse_image(results['show version | utility head -n 20']) + self.facts['hostname'] = self.parse_hostname(results['show version | utility head -n 20']) def parse_version(self, data): match = re.search(r'Version (\S+)$', data, re.M) diff --git a/lib/ansible/plugins/cliconf/iosxr.py b/lib/ansible/plugins/cliconf/iosxr.py index 9f4746681ea..d6a012e2279 100644 --- a/lib/ansible/plugins/cliconf/iosxr.py +++ b/lib/ansible/plugins/cliconf/iosxr.py @@ -35,7 +35,7 @@ class Cliconf(CliconfBase): device_info = {} device_info['network_os'] = 'iosxr' - reply = self.get(b'show version brief') + reply = self.get(b'show version | utility head -n 20') data = to_text(reply, errors='surrogate_or_strict').strip() match = re.search(r'Version (\S+)$', data, re.M) diff --git a/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20 b/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20 new file mode 100644 index 00000000000..7f82039ff19 --- /dev/null +++ b/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20 @@ -0,0 +1,18 @@ +Cisco IOS XR Software, Version 6.0.0[Default] +Copyright (c) 2015 by Cisco Systems, Inc. + +ROM: GRUB, Version 1.99(0), DEV RELEASE + +iosxr01 uptime is 11 weeks, 6 days, 2 hours, 2 minutes +System image file is "bootflash:disk0/xrvr-os-mbi-6.0.0/mbixrvr-rp.vm" + +cisco IOS XRv Series (Pentium Celeron Stepping 3) processor with 3169911K bytes +of memory. +Pentium Celeron Stepping 3 processor at 3836MHz, Revision 2.174 +IOS XRv Chassis + +1 Management Ethernet +6 GigabitEthernet +97070k bytes of non-volatile configuration memory. +866M bytes of hard disk. +2321392k bytes of disk0: (Sector size 512 bytes). diff --git a/test/units/modules/network/iosxr/test_iosxr_facts.py b/test/units/modules/network/iosxr/test_iosxr_facts.py index 8b3233d0cf2..cf55a1110ce 100644 --- a/test/units/modules/network/iosxr/test_iosxr_facts.py +++ b/test/units/modules/network/iosxr/test_iosxr_facts.py @@ -57,6 +57,7 @@ class TestIosxrFacts(TestIosxrModule): command = item filename = str(command).replace(' ', '_') filename = filename.replace('/', '7') + filename = filename.replace('|', '_') output.append(load_fixture(filename)) return output