summaryrefslogtreecommitdiff
path: root/plugins/modules/vyos_lldp.py
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2019-08-09 18:52:36 +0000
committerGitHub <noreply@github.com>2019-08-09 18:52:36 +0000
commitfbe294b702e757252a66f64edf66bce060e87494 (patch)
tree6910d3c526815c0e21f20cfbccd08bea727cf11c /plugins/modules/vyos_lldp.py
parent4a485b24db1abf87cdf0d4ef2f7acb1159aaab68 (diff)
parent5fb9df4e907a6ab2da7a6c2dafdec9c1971e8d44 (diff)
downloadvyos.vyos-fbe294b702e757252a66f64edf66bce060e87494.tar.gz
vyos.vyos-fbe294b702e757252a66f64edf66bce060e87494.zip
Merge pull request #8 from ansible-network/bt_blacked
Bt blacked Reviewed-by: Paul Belanger https://github.com/pabelanger
Diffstat (limited to 'plugins/modules/vyos_lldp.py')
-rw-r--r--plugins/modules/vyos_lldp.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/plugins/modules/vyos_lldp.py b/plugins/modules/vyos_lldp.py
index fa1ac03a..69a62a31 100644
--- a/plugins/modules/vyos_lldp.py
+++ b/plugins/modules/vyos_lldp.py
@@ -19,9 +19,11 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-ANSIBLE_METADATA = {'metadata_version': '1.1',
- 'status': ['preview'],
- 'supported_by': 'network'}
+ANSIBLE_METADATA = {
+ "metadata_version": "1.1",
+ "status": ["preview"],
+ "supported_by": "network",
+}
DOCUMENTATION = """
@@ -63,18 +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 vyos_argument_spec
+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,
+)
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,42 +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()