1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

nxos_facts cleanup (#26192)

This commit is contained in:
Nathaniel Case 2017-07-13 16:56:04 -04:00 committed by GitHub
parent f3acf9c929
commit 62e4353ba1

View file

@ -52,17 +52,6 @@ options:
""" """
EXAMPLES = """ EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
username: admin
password: admin
transport: cli
---
- nxos_facts: - nxos_facts:
gather_subset: all gather_subset: all
@ -233,6 +222,7 @@ class Default(FactsBase):
if data: if data:
self.facts.update(self.transform_dict(data, self.VERSION_MAP)) self.facts.update(self.transform_dict(data, self.VERSION_MAP))
class Config(FactsBase): class Config(FactsBase):
def populate(self): def populate(self):
@ -243,7 +233,6 @@ class Config(FactsBase):
class Hardware(FactsBase): class Hardware(FactsBase):
def populate(self): def populate(self):
cmd = {'command': 'dir', 'output': 'text'},
data = self.run('dir', 'text') data = self.run('dir', 'text')
if data: if data:
self.facts['filesystems'] = self.parse_filesystems(data) self.facts['filesystems'] = self.parse_filesystems(data)
@ -321,8 +310,7 @@ class Interfaces(FactsBase):
if data.startswith('ERROR'): if data.startswith('ERROR'):
return dict() return dict()
lines = data.split('\n') regex = re.compile(r'(\S+)\s+(\S+)\s+\d+\s+\w+\s+(\S+)')
regex = re.compile('(\S+)\s+(\S+)\s+\d+\s+\w+\s+(\S+)')
for item in data.split('\n')[4:-1]: for item in data.split('\n')[4:-1]:
match = regex.match(item) match = regex.match(item)
@ -358,6 +346,7 @@ class Interfaces(FactsBase):
intf['ipv6'] = self.transform_dict(item, self.INTERFACE_IPV6_MAP) intf['ipv6'] = self.transform_dict(item, self.INTERFACE_IPV6_MAP)
self.facts['all_ipv6_addresses'].append(item['ROW_intf']['addr']) self.facts['all_ipv6_addresses'].append(item['ROW_intf']['addr'])
class Legacy(FactsBase): class Legacy(FactsBase):
# facts from nxos_facts 2.1 # facts from nxos_facts 2.1
@ -457,6 +446,7 @@ FACT_SUBSETS = dict(
VALID_SUBSETS = frozenset(FACT_SUBSETS.keys()) VALID_SUBSETS = frozenset(FACT_SUBSETS.keys())
def main(): def main():
spec = dict( spec = dict(
gather_subset=dict(default=['!config'], type='list') gather_subset=dict(default=['!config'], type='list')