Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_pim_global.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 The module file for sonic_pim_global
9 """
10
11 from __future__ import absolute_import, division, print_function
12 __metaclass__ = type
13
14
15 DOCUMENTATION = """
16 ---
17 module: sonic_pim_global
18 version_added: 2.5.0
19 notes:
20 - Supports C(check_mode).
21 short_description: Manage global PIM configurations on SONiC
22 description:
23 - This module provides configuration management of global PIM
24 parameters for devices running SONiC.
25 - VRF and prefix-list need to be created earlier in the device.
26 author: 'Arun Saravanan Balachandran (@ArunSaravananBalachandran)'
27 options:
28 config:
29 description:
30 - Specifies global PIM configurations.
31 type: list
32 elements: dict
33 suboptions:
34 vrf_name:
35 description:
36 - Name of the VRF to which the PIM configurations belong.
37 type: str
38 default: 'default'
39 join_prune_interval:
40 description:
41 - Specifies the PIM Join Prune Interval in seconds.
42 - The range is from 60 to 600.
43 type: int
44 keepalive_timer:
45 description:
46 - Specifies the PIM Keepalive timer in seconds.
47 - The range is from 31 to 60000.
48 type: int
49 ssm_prefix_list:
50 description:
51 - Specifies the SSM prefix-list.
52 type: str
53 ecmp_enable:
54 description:
55 - Enable PIM ECMP.
56 type: bool
57 ecmp_rebalance_enable:
58 description:
59 - Enable PIM ECMP rebalance.
60 - ECMP has to be enabled for configuring ECMP rebalance.
61 type: bool
62 state:
63 description:
64 - The state of the configuration after module completion.
65 - C(merged) - Merges provided global PIM configuration with on-device configuration.
66 - C(replaced) - Replaces on-device PIM configuration of the specified VRFs with provided configuration.
67 - C(overridden) - Overrides all on-device global PIM configurations with the provided configuration.
68 - C(deleted) - Deletes on-device global PIM configuration.
69 type: str
70 choices:
71 - merged
72 - deleted
73 - replaced
74 - overridden
75 default: merged
76 """
77
78 EXAMPLES = """
79 # Using "deleted" state
80 #
81 # Before state:
82 # -------------
83 #
84 # sonic# show running-configuration | grep "ip pim"
85 # ip pim vrf VrfReg1 join-prune-interval 60
86 # ip pim vrf VrfReg1 keep-alive-timer 180
87 # ip pim vrf VrfReg1 ssm prefix-list prefix-list-1
88 # ip pim vrf VrfReg2 ecmp
89 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
90 # ip pim vrf default ecmp
91 # ip pim vrf default ecmp rebalance
92 # sonic#
93
94 - name: Delete specified global PIM configurations
95 dellemc.enterprise_sonic.sonic_pim_global:
96 config:
97 - vrf_name: 'VrfReg1'
98 join_prune_interval: 60
99 keepalive_timer: 180
100 - vrf_name: 'VrfReg2'
101 state: deleted
102
103 # After state:
104 # ------------
105 #
106 # sonic# show running-configuration | grep "ip pim"
107 # ip pim vrf VrfReg1 ssm prefix-list prefix-list-1
108 # ip pim vrf default ecmp
109 # ip pim vrf default ecmp rebalance
110 # sonic#
111
112
113 # Using "deleted" state
114 #
115 # Before state:
116 # -------------
117 #
118 # sonic# show running-configuration | grep "ip pim"
119 # ip pim vrf VrfReg1 join-prune-interval 60
120 # ip pim vrf VrfReg1 keep-alive-timer 180
121 # ip pim vrf VrfReg1 ssm prefix-list prefix-list-1
122 # ip pim vrf VrfReg2 ecmp
123 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
124 # ip pim vrf default ecmp
125 # ip pim vrf default ecmp rebalance
126 # sonic#
127
128 - name: Delete all global PIM configurations
129 dellemc.enterprise_sonic.sonic_pim_global:
130 config:
131 state: deleted
132
133 # After state:
134 # ------------
135 #
136 # sonic# show running-configuration | grep "ip pim"
137 # sonic#
138
139
140 # Using "merged" state
141 #
142 # Before state:
143 # -------------
144 #
145 # sonic# show running-configuration | grep "ip pim"
146 # ip pim vrf default join-prune-interval 120
147 # ip pim vrf default keep-alive-timer 360
148 # ip pim vrf default ssm prefix-list prefix-list-1
149 # sonic#
150
151 - name: Merge provided global PIM configurations
152 dellemc.enterprise_sonic.sonic_pim_global:
153 config:
154 - vrf_name: 'default'
155 ecmp_enable: true
156 ecmp_rebalance_enable: true
157 join_prune_interval: 60
158 keepalive_timer: 180
159 ssm_prefix_list: 'prefix-list-def'
160 - vrf_name: 'VrfReg1'
161 join_prune_interval: 60
162 keepalive_timer: 180
163 - vrf_name: 'VrfReg2'
164 ssm_prefix_list: 'prefix-list-2'
165 state: merged
166
167 # After state:
168 # ------------
169 #
170 # sonic# show running-configuration | grep "ip pim"
171 # ip pim vrf VrfReg1 join-prune-interval 60
172 # ip pim vrf VrfReg1 keep-alive-timer 180
173 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
174 # ip pim vrf default ecmp
175 # ip pim vrf default ecmp rebalance
176 # ip pim vrf default join-prune-interval 60
177 # ip pim vrf default keep-alive-timer 180
178 # ip pim vrf default ssm prefix-list prefix-list-def
179 # sonic#
180
181
182 # Using "replaced" state
183 #
184 # Before state:
185 # -------------
186 #
187 # sonic# show running-configuration | grep "ip pim"
188 # ip pim vrf VrfReg1 join-prune-interval 60
189 # ip pim vrf VrfReg1 keep-alive-timer 180
190 # ip pim vrf VrfReg1 ssm prefix-list prefix-list-1
191 # ip pim vrf VrfReg2 ecmp
192 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
193 # ip pim vrf default ecmp
194 # ip pim vrf default ecmp rebalance
195 # sonic#
196
197 - name: Replace global PIM configurations of specified VRFs
198 dellemc.enterprise_sonic.sonic_pim_global:
199 config:
200 - vrf_name: 'default'
201 ecmp_enable: true
202 - vrf_name: 'VrfReg1'
203 join_prune_interval: 120
204 keepalive_timer: 360
205 state: replaced
206
207 # After state:
208 # ------------
209 #
210 # sonic# show running-configuration | grep "ip pim"
211 # ip pim vrf VrfReg1 join-prune-interval 120
212 # ip pim vrf VrfReg1 keep-alive-timer 360
213 # ip pim vrf VrfReg2 ecmp
214 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
215 # ip pim vrf default ecmp
216 # sonic#
217
218
219 # Using "replaced" state
220 #
221 # Before state:
222 # -------------
223 #
224 # sonic# show running-configuration | grep "ip pim"
225 # ip pim vrf VrfReg1 join-prune-interval 60
226 # ip pim vrf VrfReg1 keep-alive-timer 180
227 # ip pim vrf VrfReg1 ssm prefix-list prefix-list-1
228 # ip pim vrf VrfReg2 ecmp
229 # ip pim vrf VrfReg2 ssm prefix-list prefix-list-2
230 # ip pim vrf default ecmp
231 # ip pim vrf default ecmp rebalance
232 # sonic#
233
234 - name: Override global PIM configurations
235 dellemc.enterprise_sonic.sonic_pim_global:
236 config:
237 - vrf_name: 'default'
238 ecmp_enable: true
239 - vrf_name: 'VrfReg1'
240 join_prune_interval: 120
241 keepalive_timer: 360
242 state: overridden
243
244 # After state:
245 # ------------
246 #
247 # sonic# show running-configuration | grep "ip pim"
248 # ip pim vrf VrfReg1 join-prune-interval 120
249 # ip pim vrf VrfReg1 keep-alive-timer 360
250 # ip pim vrf default ecmp
251 # sonic#
252 """
253
254 RETURN = """
255 before:
256 description: The configuration prior to the module invocation.
257 returned: always
258 type: list
259 sample: >
260 The configuration returned will always be in the same format
261 as the parameters above.
262 after:
263 description: The resulting configuration on module invocation.
264 returned: when changed
265 type: list
266 sample: >
267 The configuration returned will always be in the same format
268 as the parameters above.
269 after_generated:
270 description: The generated configuration on module invocation.
271 returned: when C(check_mode)
272 type: list
273 sample: >
274 The configuration returned will always be in the same format
275 as the parameters above.
276 commands:
277 description: The set of commands pushed to the remote device.
278 returned: always
279 type: list
280 sample: ['command 1', 'command 2', 'command 3']
281 """
282
283
284 from ansible.module_utils.basic import AnsibleModule
285 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.pim_global.pim_global import Pim_globalArgs
286 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.pim_global.pim_global import Pim_global
287
288
289 def main():
290 """
291 Main entry point for module execution
292
293 :returns: the result form module invocation
294 """
295 module = AnsibleModule(argument_spec=Pim_globalArgs.argument_spec,
296 supports_check_mode=True)
297
298 result = Pim_global(module).execute_module()
299 module.exit_json(**result)
300
301
302 if __name__ == '__main__':
303 main()