Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_port_breakout.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_port_breakout
9 """
10
11 from __future__ import absolute_import, division, print_function
12 __metaclass__ = type
13
14 DOCUMENTATION = """
15 ---
16 module: sonic_port_breakout
17 version_added: 1.0.0
18 notes:
19 - Tested against Enterprise SONiC Distribution by Dell Technologies.
20 - Supports C(check_mode).
21 author: Niraimadaiselvam M (@niraimadaiselvamm)
22 short_description: Configure port breakout settings on physical interfaces
23 description:
24 - This module provides configuration management of port breakout parameters on devices running Enterprise SONiC.
25 options:
26 config:
27 description:
28 - Specifies the port breakout related configuration.
29 type: list
30 elements: dict
31 suboptions:
32 name:
33 description:
34 - Specifies the name of the port breakout.
35 type: str
36 required: true
37 mode:
38 description:
39 - Specifies the mode of the port breakout.
40 type: str
41 choices:
42 - 1x10G
43 - 1x25G
44 - 1x40G
45 - 1x50G
46 - 1x100G
47 - 1x200G
48 - 1x400G
49 - 1x800G
50 - 2x10G
51 - 2x25G
52 - 2x40G
53 - 2x50G
54 - 2x100G
55 - 2x200G
56 - 2x400G
57 - 4x10G
58 - 4x25G
59 - 4x50G
60 - 4x100G
61 - 4x200G
62 - 8x10G
63 - 8x25G
64 - 8x50G
65 - 8x100G
66 state:
67 description:
68 - Specifies the operation to be performed on the port breakout configured on the device.
69 - In case of merged, the input mode configuration will be merged with the existing port breakout configuration on the device.
70 - In case of deleted, the existing port breakout mode configuration will be removed from the device.
71 - In case of replaced, on-device port breakout configuration of the specified interfaces is replaced with provided configuration.
72 - In case of overridden, all on-device port breakout configurations are overridden with the provided configuration.
73 default: merged
74 choices: ['merged', 'deleted', 'replaced', 'overridden']
75 type: str
76 """
77
78 EXAMPLES = """
79 # Using "deleted" state
80 #
81 # Before state:
82 # -------------
83 #
84 # sonic# show interface breakout
85 # -----------------------------------------------
86 # Port Breakout Mode Status Interfaces
87 # -----------------------------------------------
88 # 1/1 4x10G Completed Eth1/1/1
89 # Eth1/1/2
90 # Eth1/1/3
91 # Eth1/1/4
92 # 1/11 1x100G Completed Eth1/11/1
93 #
94
95 - name: Delete interface port breakout configuration
96 dellemc.enterprise_sonic.sonic_port_breakout:
97 config:
98 - name: 1/11
99 mode: 1x100G
100 state: deleted
101
102 # After state:
103 # ------------
104 #
105 # sonic# show interface breakout
106 # -----------------------------------------------
107 # Port Breakout Mode Status Interfaces
108 # -----------------------------------------------
109 # 1/1 4x10G Completed Eth1/1/1
110 # Eth1/1/2
111 # Eth1/1/3
112 # Eth1/1/4
113 # 1/11 Default Completed Eth1/11
114 #
115
116
117 # Using "deleted" state
118 #
119 # Before state:
120 # -------------
121 #
122 # sonic# show interface breakout
123 # -----------------------------------------------
124 # Port Breakout Mode Status Interfaces
125 # -----------------------------------------------
126 # 1/1 4x10G Completed Eth1/1/1
127 # Eth1/1/2
128 # Eth1/1/3
129 # Eth1/1/4
130 # 1/11 1x100G Completed Eth1/11/1
131 #
132
133 - name: Delete all port breakout configurations
134 dellemc.enterprise_sonic.sonic_port_breakout:
135 config:
136 state: deleted
137
138 # After state:
139 # ------------
140 #
141 # sonic# show interface breakout
142 # -----------------------------------------------
143 # Port Breakout Mode Status Interfaces
144 # -----------------------------------------------
145 # 1/1 Default Completed Eth1/1
146 # 1/11 Default Completed Eth1/11
147
148
149 # Using "merged" state
150 #
151 # Before state:
152 # -------------
153 #
154 # sonic# show interface breakout
155 # -----------------------------------------------
156 # Port Breakout Mode Status Interfaces
157 # -----------------------------------------------
158 # 1/1 4x10G Completed Eth1/1/1
159 # Eth1/1/2
160 # Eth1/1/3
161 # Eth1/1/4
162 #
163
164 - name: Merge port breakout configurations
165 dellemc.enterprise_sonic.sonic_port_breakout:
166 config:
167 - name: 1/11
168 mode: 1x100G
169 state: merged
170
171 # After state:
172 # ------------
173 #
174 # sonic# show interface breakout
175 # -----------------------------------------------
176 # Port Breakout Mode Status Interfaces
177 # -----------------------------------------------
178 # 1/1 4x10G Completed Eth1/1/1
179 # Eth1/1/2
180 # Eth1/1/3
181 # Eth1/1/4
182 # 1/11 1x100G Completed Eth1/11/1
183
184
185 # Using "replaced" state
186 #
187 # Before state:
188 # -------------
189 #
190 # sonic# show interface breakout
191 # -----------------------------------------------
192 # Port Breakout Mode Status Interfaces
193 # -----------------------------------------------
194 # 1/49 4x25G Completed Eth1/49/1
195 # Eth1/49/2
196 # Eth1/49/3
197 # Eth1/49/4
198 #
199
200 - name: Replace port breakout configurations
201 dellemc.enterprise_sonic.sonic_port_breakout:
202 config:
203 - name: 1/49
204 mode: 4x10G
205 state: replaced
206
207 # After state:
208 # ------------
209 #
210 # sonic# show interface breakout
211 # -----------------------------------------------
212 # Port Breakout Mode Status Interfaces
213 # -----------------------------------------------
214 # 1/49 4x10G Completed Eth1/49/1
215 # Eth1/49/2
216 # Eth1/49/3
217 # Eth1/49/4
218
219
220 # Using "overridden" state
221 #
222 # Before state:
223 # -------------
224 #
225 # sonic# show interface breakout
226 # ----------------------------------------------
227 # Port Breakout Mode Status Interfaces
228 # -----------------------------------------------
229 # 1/49 4x10G Completed Eth1/49/1
230 # Eth1/49/2
231 # Eth1/49/3
232 # Eth1/49/4
233 # 1/50 2x50G Completed Eth1/50/1
234 # Eth1/50/2
235 # 1/51 1x100G Completed Eth1/51/1
236 #
237
238 - name: Override port breakout configurations
239 dellemc.enterprise_sonic.sonic_port_breakout:
240 config:
241 - name: 1/52
242 mode: 4x10G
243 state: overridden
244
245 # After state:
246 # ------------
247 #
248 # sonic# show interface breakout
249 # -----------------------------------------------
250 # Port Breakout Mode Status Interfaces
251 # -----------------------------------------------
252 # 1/49 Default Completed Eth1/49
253 # 1/50 Default Completed Eth1/50
254 # 1/51 Default Completed Eth1/51
255 # 1/52 4x10G Completed Eth1/52/1
256 # Eth1/52/2
257 # Eth1/52/3
258 # Eth1/52/4
259 """
260
261 RETURN = """
262 before:
263 description: The configuration prior to the module invocation.
264 returned: always
265 type: list
266 sample: >
267 The configuration returned will always be in the same format
268 as the parameters above.
269 after:
270 description: The resulting configuration module invocation.
271 returned: when changed
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.port_breakout.port_breakout import Port_breakoutArgs
286 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.port_breakout.port_breakout import Port_breakout
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=Port_breakoutArgs.argument_spec,
296 supports_check_mode=True)
297
298 result = Port_breakout(module).execute_module()
299 module.exit_json(**result)
300
301
302 if __name__ == '__main__':
303 main()