Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_evpn_esi_multihome.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_evpn_esi_multihome
9 """
10
11 from __future__ import absolute_import, division, print_function
12 __metaclass__ = type
13
14 DOCUMENTATION = """
15 ---
16 module: sonic_evpn_esi_multihome
17 version_added: 3.1.0
18 notes:
19 - Tested against Enterprise SONiC Distribution by Dell Technologies.
20 - Supports C(check_mode).
21 short_description: Manage EVPN ESI multihoming configuration on SONiC
22 description:
23 - This module provides configuration management of EVPN ESI multihoming for devices running SONiC
24 author: Aida Shumburo (@aida-shumburo)
25 options:
26 config:
27 description:
28 - EVPN ESI multihoming configuration
29 type: dict
30 suboptions:
31 df_election_time:
32 description:
33 - Election timer value in seconds
34 - Has a range of 0 to 86400
35 - Default is 3
36 type: int
37 es_activation_delay:
38 description:
39 - Activation delay in seconds
40 - Has a range of 0 to 1200000
41 - Default is 0
42 type: int
43 mac_holdtime:
44 description:
45 - MAC hold time in seconds
46 - Has a range of 0 to 86400
47 - Default is 1080
48 - Specify 0 to disable MAC hold time
49 type: int
50 neigh_holdtime:
51 description:
52 - Neighbor hold time in seconds
53 - Has a range of 0 to 86400
54 - Default is 1080
55 - Specify 0 to disable neighbor hold time
56 type: int
57 startup_delay:
58 description:
59 - Startup delay in seconds
60 - Has a range of 0 to 3600
61 - Default is 300
62 - Specify 0 to disable startup delay
63 type: int
64 state:
65 description:
66 - The state of the configuration after module completion
67 type: str
68 choices: ['merged', 'deleted', 'replaced', 'overridden']
69 default: merged
70 """
71
72 EXAMPLES = """
73 # Using "deleted" state
74 #
75 # Before state:
76 # ---------------
77 #
78 # sonic# show running-configuration evpn-mh
79 # !
80 # evpn esi-multihoming
81 # mac-holdtime 1080
82 # neigh-holdtime 1080
83 # startup-delay 300
84
85 - name: Delete specific option from evpn_esi_multihome configuration
86 sonic_evpn_esi_multihome:
87 config:
88 mac-holdtime: 1080
89 state: deleted
90
91 # After State:
92 # --------------
93 #
94 # sonic# show running-configuration evpn-mh
95 # !
96 # evpn esi-multihoming
97 # neigh-holdtime 1080
98 # startup-delay 300
99
100
101 # Using "deleted" state
102 #
103 # Before state:
104 # ---------------
105 #
106 # sonic# show running-configuration evpn-mh
107 # !
108 # evpn esi-multihoming
109 # mac-holdtime 1080
110 # neigh-holdtime 1080
111 # startup-delay 300
112 # df-election-time 3
113
114 - name: Delete all evpn_esi_multihome configuration
115 sonic_evpn_esi_multihome:
116 config: {}
117 state: deleted
118
119 # After State:
120 # --------------
121 #
122 # sonic# show running-configuration evpn-mh
123 # (No "evpn-mh" configuration present)
124
125
126 # Using "merged" state
127 #
128 # Before state:
129 # ---------------
130 #
131 # sonic# show running-configuration evpn-mh
132 # (No "evpn-mh" configuration present)
133
134 - name: Merge specific option from evpn_esi_multihome configuration
135 sonic_evpn_esi_multihome:
136 config:
137 startup-delay: 300
138 es-activation-delay: 3000
139 state: merged
140
141 # After State:
142 # --------------
143 #
144 # sonic# show running-configuration evpn-mh
145 # !
146 # evpn esi-multihoming
147 # startup-delay 300
148 # es-activation-delay 3000
149
150
151 # Using "replaced" state
152 #
153 # Before state:
154 # ----------------
155 #
156 # sonic# show running-configuration evpn-mh
157 # !
158 # evpn esi-multihoming
159 # mac-holdtime 1080
160 # neigh-holdtime 1080
161 # startup-delay 300
162 # df-election-time: 3
163
164 - name: Replace evpn_esi_multihome configuration
165 sonic_evpn_esi_multihome:
166 config:
167 neigh-holdtime: 200
168 df-election-time: 600
169 state: replaced
170
171 # After State:
172 # --------------
173 #
174 # sonic# show running-configuration evpn-mh
175 # !
176 # evpn esi-multihoming
177 # neigh-holdtime 200
178 # df-election-time: 600
179
180
181 # Using "overridden" state
182 #
183 # Before state:
184 # ----------------
185 #
186 # sonic# show running-configuration evpn-mh
187 # !
188 # evpn esi-multihoming
189 # mac-holdtime 1080
190 # neigh-holdtime 1080
191 # startup-delay 300
192
193 - name: Override evpn_esi_multihome configuration
194 sonic_evpn_esi_multihome:
195 config:
196 startup-delay: 200
197 mac_holdtime: 500
198 state: overridden
199
200 # After State:
201 # --------------
202 #
203 # sonic# show running-configuration evpn-mh
204 # !
205 # evpn esi-multihoming
206 # startup-delay 200
207 # mac_holdtime: 500
208 """
209
210 RETURN = """
211 before:
212 description: The configuration prior to the module invocation.
213 returned: always
214 type: dict
215 after:
216 description: The configuration resulting from module invocation.
217 returned: when changed
218 type: dict
219 after_generated:
220 description: The configuration that would result from non-check-mode module invocation.
221 returned: when C(check_mode)
222 type: dict
223 commands:
224 description: The set of commands pushed to the remote device. In C(check_mode) the needed commands are displayed, but not pushed to the device.
225 returned: always
226 type: list
227 sample: ['command 1', 'command 2', 'command 3']
228 """
229
230
231 from ansible.module_utils.basic import AnsibleModule
232 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.evpn_esi_multihome.evpn_esi_multihome import Evpn_esi_multihomeArgs
233 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.evpn_esi_multihome.evpn_esi_multihome import Evpn_esi_multihome
234
235
236 def main():
237 """
238 Main entry point for module execution
239
240 :returns: the result form module invocation
241 """
242 module = AnsibleModule(argument_spec=Evpn_esi_multihomeArgs.argument_spec,
243 supports_check_mode=True)
244
245 result = Evpn_esi_multihome(module).execute_module()
246 module.exit_json(**result)
247
248
249 if __name__ == '__main__':
250 main()