summaryrefslogtreecommitdiff
path: root/plugins/modules/vyos_lldp.py
diff options
context:
space:
mode:
authorBradley A. Thornton <bthornto@thethorntons.net>2019-08-09 10:48:27 -0700
committerBradley A. Thornton <bthornto@thethorntons.net>2019-08-09 10:48:27 -0700
commit5fb9df4e907a6ab2da7a6c2dafdec9c1971e8d44 (patch)
tree4459ed61d06c8d8caabbcc3ab36d84e27a919ee7 /plugins/modules/vyos_lldp.py
parent7b9a33a29007ed302c3001566061e22c514cde64 (diff)
downloadvyos-ansible-collection-5fb9df4e907a6ab2da7a6c2dafdec9c1971e8d44.tar.gz
vyos-ansible-collection-5fb9df4e907a6ab2da7a6c2dafdec9c1971e8d44.zip
bt_blackked
Diffstat (limited to 'plugins/modules/vyos_lldp.py')
-rw-r--r--plugins/modules/vyos_lldp.py49
1 files changed, 27 insertions, 22 deletions
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()