Add FQCN mappings for network facts modules (#69601)

* Add FQCN mappings for network facts modules

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Add unit tests

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* update entry for ironware

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
pull/69688/head
Nilashish Chakraborty 5 years ago committed by GitHub
parent fe9696be52
commit dae3ba71a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1322,17 +1322,29 @@ CONNECTION_FACTS_MODULES:
name: Map of connections to fact modules name: Map of connections to fact modules
default: default:
asa: asa_facts asa: asa_facts
cisco.asa.asa: cisco.asa.asa_facts
eos: eos_facts eos: eos_facts
arista.eos.eos: arista.eos.eos_facts
frr: frr_facts frr: frr_facts
frr.frr.frr: frr.frr.frr_facts
ios: ios_facts ios: ios_facts
cisco.ios.ios: cisco.ios.ios_facts
iosxr: iosxr_facts iosxr: iosxr_facts
cisco.iosxr.iosxr: cisco.iosxr.iosxr_facts
junos: junos_facts junos: junos_facts
junipernetworks.junos.junos: junipernetworks.junos.junos_facts
nxos: nxos_facts nxos: nxos_facts
cisco.nxos.nxos: cisco.nxos.nxos_facts
vyos: vyos_facts vyos: vyos_facts
vyos.vyos.vyos: vyos.vyos.vyos_facts
exos: exos_facts exos: exos_facts
extreme.exos.exos: extreme.exos.exos_facts
slxos: slxos_facts slxos: slxos_facts
extreme.slxos.slxos: extreme.slxos.slxos_facts
voss: voss_facts voss: voss_facts
extreme.voss.voss: extreme.voss.voss_facts
ironware: ironware_facts ironware: ironware_facts
community.network.ironware: community.network.ironware_facts
description: "Which modules to run during a play's fact gathering stage based on connection" description: "Which modules to run during a play's fact gathering stage based on connection"
env: [{name: ANSIBLE_CONNECTION_FACTS_MODULES}] env: [{name: ANSIBLE_CONNECTION_FACTS_MODULES}]
ini: ini:

@ -31,7 +31,6 @@ from units.mock.loader import DictDataLoader
class TestNetworkFacts(unittest.TestCase): class TestNetworkFacts(unittest.TestCase):
task = MagicMock(Task) task = MagicMock(Task)
task_vars = {'ansible_network_os': 'ios'}
play_context = MagicMock() play_context = MagicMock()
play_context.check_mode = False play_context.check_mode = False
connection = MagicMock() connection = MagicMock()
@ -46,6 +45,7 @@ class TestNetworkFacts(unittest.TestCase):
pass pass
def test_network_gather_facts(self): def test_network_gather_facts(self):
self.task_vars = {'ansible_network_os': 'ios'}
self.task.action = 'gather_facts' self.task.action = 'gather_facts'
self.task.async_val = False self.task.async_val = False
self.task.args = {'gather_subset': 'min'} self.task.args = {'gather_subset': 'min'}
@ -62,3 +62,22 @@ class TestNetworkFacts(unittest.TestCase):
facts_modules = C.config.get_config_value('FACTS_MODULES', variables=self.task_vars) facts_modules = C.config.get_config_value('FACTS_MODULES', variables=self.task_vars)
self.assertEqual(facts_modules, ['ios_facts']) self.assertEqual(facts_modules, ['ios_facts'])
def test_network_gather_facts_fqcn(self):
self.fqcn_task_vars = {'ansible_network_os': 'cisco.ios.ios'}
self.task.action = 'gather_facts'
self.task.async_val = False
self.task.args = {'gather_subset': 'min'}
self.task.module_defaults = [{'cisco.ios.ios_facts': {'gather_subset': 'min'}}]
plugin = ActionModule(self.task, self.connection, self.play_context, loader=None, templar=self.templar, shared_loader_obj=None)
plugin._execute_module = MagicMock()
res = plugin.run(task_vars=self.fqcn_task_vars)
self.assertEqual(res['ansible_facts']['_ansible_facts_gathered'], True)
mod_args = plugin._get_module_args('cisco.ios.ios_facts', task_vars=self.fqcn_task_vars)
self.assertEqual(mod_args['gather_subset'], 'min')
facts_modules = C.config.get_config_value('FACTS_MODULES', variables=self.fqcn_task_vars)
self.assertEqual(facts_modules, ['cisco.ios.ios_facts'])

Loading…
Cancel
Save