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

update junos_facts module to remove get_module() factory function (#4760)

Replaces get_module() with NetworkModule instance
This commit is contained in:
Peter Sprygada 2016-09-09 12:22:43 -04:00 committed by Matt Clay
parent 290a4b5fac
commit 09b8e220ca

View file

@ -85,6 +85,8 @@ ansible_facts:
returned: always returned: always
type: dict type: dict
""" """
from ansible.module_utils.junos import NetworkModule
from ansible.module_utils.junos import xml_to_string, xml_to_json
def main(): def main():
""" Main entry point for AnsibleModule """ Main entry point for AnsibleModule
@ -95,12 +97,12 @@ def main():
transport=dict(default='netconf', choices=['netconf']) transport=dict(default='netconf', choices=['netconf'])
) )
module = get_module(argument_spec=spec, module = NetworkModule(argument_spec=spec,
supports_check_mode=True) supports_check_mode=True)
result = dict(changed=False) result = dict(changed=False)
facts = module.get_facts() facts = module.connection.get_facts()
if '2RE' in facts: if '2RE' in facts:
facts['has_2RE'] = facts['2RE'] facts['has_2RE'] = facts['2RE']
@ -110,7 +112,7 @@ def main():
if module.params['config'] is True: if module.params['config'] is True:
config_format = module.params['config_format'] config_format = module.params['config_format']
resp_config = module.get_config( config_format=config_format) resp_config = module.config.get_config(config_format=config_format)
if config_format in ['text', 'set']: if config_format in ['text', 'set']:
facts['config'] = resp_config facts['config'] = resp_config
@ -121,8 +123,6 @@ def main():
result['ansible_facts'] = facts result['ansible_facts'] = facts
module.exit_json(**result) module.exit_json(**result)
from ansible.module_utils.basic import *
from ansible.module_utils.junos import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()