Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_lldp_global.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 The module file for nxos_lldp_global
26 """
27 from __future__ import absolute_import, division, print_function
28
29
30 __metaclass__ = type
31
32
33 DOCUMENTATION = """
34 module: nxos_lldp_global
35 short_description: LLDP resource module
36 description: This module configures and manages the Link Layer Discovery Protocol(LLDP)
37 attributes on NX-OS platforms.
38 version_added: 1.0.0
39 author: Adharsh Srivats Rangarajan (@adharshsrivatsr)
40 notes:
41 - Tested against NxOS 7.3.(0)D1(1) on VIRL
42 - Unsupported for Cisco MDS
43 - The LLDP feature needs to be enabled before using this module
44 options:
45 running_config:
46 description:
47 - This option is used only with state I(parsed).
48 - The value of this option should be the output received from the NX-OS device
49 by executing the command B(show running-config | include lldp).
50 - The state I(parsed) reads the configuration from C(running_config) option and
51 transforms it into Ansible structured data as per the resource module's argspec
52 and the value is then returned in the I(parsed) key within the result.
53 type: str
54 config:
55 description:
56 - A list of link layer discovery configurations
57 type: dict
58 suboptions:
59 holdtime:
60 description:
61 - Amount of time the receiving device should hold the information (in seconds)
62 type: int
63 port_id:
64 description:
65 - This attribute defines if the interface names should be advertised in the
66 long(0) or short(1) form.
67 type: int
68 choices:
69 - 0
70 - 1
71 reinit:
72 description:
73 - Amount of time to delay the initialization of LLDP on any interface (in
74 seconds)
75 type: int
76 timer:
77 description:
78 - Frequency at which LLDP updates need to be transmitted (in seconds)
79 type: int
80 tlv_select:
81 description:
82 - This attribute can be used to specify the TLVs that need to be sent and
83 received in the LLDP packets. By default, all TLVs are advertised
84 type: dict
85 suboptions:
86 dcbxp:
87 description:
88 - Used to specify the Data Center Bridging Exchange Protocol TLV
89 type: bool
90 management_address:
91 description:
92 - Used to specify the management address in TLV messages
93 type: dict
94 suboptions:
95 v4:
96 description: Management address with TLV v4
97 type: bool
98 v6:
99 description: Management address with TLV v6
100 type: bool
101 port:
102 description:
103 - Used to manage port based attributes in TLV messages
104 type: dict
105 suboptions:
106 description:
107 description:
108 - Used to specify the port description TLV
109 type: bool
110 vlan:
111 description:
112 - Used to specify the port VLAN ID TLV
113 type: bool
114 power_management:
115 description:
116 - Used to specify IEEE 802.3 DTE Power via MDI TLV
117 type: bool
118 system:
119 description:
120 - Used to manage system based attributes in TLV messages
121 type: dict
122 suboptions:
123 capabilities:
124 description:
125 - Used to specify the system capabilities TLV
126 type: bool
127 description:
128 description:
129 - Used to specify the system description TLV
130 type: bool
131 name:
132 description:
133 - Used to specify the system name TLV
134 type: bool
135 state:
136 description:
137 - The state of the configuration after module completion.
138 - States C(replaced) and C(overridden) have the same behaviour for this module.
139 type: str
140 choices:
141 - merged
142 - replaced
143 - overridden
144 - deleted
145 - gathered
146 - rendered
147 - parsed
148 default: merged
149
150 """
151 EXAMPLES = """
152 # Using merged
153 # Before state:
154 # -------------
155 #
156 # user(config)# show running-config | include lldp
157 # feature lldp
158
159 - name: Merge provided configuration with device configuration
160 cisco.nxos.nxos_lldp_global:
161 config:
162 timer: 35
163 holdtime: 100
164 state: merged
165
166 # After state:
167 # ------------
168 #
169 # user(config)# show running-config | include lldp
170 # feature lldp
171 # lldp timer 35
172 # lldp holdtime 100
173
174
175 # Using replaced
176 # Before state:
177 # -------------
178 #
179 # user(config)# show running-config | include lldp
180 # feature lldp
181 # lldp holdtime 100
182 # lldp reinit 5
183 # lldp timer 35
184
185 - name: Replace device configuration of specific LLDP attributes with provided configuration
186 cisco.nxos.nxos_lldp_global:
187 config:
188 timer: 40
189 tlv_select:
190 system:
191 description: true
192 name: false
193 management_address:
194 v4: true
195 state: replaced
196
197 # After state:
198 # ------------
199 #
200 # user(config)# show running-config | include lldp
201 # feature lldp
202 # lldp timer 40
203 # no lldp tlv-select system-name
204
205
206 # Using deleted
207 # Before state:
208 # -------------
209 #
210 # user(config)# show running-config | include lldp
211 # feature lldp
212 # lldp holdtime 5
213 # lldp reinit 3
214
215 - name: Delete LLDP configuration (this will by default remove all lldp configuration)
216 cisco.nxos.nxos_lldp_global:
217 state: deleted
218
219 # After state:
220 # ------------
221 #
222 # user(config)# show running-config | include lldp
223 # feature lldp
224
225 # Using rendered
226
227 - name: Use rendered state to convert task input to device specific commands
228 cisco.nxos.nxos_lldp_global:
229 config:
230 holdtime: 130
231 port_id: 1
232 reinit: 5
233 tlv_select:
234 dcbxp: true
235 power_management: true
236 state: rendered
237
238 # Task Output (redacted)
239 # -----------------------
240
241 # rendered:
242 # - "lldp tlv-select dcbxp"
243 # - "lldp tlv-select power-management"
244 # - "lldp portid-subtype 1"
245 # - "lldp reinit 5"
246 # - "lldp holdtime 130"
247
248 # Using parsed
249
250 # parsed.cfg
251 # ------------
252 # lldp holdtime 131
253 # lldp reinit 7
254 # no lldp tlv-select system-name
255 # no lldp tlv-select system-description
256
257 # Task output (redacted)
258 # -----------------------
259
260 # parsed:
261 # holdtime: 131
262 # reinit: 7
263 # tlv_select:
264 # system:
265 # description: false
266 # name: false
267
268 # Using gathered
269
270 # Existing device config state
271 # -------------------------------
272 # feature lldp
273 # lldp holdtime 129
274 # lldp reinit 5
275 # lldp timer 35
276 # no lldp tlv-select system-name
277
278 # Task output (redacted)
279 # -----------------------
280
281 # gathered:
282 # reinit: 5
283 # timer: 35
284 # tlv_select:
285 # system:
286 # name: False
287 # holdtime: 129
288 """
289 RETURN = """
290 before:
291 description: The configuration as structured data prior to module invocation.
292 returned: always
293 type: dict
294 sample: >
295 The configuration returned will always be in the same format
296 of the parameters above.
297 after:
298 description: The configuration as structured data after module completion.
299 returned: when changed
300 type: dict
301 sample: >
302 The configuration returned will always be in the same format
303 of the parameters above.
304 commands:
305 description: The set of commands pushed to the remote device.
306 returned: always
307 type: list
308 sample: ['lldp holdtime 125', 'lldp reinit 4', 'no lldp tlv-select system-name']
309 """
310
311 from ansible.module_utils.basic import AnsibleModule
312
313 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_global.lldp_global import (
314 Lldp_globalArgs,
315 )
316 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lldp_global.lldp_global import (
317 Lldp_global,
318 )
319
320
321 def main():
322 """
323 Main entry point for module execution
324
325 :returns: the result form module invocation
326 """
327 required_if = [
328 ("state", "merged", ("config",)),
329 ("state", "replaced", ("config",)),
330 ("state", "rendered", ("config",)),
331 ("state", "parsed", ("running_config",)),
332 ]
333 mutually_exclusive = [("config", "running_config")]
334
335 module = AnsibleModule(
336 argument_spec=Lldp_globalArgs.argument_spec,
337 required_if=required_if,
338 mutually_exclusive=mutually_exclusive,
339 supports_check_mode=True,
340 )
341
342 result = Lldp_global(module).execute_module()
343 module.exit_json(**result)
344
345
346 if __name__ == "__main__":
347 main()