From ab4e83f288298fe05fdcf687b3ee8f65efa50702 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Wed, 22 Feb 2017 15:44:17 +0100 Subject: [PATCH] Remove superfluous include on iosxr filesystems fact gathering (#21775) The regex will catch only lines that start with 'Directory of' regardless. Also, fixing unit tests while at it. --- lib/ansible/modules/network/iosxr/iosxr_facts.py | 4 ++-- test/units/modules/network/iosxr/fixtures/dir_7all | 6 ++++++ .../network/iosxr/fixtures/dir_7all_1_include_Directory | 1 - test/units/modules/network/iosxr/test_iosxr_facts.py | 3 +-- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 test/units/modules/network/iosxr/fixtures/dir_7all delete mode 100644 test/units/modules/network/iosxr/fixtures/dir_7all_1_include_Directory diff --git a/lib/ansible/modules/network/iosxr/iosxr_facts.py b/lib/ansible/modules/network/iosxr/iosxr_facts.py index 5a7237b52b..6ac17dc3aa 100644 --- a/lib/ansible/modules/network/iosxr/iosxr_facts.py +++ b/lib/ansible/modules/network/iosxr/iosxr_facts.py @@ -166,11 +166,11 @@ class Default(FactsBase): class Hardware(FactsBase): def commands(self): - return(['dir /all | include Directory', 'show memory summary']) + return(['dir /all', 'show memory summary']) def populate(self, results): self.facts['filesystems'] = self.parse_filesystems( - results['dir /all | include Directory']) + results['dir /all']) match = re.search(r'Physical Memory (\d+)M total \((\d+)', results['show memory summary']) diff --git a/test/units/modules/network/iosxr/fixtures/dir_7all b/test/units/modules/network/iosxr/fixtures/dir_7all new file mode 100644 index 0000000000..b992498c0e --- /dev/null +++ b/test/units/modules/network/iosxr/fixtures/dir_7all @@ -0,0 +1,6 @@ +Directory of disk0: +file1 +file2 + +Directory of flash0: +file3 diff --git a/test/units/modules/network/iosxr/fixtures/dir_7all_1_include_Directory b/test/units/modules/network/iosxr/fixtures/dir_7all_1_include_Directory deleted file mode 100644 index 38a518f9ac..0000000000 --- a/test/units/modules/network/iosxr/fixtures/dir_7all_1_include_Directory +++ /dev/null @@ -1 +0,0 @@ -lollll diff --git a/test/units/modules/network/iosxr/test_iosxr_facts.py b/test/units/modules/network/iosxr/test_iosxr_facts.py index 1b369116e2..3a307d0875 100644 --- a/test/units/modules/network/iosxr/test_iosxr_facts.py +++ b/test/units/modules/network/iosxr/test_iosxr_facts.py @@ -52,7 +52,6 @@ class TestIosxrFacts(TestIosxrModule): command = item filename = str(command).replace(' ', '_') filename = filename.replace('/', '7') - filename = filename.replace('|', '1') output.append(load_fixture(filename)) return output @@ -66,7 +65,7 @@ class TestIosxrFacts(TestIosxrModule): self.assertIn('default', ansible_facts['ansible_net_gather_subset']) self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset']) self.assertEquals('iosxr01', ansible_facts['ansible_net_hostname']) - self.assertEquals([], ansible_facts['ansible_net_filesystems']) + self.assertEquals(['disk0:', 'flash0:'], ansible_facts['ansible_net_filesystems']) self.assertIn('GigabitEthernet0/0/0/0', ansible_facts['ansible_net_interfaces'].keys())