Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_evpn_global.py

raw
1 #!/usr/bin/python
2 #
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17 #
18 from __future__ import absolute_import, division, print_function
19
20
21 __metaclass__ = type
22
23
24 DOCUMENTATION = """
25 module: nxos_evpn_global
26 extends_documentation_fragment:
27 - cisco.nxos.nxos
28 short_description: Handles the EVPN control plane for VXLAN.
29 description:
30 - Handles the EVPN control plane for VXLAN.
31 version_added: 1.0.0
32 author: Gabriele Gerbino (@GGabriele)
33 notes:
34 - This module is not supported on Nexus 3000 series of switches.
35 - Unsupported for Cisco MDS
36 options:
37 nv_overlay_evpn:
38 description:
39 - EVPN control plane.
40 required: true
41 type: bool
42 """
43
44 EXAMPLES = """
45 - cisco.nxos.nxos_evpn_global:
46 nv_overlay_evpn: true
47 """
48
49 RETURN = """
50 commands:
51 description: The set of commands to be sent to the remote device
52 returned: always
53 type: list
54 sample: ['nv overlay evpn']
55 """
56
57 from ansible.module_utils.basic import AnsibleModule
58
59 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import (
60 get_capabilities,
61 get_config,
62 load_config,
63 )
64
65
66 def main():
67 argument_spec = dict(nv_overlay_evpn=dict(required=True, type="bool"))
68
69 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
70
71 result = {"changed": False}
72
73 warnings = list()
74 if warnings:
75 result["warnings"] = warnings
76
77 config = get_config(module)
78 commands = list()
79
80 info = get_capabilities(module).get("device_info", {})
81 os_platform = info.get("network_os_platform", "")
82
83 if "3K" in os_platform:
84 module.fail_json(msg="This module is not supported on Nexus 3000 series")
85
86 if module.params["nv_overlay_evpn"] is True:
87 if "nv overlay evpn" not in config:
88 commands.append("nv overlay evpn")
89 elif "nv overlay evpn" in config:
90 commands.append("no nv overlay evpn")
91
92 if commands:
93 if not module.check_mode:
94 load_config(module, commands)
95 result["changed"] = True
96
97 result["commands"] = commands
98
99 module.exit_json(**result)
100
101
102 if __name__ == "__main__":
103 main()