Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2019 Red Hat
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 #############################################
8 # WARNING #
9 #############################################
10 #
11 # This file is auto generated by the resource
12 # module builder playbook.
13 #
14 # Do not edit this file manually.
15 #
16 # Changes to this file will be over written
17 # by the resource module builder.
18 #
19 # Changes should be made in the model used to
20 # generate this file or in the resource module
21 # builder template.
22 #
23 #############################################
24
25 """
26 The module file for nxos_lacp
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: nxos_lacp
37 short_description: LACP resource module
38 description: This module manages Global Link Aggregation Control Protocol (LACP) on
39 NX-OS devices.
40 version_added: 1.0.0
41 author: Trishna Guha (@trishnaguha)
42 notes:
43 - Tested against NXOS 7.3.(0)D1(1) on VIRL.
44 - Unsupported for Cisco MDS
45 - Feature lacp should be enabled for this module.
46 options:
47 running_config:
48 description:
49 - This option is used only with state I(parsed).
50 - The value of this option should be the output received from the NX-OS device
51 by executing the command B(show running-config | include lacp).
52 - The state I(parsed) reads the configuration from C(running_config) option and
53 transforms it into Ansible structured data as per the resource module's argspec
54 and the value is then returned in the I(parsed) key within the result.
55 type: str
56 config:
57 description: LACP global options.
58 type: dict
59 suboptions:
60 system:
61 description:
62 - LACP system options
63 type: dict
64 suboptions:
65 priority:
66 description:
67 - The system priority to use in LACP negotiations.
68 type: int
69 mac:
70 description:
71 - MAC address to be used for the LACP Protocol exchanges
72 type: dict
73 suboptions:
74 address:
75 description:
76 - MAC-address (FORMAT :xxxx.xxxx.xxxx).
77 type: str
78 role:
79 description:
80 - The role for the Switch.
81 type: str
82 choices:
83 - primary
84 - secondary
85 state:
86 description:
87 - The state of the configuration after module completion.
88 - States C(replaced) and C(overridden) have the same behaviour for this module.
89 type: str
90 choices:
91 - merged
92 - replaced
93 - overridden
94 - deleted
95 - gathered
96 - rendered
97 - parsed
98 default: merged
99
100 """
101 EXAMPLES = """
102 # Using merged
103
104 # Before state:
105 # -------------
106 #
107
108 - name: Merge provided configuration with device configuration.
109 cisco.nxos.nxos_lacp:
110 config:
111 system:
112 priority: 10
113 mac:
114 address: 00c1.4c00.bd15
115 state: merged
116
117 # After state:
118 # ------------
119 #
120 # lacp system-priority 10
121 # lacp system-mac 00c1.4c00.bd15
122
123
124 # Using replaced
125
126 # Before state:
127 # -------------
128 #
129 # lacp system-priority 10
130
131 - name: Replace device global lacp configuration with the given configuration.
132 cisco.nxos.nxos_lacp:
133 config:
134 system:
135 mac:
136 address: 00c1.4c00.bd15
137 state: replaced
138
139 # After state:
140 # ------------
141 #
142 # lacp system-mac 00c1.4c00.bd15
143
144
145 # Using deleted
146
147 # Before state:
148 # -------------
149 #
150 # lacp system-priority 10
151
152 - name: Delete global LACP configurations.
153 cisco.nxos.nxos_lacp:
154 state: deleted
155
156 # After state:
157 # ------------
158 #
159
160 # Using rendered
161
162 - name: Render platform specific configuration lines (without connecting to the device)
163 cisco.nxos.nxos_lacp:
164 config:
165 system:
166 priority: 10
167 mac:
168 address: 00c1.4c00.bd15
169 role: secondary
170 state: rendered
171
172 # Task Output (redacted)
173 # -----------------------
174
175 # rendered:
176 # - "lacp system-priority 10"
177 # - "lacp system-mac 00c1.4c00.bd15 role secondary"
178
179 # Using parsed
180
181 # parsed.cfg
182 # ------------
183 # lacp system-priority 10
184 # lacp system-mac 00c1.4c00.bd15 role secondary
185
186 - name: Use parsed state to convert externally supplied config to structured format
187 cisco.nxos.nxos_lacp:
188 running_config: "{{ lookup('file', 'parsed.cfg') }}"
189 state: parsed
190
191 # Task output (redacted)
192 # -----------------------
193 # parsed:
194 # system:
195 # priority: 10
196 # mac:
197 # address: 00c1.4c00.bd15
198 # role: secondary
199
200 # Using gathered
201
202 # Existing device config state
203 # -------------------------------
204 # Nexus9000v# show running-config | include lacp
205 # lacp system-priority 11
206 # lacp system-mac 00c1.4c00.bd15 role primary
207
208 - name: Gather lacp facts from the device using nxos_lacp
209 cisco.nxos.nxos_lacp:
210 state: gathered
211
212 # Task output (redacted)
213 # -----------------------
214 # gathered:
215 # system:
216 # priority: 11
217 # mac:
218 # address: 00c1.4c00.bd15
219 # role: primary
220 """
221 RETURN = """
222 before:
223 description: The configuration as structured data prior to module invocation.
224 returned: always
225 type: dict
226 sample: >
227 The configuration returned will always be in the same format
228 of the parameters above.
229 after:
230 description: The configuration as structured data after module completion.
231 returned: when changed
232 type: dict
233 sample: >
234 The configuration returned will always be in the same format
235 of the parameters above.
236 commands:
237 description: The set of commands pushed to the remote device.
238 returned: always
239 type: list
240 sample: ['lacp system-priority 15', 'lacp system-mac 00c1.4c00.bd15 role primary']
241 """
242
243
244 from ansible.module_utils.basic import AnsibleModule
245
246 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp.lacp import (
247 LacpArgs,
248 )
249 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lacp.lacp import Lacp
250
251
252 def main():
253 """
254 Main entry point for module execution
255
256 :returns: the result form module invocation
257 """
258 required_if = [
259 ("state", "merged", ("config",)),
260 ("state", "replaced", ("config",)),
261 ("state", "rendered", ("config",)),
262 ("state", "parsed", ("running_config",)),
263 ]
264 mutually_exclusive = [("config", "running_config")]
265
266 module = AnsibleModule(
267 argument_spec=LacpArgs.argument_spec,
268 required_if=required_if,
269 mutually_exclusive=mutually_exclusive,
270 supports_check_mode=True,
271 )
272
273 result = Lacp(module).execute_module()
274 module.exit_json(**result)
275
276
277 if __name__ == "__main__":
278 main()