Debian Codegraph @

ansible_collections/cisco/iosxr/plugins/modules/iosxr_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 iosxr_lacp_interfaces
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: iosxr_lacp_interfaces
37 short_description: Resource module to configure LACP interfaces.
38 description:
39 - This module manages Link Aggregation Control Protocol (LACP) attributes of interfaces
40 on IOS-XR devices.
41 version_added: 1.0.0
42 notes:
43 - This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html).
44 author: Nilashish Chakraborty (@nilashishc)
45 options:
46 config:
47 description: A dictionary of LACP interfaces options.
48 type: list
49 elements: dict
50 suboptions:
51 name:
52 description:
53 - Name/Identifier of the interface or Ether-Bundle.
54 type: str
55 churn_logging:
56 description:
57 - Specifies the parameter for logging of LACP churn events.
58 - Valid only for ether-bundles.
59 - Mode 'actor' logs actor churn events only.
60 - Mode 'partner' logs partner churn events only.
61 - Mode 'both' logs actor and partner churn events only.
62 type: str
63 choices:
64 - actor
65 - partner
66 - both
67 collector_max_delay:
68 description:
69 - Specifies the collector max delay to be signaled to the LACP partner.
70 - Valid only for ether-bundles.
71 - Refer to vendor documentation for valid values.
72 type: int
73 period:
74 description:
75 - Specifies the rate at which packets are sent or received.
76 - For ether-bundles, this specifies the period to be used by its member links.
77 - Refer to vendor documentation for valid values.
78 type: int
79 switchover_suppress_flaps:
80 description:
81 - Specifies the time for which to suppress flaps during a LACP switchover.
82 - Valid only for ether-bundles.
83 - Refer to vendor documentation for valid values.
84 type: int
85 system:
86 description:
87 - This dict object contains configurable options related to LACP system parameters
88 for ether-bundles.
89 type: dict
90 suboptions:
91 priority:
92 description:
93 - Specifies the system priority to use in LACP negotiations for the bundle.
94 - Refer to vendor documentation for valid values.
95 type: int
96 mac:
97 description:
98 - Specifies the system ID to use in LACP negotiations for the bundle,
99 encoded as a MAC address.
100 type: str
101 running_config:
102 description:
103 - This option is used only with state I(parsed).
104 - The value of this option should be the output received from the IOS-XR device
105 by executing the command B(show running-config int).
106 - The state I(parsed) reads the configuration from C(running_config) option and
107 transforms it into Ansible structured data as per the resource module's argspec
108 and the value is then returned in the I(parsed) key within the result.
109 type: str
110 state:
111 description:
112 - The state of the configuration after module completion.
113 type: str
114 choices:
115 - merged
116 - replaced
117 - overridden
118 - deleted
119 - parsed
120 - gathered
121 - rendered
122 default: merged
123
124 """
125 EXAMPLES = """
126 # Using merged
127 #
128 #
129 # ------------
130 # Before state
131 # ------------
132 #
133 #
134 #
135 # RP/0/0/CPU0:an-iosxr#sh running-config interface
136 # Sun Jul 21 18:01:35.079 UTC
137 # interface Bundle-Ether10
138 # !
139 # interface Bundle-Ether11
140 # !
141 # interface Bundle-Ether12
142 # !
143 # interface Loopback888
144 # description test for ansible
145 # shutdown
146 # !
147 # interface MgmtEth0/0/CPU0/0
148 # ipv4 address 192.0.2.11 255.255.255.0
149 # !
150 # interface GigabitEthernet0/0/0/1
151 # description 'GigabitEthernet - 1'
152 # !
153 # interface GigabitEthernet0/0/0/2
154 # description "GigabitEthernet - 2"
155 # !
156 # interface GigabitEthernet0/0/0/3
157 # description "GigabitEthernet - 3"
158 # !
159 # interface GigabitEthernet0/0/0/4
160 # description "GigabitEthernet - 4"
161 # !
162 #
163 #
164
165 - name: Merge provided configuration with device configuration
166 cisco.iosxr.iosxr_lacp_interfaces:
167 config:
168 - name: Bundle-Ether10
169 churn_logging: actor
170 collector_max_delay: 100
171 switchover_suppress_flaps: 500
172 - name: Bundle-Ether11
173 system:
174 mac: 00c2.4c00.bd15
175 - name: GigabitEthernet0/0/0/1
176 period: 200
177 state: merged
178
179
180 #
181 #
182 # -----------
183 # After state
184 # -----------
185 #
186 #
187 # RP/0/0/CPU0:an-iosxr#sh run int
188 # Sun Jul 21 18:24:52.413 UTC
189 # interface Bundle-Ether10
190 # lacp churn logging actor
191 # lacp switchover suppress-flaps 500
192 # lacp collector-max-delay 100
193 # !
194 # interface Bundle-Ether11
195 # lacp system mac 00c2.4c00.bd15
196 # !
197 # interface Bundle-Ether12
198 # !
199 # interface Loopback888
200 # description test for ansible
201 # shutdown
202 # !
203 # interface MgmtEth0/0/CPU0/0
204 # ipv4 address 192.0.2.11 255.255.255.0
205 # !
206 # interface GigabitEthernet0/0/0/1
207 # description 'GigabitEthernet - 1"
208 # lacp period 200
209 # !
210 # interface GigabitEthernet0/0/0/2
211 # description "GigabitEthernet - 2"
212 # !
213 # interface GigabitEthernet0/0/0/3
214 # description "GigabitEthernet - 3"
215 # !
216 # interface GigabitEthernet0/0/0/4
217 # description "GigabitEthernet - 4"
218 # !
219 #
220
221
222 # Using replaced
223 #
224 #
225 # ------------
226 # Before state
227 # ------------
228 #
229 #
230 # RP/0/0/CPU0:an-iosxr#sh run int
231 # Sun Jul 21 18:24:52.413 UTC
232 # interface Bundle-Ether10
233 # lacp churn logging actor
234 # lacp switchover suppress-flaps 500
235 # lacp collector-max-delay 100
236 # !
237 # interface Bundle-Ether11
238 # lacp system mac 00c2.4c00.bd15
239 # !
240 # interface Bundle-Ether12
241 # !
242 # interface Loopback888
243 # description test for ansible
244 # shutdown
245 # !
246 # interface MgmtEth0/0/CPU0/0
247 # ipv4 address 192.0.2.11 255.255.255.0
248 # !
249 # interface GigabitEthernet0/0/0/1
250 # description 'GigabitEthernet - 1"
251 # lacp period 200
252 # !
253 # interface GigabitEthernet0/0/0/2
254 # description "GigabitEthernet - 2"
255 # !
256 # interface GigabitEthernet0/0/0/3
257 # description "GigabitEthernet - 3"
258 # !
259 # interface GigabitEthernet0/0/0/4
260 # description "GigabitEthernet - 4"
261 # !
262 #
263
264 - name: Replace LACP configuration of listed interfaces with provided configuration
265 cisco.iosxr.iosxr_lacp_interfaces:
266 config:
267 - name: Bundle-Ether10
268 churn_logging: partner
269 - name: GigabitEthernet0/0/0/2
270 period: 300
271 state: replaced
272
273
274 #
275 #
276 # -----------
277 # After state
278 # -----------
279 #
280 #
281 # RP/0/0/CPU0:an-iosxr#sh run int
282 # Sun Jul 21 18:50:21.929 UTC
283 # interface Bundle-Ether10
284 # lacp churn logging partner
285 # !
286 # interface Bundle-Ether11
287 # lacp system mac 00c2.4c00.bd15
288 # !
289 # interface Bundle-Ether12
290 # !
291 # interface Loopback888
292 # description test for ansible
293 # shutdown
294 # !
295 # interface MgmtEth0/0/CPU0/0
296 # ipv4 address 192.0.2.11 255.255.255.0
297 # !
298 # interface GigabitEthernet0/0/0/1
299 # description 'GigabitEthernet - 1"
300 # lacp period 200
301 # !
302 # interface GigabitEthernet0/0/0/2
303 # description "GigabitEthernet - 2"
304 # lacp period 300
305 # !
306 # interface GigabitEthernet0/0/0/3
307 # description "GigabitEthernet - 3"
308 # !
309 # interface GigabitEthernet0/0/0/4
310 # description "GigabitEthernet - 4"
311 # !
312 #
313 #
314
315
316 # Using overridden
317 #
318 #
319 # ------------
320 # Before state
321 # ------------
322 #
323 #
324 # RP/0/0/CPU0:an-iosxr#sh run int
325 # Sun Jul 21 18:24:52.413 UTC
326 # interface Bundle-Ether10
327 # lacp churn logging actor
328 # lacp switchover suppress-flaps 500
329 # lacp collector-max-delay 100
330 # !
331 # interface Bundle-Ether11
332 # lacp system mac 00c2.4c00.bd15
333 # !
334 # interface Bundle-Ether12
335 # !
336 # interface Loopback888
337 # description test for ansible
338 # shutdown
339 # !
340 # interface MgmtEth0/0/CPU0/0
341 # ipv4 address 192.0.2.11 255.255.255.0
342 # !
343 # interface GigabitEthernet0/0/0/1
344 # description 'GigabitEthernet - 1"
345 # lacp period 200
346 # !
347 # interface GigabitEthernet0/0/0/2
348 # description "GigabitEthernet - 2"
349 # lacp period 200
350 # !
351 # interface GigabitEthernet0/0/0/3
352 # description "GigabitEthernet - 3"
353 # !
354 # interface GigabitEthernet0/0/0/4
355 # description "GigabitEthernet - 4"
356 # !
357 #
358 #
359
360 - name: Override all interface LACP configuration with provided configuration
361 cisco.iosxr.iosxr_lacp_interfaces:
362 config:
363 - name: Bundle-Ether12
364 churn_logging: both
365 collector_max_delay: 100
366 switchover_suppress_flaps: 500
367 - name: GigabitEthernet0/0/0/1
368 period: 300
369 state: overridden
370
371
372 #
373 #
374 # -----------
375 # After state
376 # -----------
377 #
378 #
379 # RP/0/0/CPU0:an-iosxr(config-if)#do sh run int
380 # Sun Jul 21 19:32:36.115 UTC
381 # interface Bundle-Ether10
382 # !
383 # interface Bundle-Ether11
384 # !
385 # interface Bundle-Ether12
386 # lacp churn logging both
387 # lacp switchover suppress-flaps 500
388 # lacp collector-max-delay 100
389 # !
390 # interface Loopback888
391 # description test for ansible
392 # shutdown
393 # !
394 # interface MgmtEth0/0/CPU0/0
395 # ipv4 address 192.0.2.11 255.255.255.0
396 # !
397 # interface GigabitEthernet0/0/0/1
398 # description 'GigabitEthernet - 1"
399 # lacp period 300
400 # !
401 # interface GigabitEthernet0/0/0/2
402 # description "GigabitEthernet - 2"
403 # !
404 # interface GigabitEthernet0/0/0/3
405 # description "GigabitEthernet - 3"
406 # !
407 # interface GigabitEthernet0/0/0/4
408 # description "GigabitEthernet - 4"
409 # !
410 #
411
412
413 # Using deleted
414 #
415 #
416 # ------------
417 # Before state
418 # ------------
419 #
420 #
421 # RP/0/0/CPU0:an-iosxr#sh run int
422 # Sun Jul 21 18:24:52.413 UTC
423 # interface Bundle-Ether10
424 # lacp churn logging actor
425 # lacp switchover suppress-flaps 500
426 # lacp collector-max-delay 100
427 # !
428 # interface Bundle-Ether11
429 # lacp non-revertive
430 # !
431 # interface Bundle-Ether12
432 # !
433 # interface Loopback888
434 # description test for ansible
435 # shutdown
436 # !
437 # interface MgmtEth0/0/CPU0/0
438 # ipv4 address 192.0.2.11 255.255.255.0
439 # !
440 # interface GigabitEthernet0/0/0/1
441 # description 'GigabitEthernet - 1"
442 # lacp period 200
443 # !
444 # interface GigabitEthernet0/0/0/2
445 # description "GigabitEthernet - 2"
446 # lacp period 300
447 # !
448 # interface GigabitEthernet0/0/0/3
449 # description "GigabitEthernet - 3"
450 # !
451 # interface GigabitEthernet0/0/0/4
452 # description "GigabitEthernet - 4"
453 # !
454 #
455
456 - name: >-
457 Deleted LACP configurations of provided interfaces (Note - This won't delete
458 the interface itself)
459 cisco.iosxr.iosxr_lacp_interfaces:
460 config:
461 - name: Bundle-Ether10
462 - name: Bundle-Ether11
463 - name: GigabitEthernet0/0/0/1
464 - name: GigabitEthernet0/0/0/2
465 state: deleted
466
467
468 #
469 #
470 # -----------
471 # After state
472 # -----------
473 #
474 #
475 # Using parsed:
476
477 # parsed.cfg
478 # interface Bundle-Ether10
479 # lacp churn logging actor
480 # lacp switchover suppress-flaps 500
481 # lacp collector-max-delay 100
482 # !
483 # interface Bundle-Ether11
484 # lacp system mac 00c2.4c00.bd15
485 # !
486 # interface MgmtEth0/0/CPU0/0
487 # ipv4 address 192.0.2.11 255.255.255.0
488 # !
489 # interface GigabitEthernet0/0/0/1
490 # lacp period 200
491 # !
492 #
493
494 - name: Convert lacp interfaces config to argspec without connecting to the appliance
495 cisco.iosxr.iosxr_lacp_interfaces:
496 running_config: "{{ lookup('file', './parsed.cfg') }}"
497 state: parsed
498
499 # --------------
500 # Output:
501 # --------------
502
503 # parsed:
504 # - name: Bundle-Ether10
505 # churn_logging: actor
506 # collector_max_delay: 100
507 # switchover_suppress_flaps: 500
508 #
509 # - name: Bundle-Ether11
510 # system:
511 # mac: 00c2.4c00.bd15
512 #
513 # - name: GigabitEthernet0/0/0/1
514 # period: 200
515 #
516 #
517
518 # Using gathered:
519
520 # Native config:
521 # interface Bundle-Ether10
522 # lacp churn logging actor
523 # lacp switchover suppress-flaps 500
524 # lacp collector-max-delay 100
525 # !
526 # interface Bundle-Ether11
527 # lacp system mac 00c2.4c00.bd15
528 # !
529 # interface MgmtEth0/0/CPU0/0
530 # ipv4 address 192.0.2.11 255.255.255.0
531 # !
532 # interface GigabitEthernet0/0/0/1
533 # lacp period 200
534 # !
535 #
536
537 - name: Gather IOSXR lacp interfaces configuration
538 cisco.iosxr.iosxr_lacp_interfaces:
539 config:
540 state: gathered
541
542 # ----------
543 # Output
544 # ---------
545 # gathered:
546 # - name: Bundle-Ether10
547 # churn_logging: actor
548 # collector_max_delay: 100
549 # switchover_suppress_flaps: 500
550 #
551 # - name: Bundle-Ether11
552 # system:
553 # mac: 00c2.4c00.bd15
554 #
555 # - name: GigabitEthernet0/0/0/1
556 # period: 200
557
558 # Using rendered:
559
560 - name: Render platform specific commands from task input using rendered state
561 cisco.iosxr.iosxr_lacp_interfaces:
562 config:
563 - name: Bundle-Ether10
564 churn_logging: actor
565 collector_max_delay: 100
566 switchover_suppress_flaps: 500
567 - name: Bundle-Ether11
568 system:
569 mac: 00c2.4c00.bd15
570 - name: GigabitEthernet0/0/0/1
571 period: 200
572 state: rendered
573
574
575 # -------------
576 # Output
577 # -------------
578 # rendered: [
579 # - "interface Bundle-Ether10"
580 # - " lacp churn logging actor"
581 # - " lacp switchover suppress-flaps 500"
582 # - " lacp collector-max-delay 100"
583 # - "interface Bundle-Ether11"
584 # - " lacp system mac 00c2.4c00.bd15"
585 # - "interface MgmtEth0/0/CPU0/0"
586 # - " ipv4 address 192.0.2.11 255.255.255.0"
587 # - "interface GigabitEthernet0/0/0/1"
588 # - " lacp period 200"
589 #
590 """
591 RETURN = """
592 before:
593 description: The configuration as structured data prior to module invocation.
594 returned: always
595 type: list
596 sample: >
597 The configuration returned will always be in the same format
598 of the parameters above.
599 after:
600 description: The configuration as structured data after module completion.
601 returned: when changed
602 type: list
603 sample: >
604 The configuration returned will always be in the same format
605 of the parameters above.
606 commands:
607 description: The set of commands pushed to the remote device.
608 returned: always
609 type: list
610 sample: ['interface Bundle-Ether10', 'lacp churn logging partner', 'lacp period 150']
611 """
612
613
614 from ansible.module_utils.basic import AnsibleModule
615
616 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.lacp_interfaces.lacp_interfaces import (
617 Lacp_interfacesArgs,
618 )
619 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.lacp_interfaces.lacp_interfaces import (
620 Lacp_interfaces,
621 )
622
623
624 def main():
625 """
626 Main entry point for module execution
627
628 :returns: the result form module invocation
629 """
630 required_if = [
631 ("state", "merged", ("config",)),
632 ("state", "replaced", ("config",)),
633 ("state", "overridden", ("config",)),
634 ("state", "rendered", ("config",)),
635 ("state", "parsed", ("running_config",)),
636 ]
637
638 mutually_exclusive = [("config", "running_config")]
639 module = AnsibleModule(
640 argument_spec=Lacp_interfacesArgs.argument_spec,
641 required_if=required_if,
642 supports_check_mode=True,
643 mutually_exclusive=mutually_exclusive,
644 )
645
646 result = Lacp_interfaces(module).execute_module()
647 module.exit_json(**result)
648
649
650 if __name__ == "__main__":
651 main()