Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ospfv3_interfaces.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7
8 """
9 The module file for sonic_ospfv3_interfaces
10 """
11
12 from __future__ import absolute_import, division, print_function
13 __metaclass__ = type
14
15
16 DOCUMENTATION = """
17 ---
18 module: sonic_ospfv3_interfaces
19 version_added: '3.1.0'
20 notes:
21 - Supports C(check_mode).
22 - Tested against Enterprise SONiC Distribution by Dell Technologies.
23 short_description: Configure OSPFv3 interface mode protocol settings on SONiC.
24 description:
25 - This module provides configuration management of OSPFv3 interface mode parameters on devices running SONiC.
26 - Configure VRF instance before configuring OSPFv3 in a VRF.
27 - Configure global/VRF OSPFv3 instance before configuring OSPFv3 in interfaces.
28 author: "Mansi Jharia (@Mansi062001)"
29 options:
30 config:
31 description:
32 - Specifies the OSPFv3 interface mode related configuration.
33 type: list
34 elements: dict
35 suboptions:
36 name:
37 required: True
38 type: str
39 description:
40 - Full name of the interface, i.e. Ethernet1.
41 advertise:
42 description:
43 - Enable OSPFv3 interface advertise.
44 - expects name of a prefix list.
45 type: str
46 area_id:
47 description:
48 - OSPFv3 Area ID of the network (A.B.C.D or 0 to 4294967295).
49 type: str
50 bfd:
51 description:
52 - Configure OSPFv3 interface BFD.
53 type: dict
54 suboptions:
55 enable:
56 description:
57 - Enable BFD support for OSPFv3.
58 type: bool
59 required: true
60 bfd_profile:
61 description:
62 - Configure BFD profile.
63 type: str
64 cost:
65 description:
66 - Configure OSPFv3 interface cost (1 to 65535).
67 type: int
68 dead_interval:
69 description:
70 - Configure OSPFv3 adjacency dead interval (1 to 65535).
71 type: int
72 hello_interval:
73 description:
74 - Configure OSPFv3 neighbour hello interval (1 to 65535).
75 type: int
76 mtu_ignore:
77 description:
78 - Disable OSPFv3 MTU mismatch detection.
79 type: bool
80 network:
81 description:
82 - Configure OSPFv3 interface network type
83 type: str
84 choices:
85 - broadcast
86 - point_to_point
87 passive:
88 description:
89 - Configure ospfv3 interface as passive.
90 type: bool
91 priority:
92 description:
93 - Configure OSPFv3 adjacency router priority (0 to 255).
94 type: int
95 retransmit_interval:
96 description:
97 - Configure OSPFv3 retransmit interval (2 to 65535).
98 type: int
99 transmit_delay:
100 description:
101 - Configure OSPFv3 transmit delay (1 to 65535).
102 type: int
103 state:
104 description:
105 - Specifies the operation to be performed on the OSPFv3 interfaces configured on the device.
106 - In case of merged, the input configuration will be merged with the existing OSPFv3 interfaces configuration on the device.
107 - In case of deleted, the specified existing OSPFv3 interfaces configuration will be removed from the device.
108 - In case of overridden, all the existing OSPFv3 interfaces configuration will be deleted and the specified input
109 configuration will be installed.
110 - In case of replaced, the existing OSPFv3 interface configuration on the device will be replaced by the configuration in the
111 playbook for each interface group configured by the playbook.
112 type: str
113 default: merged
114 choices: ['merged', 'deleted', 'replaced', 'overridden']
115 """
116 EXAMPLES = """
117 # Using deleted
118
119 # Before state:
120 # -------------
121 #
122 # sonic# show running-configuration interface
123 # !
124 # interface Eth1/1
125 # ipv6 ospfv3 advertise prefix-list test1
126 # ipv6 ospfv3 area 2.2.2.2
127 # ipv6 ospfv3 bfd
128 # ipv6 ospfv3 bfd profile profile2
129 # ipv6 ospfv3 cost 30
130 # ipv6 ospfv3 dead-interval 40
131 # ipv6 ospfv3 hello-interval 10
132 # ipv6 ospfv3 mtu-ignore
133 # ipv6 ospfv3 network point-to-point
134 # ipv6 ospfv3 priority 20
135 # ipv6 ospfv3 passive
136 # !
137 # interface Eth1/2
138 # ipv6 ospfv3 bfd
139 # ipv6 ospfv3 network point-to-point
140 # !
141 # interface Eth1/3
142 # ipv6 ospfv3 bfd
143 # ipv6 ospfv3 network point-to-point
144 # ipv6 ospfv3 area 3.3.3.3
145 # !
146 # sonic#
147
148 - name: Delete the specified OSPFv3_interface configurations
149 sonic_ospfv3_interfaces:
150 config:
151 - name: 'Eth1/1'
152 area_id: '2.2.2.2'
153 cost: 30
154 priority: 20
155 hello_interval: 10
156 dead_interval: 40
157 mtu_ignore: true
158 bfd:
159 enable: true
160 bfd_profile: 'profile2'
161 network: point_to_point
162 - name: 'Eth1/2'
163 bfd:
164 enable: true
165 - name: 'Eth1/3'
166 state: deleted
167
168 # After state:
169 # ------------
170 #
171 # sonic# show running-configuration interface
172 # !
173 # interface Eth1/1
174 # ipv6 ospfv3 advertise prefix-list test1
175 # ipv6 ospfv3 passive
176 # !
177 # interface Eth1/2
178 # ipv6 ospfv3 network point-to-point
179 # !
180 # interface Eth1/3
181 # !
182 # sonic#
183
184
185 # Using deleted
186
187 # Before state:
188 # -------------
189 #
190 # sonic# show running-configuration interface
191 # !
192 # interface Eth1/1
193 # ipv6 ospfv3 advertise prefix-list test1
194 # ipv6 ospfv3 area 2.2.2.2
195 # ipv6 ospfv3 bfd
196 # ipv6 ospfv3 bfd profile profile2
197 # ipv6 ospfv3 cost 30
198 # ipv6 ospfv3 dead-interval 40
199 # ipv6 ospfv3 hello-interval 10
200 # ipv6 ospfv3 mtu-ignore
201 # ipv6 ospfv3 network point-to-point
202 # ipv6 ospfv3 priority 20
203 # ipv6 ospfv3 passive
204 # !
205 # interface Eth1/2
206 # ipv6 ospfv3 bfd
207 # ipv6 ospfv3 network point-to-point
208 # !
209 # interface Eth1/3
210 # ipv6 ospfv3 bfd
211 # ipv6 ospfv3 network point-to-point
212 # ipv6 ospfv3 area 3.3.3.3
213 # !
214 # sonic#
215
216 - name: Delete the specified OSPFv3_interface configurations
217 sonic_ospfv3_interfaces:
218 config:
219 - name: 'Eth1/1'
220 - name: 'Eth1/2'
221 bfd:
222 enable: true
223 - name: 'Eth1/3'
224 state: deleted
225
226 # After state:
227 # ------------
228 #
229 # sonic# show running-configuration interface
230 # !
231 # interface Eth1/1
232 # !
233 # interface Eth1/2
234 # ipv6 ospfv3 network point-to-point
235 # !
236 # interface Eth1/3
237 # !
238 # sonic#
239
240
241 # Using merged
242
243 # Before state:
244 # -------------
245 #
246 # sonic# show running-configuration interface
247 # !
248 # interface Eth1/1
249 # !
250 # interface Eth1/2
251 # !
252 # interface Eth1/3
253 # !
254 # sonic#
255
256 - name: Add the OSPFv3_interface configurations
257 sonic_ospfv3_interfaces:
258 config:
259 - name: 'Eth1/1'
260 advertise: 'test1'
261 area_id: '2.2.2.2'
262 cost: 20
263 passive: true
264 priority: 20
265 hello_interval: 10
266 dead_interval: 40
267 mtu_ignore: true
268 hello_multiplier: 5
269 bfd:
270 enable: true
271 bfd_profile: 'profile1'
272 network: broadcast
273 - name: 'Eth1/3'
274 area_id: '3.3.3.3'
275 hello_multiplier: 5
276 bfd:
277 enable: true
278 network: point_to_point
279 state: merged
280
281 # After state:
282 # ------------
283 #
284 # sonic# show running-configuration interface
285 # !
286 # interface Eth1/1
287 # ipv6 ospfv3 advertise prefix-list test1
288 # ipv6 ospfv3 area 2.2.2.2
289 # ipv6 ospfv3 bfd
290 # ipv6 ospfv3 bfd profile profile1
291 # ipv6 ospfv3 cost 20
292 # ipv6 ospfv3 dead-interval 40
293 # ipv6 ospfv3 hello-interval 10
294 # ipv6 ospfv3 mtu-ignore
295 # ipv6 ospfv3 network broadcast
296 # ipv6 ospfv3 passive
297 # ipv6 ospfv3 priority 20
298 # !
299 # interface Eth1/2
300 # !
301 # interface Eth1/3
302 # ipv6 ospfv3 bfd
303 # ipv6 ospfv3 network point-to-point
304 # ipv6 ospfv3 area 3.3.3.3
305 # !
306 # sonic#
307
308 # Using merged
309
310 # Before state:
311 # -------------
312 #
313 # sonic# show running-configuration interface
314 # !
315 # interface Eth1/1
316 # ipv6 ospfv3 advertise prefix-list test1
317 # ipv6 ospfv3 area 2.2.2.2
318 # ipv6 ospfv3 bfd
319 # ipv6 ospfv3 bfd profile profile1
320 # ipv6 ospfv3 cost 20
321 # ipv6 ospfv3 dead-interval 40
322 # ipv6 ospfv3 hello-interval 10
323 # ipv6 ospfv3 mtu-ignore
324 # ipv6 ospfv3 network broadcast
325 # ipv6 ospfv3 priority 20
326 # !
327 # interface Eth1/2
328 # !
329 # interface Eth1/3
330 # ipv6 ospfv3 bfd
331 # ipv6 ospfv3 network point-to-point
332 # ipv6 ospfv3 area 3.3.3.3
333 # !
334 # sonic#
335
336 - name: Add the OSPFv3_interface configurations
337 sonic_ospfv3_interfaces:
338 config:
339 - name: 'Eth1/1'
340 area_id: '2.2.2.2'
341 cost: 30
342 passive: true
343 priority: 20
344 hello_interval: 10
345 dead_interval: 40
346 mtu_ignore: true
347 bfd:
348 enable: true
349 bfd_profile: 'profile2'
350 network: point_to_point
351 - name: 'Eth1/2'
352 bfd:
353 enable: true
354 network: point_to_point
355 state: merged
356
357 # After state:
358 # ------------
359 #
360 # sonic# show running-configuration interface
361 # !
362 # interface Eth1/1
363 # ipv6 ospfv3 advertise prefix-list test1
364 # ipv6 ospfv3 area 2.2.2.2
365 # ipv6 ospfv3 bfd
366 # ipv6 ospfv3 bfd profile profile2
367 # ipv6 ospfv3 cost 30
368 # ipv6 ospfv3 dead-interval 40
369 # ipv6 ospfv3 hello-interval 10
370 # ipv6 ospfv3 mtu-ignore
371 # ipv6 ospfv3 network point-to-point
372 # ipv6 ospfv3 passive
373 # ipv6 ospfv3 priority 20
374 # !
375 # interface Eth1/2
376 # ipv6 ospfv3 bfd
377 # ipv6 ospfv3 network point-to-point
378 # !
379 # interface Eth1/3
380 # ipv6 ospfv3 bfd
381 # ipv6 ospfv3 network point-to-point
382 # ipv6 ospfv3 area 3.3.3.3
383 # !
384 # sonic#
385
386
387 # Using replaced
388
389 # Before state:
390 # -------------
391 #
392 # sonic# show running-configuration interface
393 # !
394 # interface Eth1/1
395 # ipv6 ospfv3 advertise prefix-list test1
396 # ipv6 ospfv3 area 2.2.2.2
397 # ipv6 ospfv3 bfd
398 # ipv6 ospfv3 bfd profile profile1
399 # ipv6 ospfv3 cost 20
400 # ipv6 ospfv3 dead-interval 40
401 # ipv6 ospfv3 hello-interval 10
402 # ipv6 ospfv3 mtu-ignore
403 # ipv6 ospfv3 network broadcast
404 # ipv6 ospfv3 passive
405 # ipv6 ospfv3 priority 20
406 # !
407 # interface Eth1/2
408 # !
409 # interface Eth1/3
410 # ipv6 ospfv3 bfd
411 # ipv6 ospfv3 network point-to-point
412 # ipv6 ospfv3 area 3.3.3.3
413 # !
414 # sonic#
415
416
417 - name: Replace the OSPFv3_interface configurations
418 sonic_ospfv3_interfaces:
419 config:
420 - name: 'Eth1/3'
421 area_id: '2.2.2.2'
422 cost: 30
423 passive: true
424 priority: 20
425 hello_interval: 10
426 dead_interval: 40
427 mtu_ignore: true
428 bfd:
429 enable: true
430 bfd_profile: 'profile2'
431 network: broadcast
432 state: replaced
433
434 # After state:
435 # ------------
436 #
437 # sonic# show running-configuration interface
438 # !
439 # interface Eth1/1
440 # ipv6 ospfv3 advertise prefix-list test1
441 # ipv6 ospfv3 area 2.2.2.2
442 # ipv6 ospfv3 bfd
443 # ipv6 ospfv3 bfd profile profile1
444 # ipv6 ospfv3 cost 20
445 # ipv6 ospfv3 dead-interval 40
446 # ipv6 ospfv3 hello-interval 10
447 # ipv6 ospfv3 mtu-ignore
448 # ipv6 ospfv3 network broadcast
449 # ipv6 ospfv3 passive
450 # ipv6 ospfv3 priority 20
451 # !
452 # interface Eth1/2
453 # !
454 # interface Eth1/3
455 # ipv6 ospfv3 area 2.2.2.2
456 # ipv6 ospfv3 bfd
457 # ipv6 ospfv3 bfd profile profile2
458 # ipv6 ospfv3 cost 30
459 # ipv6 ospfv3 dead-interval 40
460 # ipv6 ospfv3 hello-interval 10
461 # ipv6 ospfv3 mtu-ignore
462 # ipv6 ospfv3 network broadcast
463 # ipv6 ospfv3 passive
464 # ipv6 ospfv3 priority 20
465 # !
466 # sonic#
467
468
469 # Using overridden
470
471 # Before state:
472 # -------------
473 #
474 # sonic# show running-configuration interface
475 # !
476 # interface Eth1/1
477 # ipv6 ospfv3 area 2.2.2.2
478 # ipv6 ospfv3 bfd
479 # ipv6 ospfv3 bfd profile profile1
480 # ipv6 ospfv3 cost 20
481 # ipv6 ospfv3 dead-interval 40
482 # ipv6 ospfv3 hello-interval 10
483 # ipv6 ospfv3 mtu-ignore
484 # ipv6 ospfv3 network broadcast
485 # ipv6 ospfv3 priority 20
486 # !
487 # interface Eth1/2
488 # !
489 # interface Eth1/3
490 # ipv6 ospfv3 bfd
491 # ipv6 ospfv3 network point-to-point
492 # ipv6 ospfv3 area 3.3.3.3
493 # !
494 # sonic#
495
496 - name: Override the OSPFv3_interface configurations
497 sonic_ospfv3_interfaces:
498 config:
499 - name: 'Eth1/3'
500 advertise: 'test1'
501 area_id: '2.2.2.2'
502 cost: 30
503 passive: true
504 priority: 20
505 hello_interval: 10
506 dead_interval: 40
507 mtu_ignore: true
508 bfd:
509 enable: true
510 bfd_profile: 'profile2'
511 network: broadcast
512 state: overridden
513
514 # After state:
515 # ------------
516 #
517 # sonic# show running-configuration interface
518 # !
519 # interface Eth1/1
520 # !
521 # interface Eth1/2
522 # !
523 # interface Eth1/3
524 # ipv6 ospfv3 advertise prefix-list test1
525 # ipv6 ospfv3 area 2.2.2.2
526 # ipv6 ospfv3 bfd
527 # ipv6 ospfv3 bfd profile profile2
528 # ipv6 ospfv3 cost 30
529 # ipv6 ospfv3 dead-interval 40
530 # ipv6 ospfv3 hello-interval 10
531 # ipv6 ospfv3 mtu-ignore
532 # ipv6 ospfv3 network broadcast
533 # ipv6 ospfv3 passive
534 # ipv6 ospfv3 priority 20
535 # !
536 # sonic#
537 """
538 RETURN = """
539 before:
540 description: The configuration prior to the module invocation.
541 returned: always
542 type: list
543 sample: >
544 The configuration returned will always be in the same format
545 as the parameters above.
546 after:
547 description: The configuration resulting from module invocation.
548 returned: when changed
549 type: list
550 sample: >
551 The configuration returned will always be in the same format
552 as the parameters above.
553 after_generated:
554 description: The generated(calculated) configuration that would be applied by module invocation.
555 returned: when C(check_mode)
556 type: list
557 sample: >
558 The configuration returned will always be in the same format
559 as the parameters above.
560 commands:
561 description: The set of commands pushed to the remote device.
562 returned: always
563 type: list
564 sample: ['command 1', 'command 2', 'command 3']
565 """
566
567 from ansible.module_utils.basic import AnsibleModule
568 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.ospfv3_interfaces.ospfv3_interfaces import Ospfv3_interfacesArgs
569 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.ospfv3_interfaces.ospfv3_interfaces import Ospfv3_interfaces
570
571
572 def main():
573 """
574 Main entry point for module execution
575 :returns: the result form module invocation
576 """
577 module = AnsibleModule(argument_spec=Ospfv3_interfacesArgs.argument_spec,
578 supports_check_mode=True)
579
580 result = Ospfv3_interfaces(module).execute_module()
581 module.exit_json(**result)
582
583
584 if __name__ == '__main__':
585 main()