ios_facts: Report space of file systems (#41850)

* ios_facts: Report file system space

Parse total and free space from dir output. For this, add a hash
filesystems_info containing the keys spacetotal_kb and spacefree_kb.

* ios_facts: Add unit test for file system space reporting

* ios_facts: Add integration test for file system space reporting
This commit is contained in:
Paul Neumann 2018-07-09 15:15:31 +02:00 committed by Nathaniel Case
parent dbb58b34c3
commit dfb2b3fdd5
7 changed files with 62 additions and 0 deletions

View file

@ -28,4 +28,8 @@
- "result.ansible_facts.ansible_net_memfree_mb > 1"
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
- assert:
that: "{{ item.value.spacetotal_kb }} > {{ item.value.spacefree_kb }}"
loop: "{{ lookup('dict', result.ansible_facts.ansible_net_filesystems_info, wantlist=True) }}"
- debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}"

View file

@ -28,4 +28,8 @@
# ... and not present
- "result.ansible_facts.ansible_net_config is not defined" # config
- assert:
that: "{{ item.value.spacetotal_kb }} > {{ item.value.spacefree_kb }}"
loop: "{{ lookup('dict', result.ansible_facts.ansible_net_filesystems_info, wantlist=True) }}"
- debug: msg="END cli/default.yaml on connection={{ ansible_connection }}"

View file

@ -26,5 +26,6 @@
- "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
# ... and not present
- "result.ansible_facts.ansible_net_filesystems is not defined"
- "result.ansible_facts.ansible_net_filesystems_info is not defined"
- debug: msg="END cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"

View file

@ -0,0 +1,23 @@
Directory of bootflash:/
11 drwx 16384 Jun 1 2017 13:03:27 +00:00 lost+found
325121 drwx 4096 Jun 1 2017 13:03:54 +00:00 .super.iso.dir
12 -rw- 31 Jun 22 2018 15:17:06 +00:00 .CsrLxc_LastInstall
13 -rw- 69 Jun 1 2017 13:05:53 +00:00 virtual-instance.conf
438913 drwx 4096 Jun 1 2017 13:04:57 +00:00 core
15 -rw- 125736960 Jun 1 2017 13:03:54 +00:00 iosxe-remote-mgmt.16.03.04.ova
105667 -rw- 292164568 Jun 1 2017 13:04:04 +00:00 csr1000v-mono-universalk9.16.03.04.SPA.pkg
105668 -rw- 34370768 Jun 1 2017 13:04:10 +00:00 csr1000v-rpboot.16.03.04.SPA.pkg
105666 -rw- 5317 Jun 1 2017 13:04:10 +00:00 packages.conf
195073 drwx 4096 Jun 1 2017 13:04:51 +00:00 .prst_sync
414529 drwx 4096 Jun 1 2017 13:04:57 +00:00 .rollback_timer
16 -rw- 0 Jun 1 2017 13:05:00 +00:00 tracelogs.kZn
16257 drwx 24576 Jun 22 2018 16:03:11 +00:00 tracelogs
349505 drwx 4096 Jun 1 2017 13:05:08 +00:00 .installer
292609 drwx 4096 Jun 1 2017 13:05:59 +00:00 virtual-instance
17 -rw- 30 Jun 22 2018 15:17:59 +00:00 throughput_monitor_params
48769 drwx 4096 Jun 1 2017 13:06:04 +00:00 onep
19 -rw- 376 Jun 22 2018 15:18:11 +00:00 csrlxc-cfg.log
20 -rw- 0 Jun 22 2018 15:17:59 +00:00 cvac.log
7897796608 bytes total (6608056320 bytes free)

View file

@ -77,3 +77,13 @@ class TestIosFactsModule(TestIosModule):
self.assertIsNone(
result['ansible_facts']['ansible_net_interfaces']['Tunnel1110']['macaddress']
)
def test_ios_facts_filesystems_info(self):
set_module_args(dict(gather_subset='hardware'))
result = self.execute_module()
self.assertEqual(
result['ansible_facts']['ansible_net_filesystems_info']['bootflash:']['spacetotal_kb'], 7712692.0
)
self.assertEqual(
result['ansible_facts']['ansible_net_filesystems_info']['bootflash:']['spacefree_kb'], 6453180.0
)