Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_lacp_interfaces.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_interfaces
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: nxos_lacp_interfaces
37 short_description: LACP interfaces resource module
38 description: This module manages Link Aggregation Control Protocol (LACP) attributes
39 of NX-OS Interfaces.
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 options:
46 running_config:
47 description:
48 - This option is used only with state I(parsed).
49 - The value of this option should be the output received from the NX-OS device
50 by executing the command B(show running-config | section ^interface).
51 - The state I(parsed) reads the configuration from C(running_config) option and
52 transforms it into Ansible structured data as per the resource module's argspec
53 and the value is then returned in the I(parsed) key within the result.
54 type: str
55 config:
56 description: A dictionary of LACP interfaces options.
57 type: list
58 elements: dict
59 suboptions:
60 name:
61 description:
62 - Name of the interface.
63 required: true
64 type: str
65 port_priority:
66 description:
67 - LACP port priority for the interface. Range 1-65535. Applicable only for
68 Ethernet.
69 type: int
70 rate:
71 description:
72 - Rate at which PDUs are sent by LACP. Applicable only for Ethernet. At fast
73 rate LACP is transmitted once every 1 second. At normal rate LACP is transmitted
74 every 30 seconds after the link is bundled.
75 type: str
76 choices:
77 - fast
78 - normal
79 links:
80 description:
81 - This dict contains configurable options related to max and min port-channel
82 links. Applicable only for Port-channel.
83 type: dict
84 suboptions:
85 max:
86 description:
87 - Port-channel max bundle.
88 type: int
89 min:
90 description:
91 - Port-channel min links.
92 type: int
93 mode:
94 description:
95 - LACP mode. Applicable only for Port-channel.
96 type: str
97 choices:
98 - delay
99 suspend_individual:
100 description:
101 - port-channel lacp state. Disabling this will cause lacp to put the port
102 to individual state and not suspend the port in case it does not get LACP
103 BPDU from the peer ports in the port-channel.
104 type: bool
105 convergence:
106 description:
107 - This dict contains configurable options related to convergence. Applicable
108 only for Port-channel.
109 type: dict
110 suboptions:
111 graceful:
112 description:
113 - port-channel lacp graceful convergence. Disable this only with lacp
114 ports connected to Non-Nexus peer. Disabling this with Nexus peer can
115 lead to port suspension.
116 type: bool
117 vpc:
118 description:
119 - Enable lacp convergence for vPC port channels.
120 type: bool
121 state:
122 description:
123 - The state of the configuration after module completion.
124 type: str
125 choices:
126 - merged
127 - replaced
128 - overridden
129 - deleted
130 - gathered
131 - rendered
132 - parsed
133 default: merged
134
135 """
136 EXAMPLES = """
137 # Using merged
138
139 # Before state:
140 # -------------
141 #
142
143 - name: Merge provided configuration with device configuration.
144 cisco.nxos.nxos_lacp_interfaces:
145 config:
146 - name: Ethernet1/3
147 port_priority: 5
148 rate: fast
149 state: merged
150
151 # After state:
152 # ------------
153 #
154 # interface Ethernet1/3
155 # lacp port-priority 5
156 # lacp rate fast
157
158
159 # Using replaced
160
161 # Before state:
162 # -------------
163 #
164 # interface Ethernet1/3
165 # lacp port-priority 5
166 # interface port-channel11
167 # lacp mode delay
168
169 - name: Replace device lacp interfaces configuration with the given configuration.
170 cisco.nxos.nxos_lacp_interfaces:
171 config:
172 - name: port-channel11
173 links:
174 min: 4
175 state: replaced
176
177 # After state:
178 # ------------
179 #
180 # interface Ethernet1/3
181 # lacp port-priority 5
182 # interface port-channel11
183 # lacp min-links 4
184
185
186 # Using overridden
187
188 # Before state:
189 # -------------
190 #
191 # interface Ethernet1/3
192 # lacp port-priority 5
193 # interface port-channel11
194 # lacp mode delay
195
196 - name: Override device configuration of all LACP interfaces attributes of given interfaces
197 on device with provided configuration.
198 cisco.nxos.nxos_lacp_interfaces:
199 config:
200 - name: port-channel11
201 links:
202 min: 4
203 state: overridden
204
205 # After state:
206 # ------------
207 #
208 # interface port-channel11
209 # lacp min-links 4
210
211
212 # Using deleted
213
214 # Before state:
215 # -------------
216 #
217 # interface Ethernet1/3
218 # lacp port-priority 5
219 # interface port-channel11
220 # lacp mode delay
221
222 - name: Delete LACP interfaces configurations.
223 cisco.nxos.nxos_lacp_interfaces:
224 state: deleted
225
226 # After state:
227 # ------------
228 #
229
230 # Using rendered
231
232 - name: Use rendered state to convert task input to device specific commands
233 cisco.nxos.nxos_lacp_interfaces:
234 config:
235 - name: Ethernet1/800
236 rate: fast
237 - name: Ethernet1/801
238 rate: fast
239 port_priority: 32
240 - name: port-channel10
241 links:
242 max: 15
243 min: 2
244 convergence:
245 graceful: true
246 state: rendered
247
248 # Task Output (redacted)
249 # -----------------------
250
251 # rendered:
252 # - "interface Ethernet1/800"
253 # - "lacp rate fast"
254 # - "interface Ethernet1/801"
255 # - "lacp port-priority 32"
256 # - "lacp rate fast"
257 # - "interface port-channel10"
258 # - "lacp min-links 2"
259 # - "lacp max-bundle 15"
260 # - "lacp graceful-convergence"
261
262 # Using parsed
263
264 # parsed.cfg
265 # ------------
266
267 # interface port-channel10
268 # lacp min-links 10
269 # lacp max-bundle 15
270 # interface Ethernet1/800
271 # lacp port-priority 100
272 # lacp rate fast
273
274 - name: Use parsed state to convert externally supplied config to structured format
275 cisco.nxos.nxos_lacp_interfaces:
276 running_config: "{{ lookup('file', 'parsed.cfg') }}"
277 state: parsed
278
279 # Task output (redacted)
280 # -----------------------
281
282 # parsed:
283 # - name: port-channel10
284 # links:
285 # max: 15
286 # min: 10
287 # - name: Ethernet1/800
288 # port_priority: 100
289 # rate: fast
290
291 # Using gathered
292
293 # Existing device config state
294 # -------------------------------
295 # interface Ethernet1/1
296 # lacp port-priority 5
297 # lacp rate fast
298 # interface port-channel10
299 # lacp mode delay
300 # interface port-channel11
301 # lacp max-bundle 10
302 # lacp min-links 5
303
304 - name: Gather lacp_interfaces facts from the device using nxos_lacp_interfaces
305 cisco.nxos.nxos_lacp_interfaces:
306 state: gathered
307
308 # Task output (redacted)
309 # -----------------------
310 # gathered:
311 # - name: Ethernet1/1
312 # port_priority: 5
313 # rate: fast
314 # - name: port-channel10
315 # mode: delay
316 # - name: port-channel11
317 # links:
318 # max: 10
319 # min: 5
320 """
321 RETURN = """
322 before:
323 description: The configuration as structured data prior to module invocation.
324 returned: always
325 type: list
326 sample: >
327 The configuration returned will always be in the same format
328 of the parameters above.
329 after:
330 description: The configuration as structured data after module completion.
331 returned: when changed
332 type: list
333 sample: >
334 The configuration returned will always be in the same format
335 of the parameters above.
336 commands:
337 description: The set of commands pushed to the remote device.
338 returned: always
339 type: list
340 sample: ['interface port-channel10', 'lacp min-links 5', 'lacp mode delay']
341 """
342
343
344 from ansible.module_utils.basic import AnsibleModule
345
346 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp_interfaces.lacp_interfaces import (
347 Lacp_interfacesArgs,
348 )
349 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lacp_interfaces.lacp_interfaces import (
350 Lacp_interfaces,
351 )
352
353
354 def main():
355 """
356 Main entry point for module execution
357
358 :returns: the result form module invocation
359 """
360 required_if = [
361 ("state", "merged", ("config",)),
362 ("state", "replaced", ("config",)),
363 ("state", "overridden", ("config",)),
364 ("state", "rendered", ("config",)),
365 ("state", "parsed", ("running_config",)),
366 ]
367 mutually_exclusive = [("config", "running_config")]
368
369 module = AnsibleModule(
370 argument_spec=Lacp_interfacesArgs.argument_spec,
371 required_if=required_if,
372 mutually_exclusive=mutually_exclusive,
373 supports_check_mode=True,
374 )
375
376 result = Lacp_interfaces(module).execute_module()
377 module.exit_json(**result)
378
379
380 if __name__ == "__main__":
381 main()