mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-19 23:00:22 -07:00
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:
parent
d395166ae0
commit
ca56a248d8
3 changed files with 89 additions and 1 deletions
|
@ -83,6 +83,7 @@ from ansible.module_utils.pycompat24 import get_exception
|
|||
from ansible.module_utils.netconf import send_request
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
except ImportError:
|
||||
|
@ -138,7 +139,6 @@ class Default(FactsBase):
|
|||
|
||||
reply = self.rpc('get-chassis-inventory')
|
||||
data = reply.find('.//chassis-inventory/chassis')
|
||||
|
||||
self.facts['serialnum'] = self.get_text(data, 'serial-number')
|
||||
|
||||
|
||||
|
@ -183,6 +183,38 @@ class Hardware(FactsBase):
|
|||
filesystems.append(self.get_text(obj, 'filesystem-name'))
|
||||
self.facts['filesystems'] = filesystems
|
||||
|
||||
reply = self.rpc('get-route-engine-information')
|
||||
data = reply.find('.//route-engine-information')
|
||||
|
||||
routing_engines = dict()
|
||||
for obj in data:
|
||||
slot = self.get_text(obj, 'slot')
|
||||
routing_engines.update({slot: {}})
|
||||
routing_engines[slot].update({'slot': slot})
|
||||
for child in obj:
|
||||
if child.text != "\n":
|
||||
routing_engines[slot].update({child.tag.replace("-", "_"): child.text})
|
||||
|
||||
self.facts['routing_engines'] = routing_engines
|
||||
|
||||
if len(data) > 1:
|
||||
self.facts['has_2RE'] = True
|
||||
else:
|
||||
self.facts['has_2RE'] = False
|
||||
|
||||
reply = self.rpc('get-chassis-inventory')
|
||||
data = reply.findall('.//chassis-module')
|
||||
|
||||
modules = list()
|
||||
for obj in data:
|
||||
mod = dict()
|
||||
for child in obj:
|
||||
if child.text != "\n":
|
||||
mod.update({child.tag.replace("-", "_"): child.text})
|
||||
modules.append(mod)
|
||||
|
||||
self.facts['modules'] = modules
|
||||
|
||||
|
||||
class Interfaces(FactsBase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue