Skip to content

Commit

Permalink
negated all, min should not return any fact
Browse files Browse the repository at this point in the history
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
  • Loading branch information
trishnaguha committed Sep 4, 2019
1 parent ce1d302 commit f7070b5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
30 changes: 16 additions & 14 deletions lib/ansible/module_utils/network/common/facts/facts.py
Expand Up @@ -90,28 +90,30 @@ def get_network_resources_facts(self, facts_resource_obj_map, resource_facts_typ
if not resource_facts_type:
resource_facts_type = self._gather_network_resources

restorun_subsets = self.gen_runable(resource_facts_type, frozenset(facts_resource_obj_map.keys()), resource_facts=True)
if restorun_subsets:
self.ansible_facts['ansible_net_gather_network_resources'] = list(restorun_subsets)
instances = list()
for key in restorun_subsets:
fact_cls_obj = facts_resource_obj_map.get(key)
if fact_cls_obj:
instances.append(fact_cls_obj(self._module))
else:
self._warnings.extend(["network resource fact gathering for '%s' is not supported" % key])

for inst in instances:
inst.populate_facts(self._connection, self.ansible_facts, data)
restorun_subsets = self.gen_runable(resource_facts_type, frozenset(facts_resource_obj_map.keys()), resource_facts=True)
if restorun_subsets:
self.ansible_facts['ansible_net_gather_network_resources'] = list(restorun_subsets)
instances = list()
for key in restorun_subsets:
fact_cls_obj = facts_resource_obj_map.get(key)
if fact_cls_obj:
instances.append(fact_cls_obj(self._module))
else:
self._warnings.extend(["network resource fact gathering for '%s' is not supported" % key])

for inst in instances:
inst.populate_facts(self._connection, self.ansible_facts, data)

def get_network_legacy_facts(self, fact_legacy_obj_map, legacy_facts_type=None):
if not legacy_facts_type:
legacy_facts_type = self._gather_subset

runable_subsets = self.gen_runable(legacy_facts_type, frozenset(fact_legacy_obj_map.keys()))
runable_subsets.add('default')
if runable_subsets:
facts = dict()
# default subset should always returned be with legacy facts subsets
if 'default' not in runable_subsets:
runable_subsets.add('default')
self.ansible_facts['ansible_net_gather_subset'] = list(runable_subsets)

instances = list()
Expand Down
10 changes: 1 addition & 9 deletions lib/ansible/module_utils/network/exos/argspec/facts/facts.py
Expand Up @@ -17,15 +17,7 @@ class FactsArgs(object): # pylint: disable=R0903
def __init__(self, **kwargs):
pass

choices = [
'all',
'!all',
'lldp_global',
'!lldp_global'
]

argument_spec = {
'gather_subset': dict(default=['!config'], type='list'),
'gather_network_resources': dict(choices=choices,
type='list'),
'gather_network_resources': dict(type='list'),
}
3 changes: 1 addition & 2 deletions lib/ansible/module_utils/network/exos/facts/facts.py
Expand Up @@ -46,9 +46,8 @@ def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None)
:rtype: dict
:return: the facts gathered
"""
netres_choices = FactsArgs.argument_spec['gather_network_resources'].get('choices', [])
if self.VALID_RESOURCE_SUBSETS:
self.get_network_resources_facts(netres_choices, FACT_RESOURCE_SUBSETS, resource_facts_type, data)
self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data)

if self.VALID_LEGACY_GATHER_SUBSETS:
self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type)
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/network/iosxr/facts/facts.py
Expand Up @@ -64,7 +64,7 @@ def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None)
:return: the facts gathered
"""
if self.VALID_RESOURCE_SUBSETS:
self.get_network_resources_facts( FACT_RESOURCE_SUBSETS, resource_facts_type, data)
self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data)

if self.VALID_LEGACY_GATHER_SUBSETS:
self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type)
Expand Down
Expand Up @@ -7,6 +7,7 @@
The arg spec for the junos facts module.
"""


class FactsArgs(object):
""" The arg spec for the junos facts module
"""
Expand Down
4 changes: 3 additions & 1 deletion lib/ansible/modules/network/exos/exos_facts.py
Expand Up @@ -60,7 +60,9 @@
to a given subset. Possible values for this argument include
all and the resources like interfaces, vlans etc.
Can specify a list of values to include a larger subset.
choices: ['all', '!all', 'lldp_global', '!lldp_global']
Values can also be used with an initial C(M(!)) to specify that
a specific subset should not be collected.
Valid subsets are 'all', 'lldp_global'.
type: list
version_added: "2.9"
"""
Expand Down

0 comments on commit f7070b5

Please sign in to comment.