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:
parent
f3acf9c929
commit
62e4353ba1
1 changed files with 6 additions and 16 deletions
|
@ -35,8 +35,8 @@ description:
|
||||||
base set of facts from the device and can enable or disable
|
base set of facts from the device and can enable or disable
|
||||||
collection of additional facts.
|
collection of additional facts.
|
||||||
author:
|
author:
|
||||||
- Jason Edelman (@jedelman8)
|
- Jason Edelman (@jedelman8)
|
||||||
- Gabriele Gerbino (@GGabriele)
|
- Gabriele Gerbino (@GGabriele)
|
||||||
options:
|
options:
|
||||||
gather_subset:
|
gather_subset:
|
||||||
description:
|
description:
|
||||||
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue