diff options
Diffstat (limited to 'plugins/modules/vyos_lldp.py')
| -rw-r--r-- | plugins/modules/vyos_lldp.py | 51 | 
1 files changed, 27 insertions, 24 deletions
| diff --git a/plugins/modules/vyos_lldp.py b/plugins/modules/vyos_lldp.py index fa1ac03..69a62a3 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() | 
