junos_facts: Add Hardware facts. (#30304)

* Add Routing Engine Facts

 - Map routing engine output information to routing_engines facts dict.
 - Add fact 'has_2RE', which is a quick way to determine how many REs
   the chassis has.

* Fix a typo

* Fix more typos

* Add slot number to routing_engine dict

* Add facts about the installed chassis modules

* Fix typo

* Fixed another typo

* Fix Path

* Change path again.

* More Typos

* Add some deubgging

* Add additional information for hardware components.

 - Return information about the Routing Engines.
 - Return a fact to easily determine if the device
   has two routing engines.
 - Return information about the hardware modules.

* Addressed pep8 stardard failures.

* Add unit test fixtures.

* Rename fixture.

* Fix unit test failures.

 - Rename the fixture file to what the unit test expects.
 - Strip out junos namespace attributes.
Rename file to match what the unit test expects.

* Scrubbed the routing engine serial numbers.

* Add unit test facts for new tests.

 - Add unit test for ansible_net_routing_engines fact
 - Add unit test for ansible_net_modules fact
 - Add unit test for ansible_net_has_2RE

* Fixed spacing.
This commit is contained in:
dteach 2017-09-20 00:13:07 -07:00 committed by Ganesh Nalawade
parent d395166ae0
commit ca56a248d8
3 changed files with 89 additions and 1 deletions

View file

@ -28,6 +28,7 @@ RPC_CLI_MAP = {
'get-interface-information': 'show interfaces details',
'get-system-memory-information': 'show system memory',
'get-chassis-inventory': 'show chassis hardware',
'get-route-engine-information': 'show chassis routing-engine',
'get-system-storage': 'show system storage'
}
@ -72,6 +73,9 @@ class TestJunosCommandModule(TestJunosModule):
self.assertEqual(facts['ansible_net_memtotal_mb'], 983500)
self.assertEqual(facts['ansible_net_filesystems'][0], '/dev/vtbd0s1a')
self.assertTrue('ansible_net_config' not in facts)
self.assertEqual(facts['ansible_net_routing_engines']["0"]['model'], 'RE-S-EX9200-1800X4')
self.assertEqual(facts['ansible_net_modules'][0]['name'], 'Midplane')
self.assertTrue(facts['ansible_net_has_2RE'])
def test_junos_get_facts_subset_config_set(self):
self.get_config.return_value = load_fixture('get_configuration_rpc_reply.txt')