From 5fb9df4e907a6ab2da7a6c2dafdec9c1971e8d44 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 9 Aug 2019 10:48:27 -0700 Subject: bt_blackked --- plugins/modules/vyos_lldp.py | 49 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'plugins/modules/vyos_lldp.py') diff --git a/plugins/modules/vyos_lldp.py b/plugins/modules/vyos_lldp.py index 5e33000..69a62a3 100644 --- a/plugins/modules/vyos_lldp.py +++ b/plugins/modules/vyos_lldp.py @@ -20,11 +20,12 @@ # ANSIBLE_METADATA = { - 'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'network' + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", } + DOCUMENTATION = """ --- module: vyos_lldp @@ -64,17 +65,20 @@ commands: - set service lldp """ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.vyos.vyos.plugins.module_utils.network. \ - vyos.vyos import get_config, load_config +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) -from ansible_collections.vyos.vyos.plugins.module_utils.network. \ - vyos.vyos import vyos_argument_spec +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) def has_lldp(module): config = get_config(module).splitlines() - if "set service 'lldp'" in config or 'set service lldp' in config: + if "set service 'lldp'" in config or "set service lldp" in config: return True else: return False @@ -84,40 +88,41 @@ def main(): """ main entry point for module execution """ argument_spec = dict( - interfaces=dict(type='list'), - state=dict(default='present', - choices=['present', 'absent', 'enabled', 'disabled'])) + interfaces=dict(type="list"), + state=dict( + default="present", choices=["present", "absent", "enabled", "disabled"] + ), + ) argument_spec.update(vyos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, - supports_check_mode=True) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() - result = {'changed': False} + result = {"changed": False} if warnings: - result['warnings'] = warnings + result["warnings"] = warnings HAS_LLDP = has_lldp(module) commands = [] - if module.params['state'] == 'absent' and HAS_LLDP: - commands.append('delete service lldp') - elif module.params['state'] == 'present' and not HAS_LLDP: - commands.append('set service lldp') + if module.params["state"] == "absent" and HAS_LLDP: + commands.append("delete service lldp") + elif module.params["state"] == "present" and not HAS_LLDP: + commands.append("set service lldp") - result['commands'] = commands + result["commands"] = commands if commands: commit = not module.check_mode load_config(module, commands, commit=commit) - result['changed'] = True + result["changed"] = True module.exit_json(**result) -if __name__ == '__main__': +if __name__ == "__main__": main() -- cgit v1.2.3