Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_lldp_interfaces.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_interfaces
26 """
27
28 from __future__ import absolute_import, division, print_function
29
30
31 __metaclass__ = type
32
33
34 DOCUMENTATION = """
35 module: nxos_lldp_interfaces
36 short_description: LLDP interfaces resource module
37 description: This module manages interfaces' configuration for Link Layer Discovery
38 Protocol (LLDP) on NX-OS platforms.
39 version_added: 1.0.0
40 author: Adharsh Srivats Rangarajan (@adharshsrivatsr)
41 notes:
42 - Tested against NXOS 7.3.(0)D1(1) on VIRL
43 - Unsupported for Cisco MDS
44 - The LLDP feature needs to be enabled before using this module
45 options:
46 running_config:
47 description:
48 - This option is used only with state I(parsed).
49 - The value of this option should be the output received from the NX-OS device
50 by executing the command B(show running-config | section ^interface).
51 - The state I(parsed) reads the configuration from C(running_config) option and
52 transforms it into Ansible structured data as per the resource module's argspec
53 and the value is then returned in the I(parsed) key within the result.
54 type: str
55 config:
56 description:
57 - A list of link layer discovery configurations for interfaces.
58 type: list
59 elements: dict
60 suboptions:
61 name:
62 description:
63 - Name of the interface
64 required: true
65 type: str
66 receive:
67 description:
68 - Used to enable or disable the reception of LLDP packets on that interface.
69 By default, this is enabled after LLDP is enabled globally.
70 type: bool
71 transmit:
72 description:
73 - Used to enable or disable the transmission of LLDP packets on that interface.
74 By default, this is enabled after LLDP is enabled globally.
75 type: bool
76 tlv_set:
77 description:
78 - Used to configure TLV parameters on the interface
79 type: dict
80 suboptions:
81 management_address:
82 description:
83 - Used to mention the IPv4 or IPv6 management address for the interface
84 type: str
85 vlan:
86 description:
87 - Used to mention the VLAN for the interface
88 type: int
89 state:
90 description:
91 - The state the configuration should be left in
92 type: str
93 choices:
94 - merged
95 - replaced
96 - overridden
97 - deleted
98 - gathered
99 - rendered
100 - parsed
101 default: merged
102
103 """
104 EXAMPLES = """
105 # Using merged
106
107 # Before state:
108 # -------------
109 #
110
111 - name: Merge provided configuration with device configuration
112 cisco.nxos.nxos_lldp_interfaces:
113 config:
114 - name: Ethernet1/4
115 receive: false
116 transmit: true
117 tlv_set:
118 management_address: 192.168.122.64
119 vlan: 12
120 state: merged
121
122 # After state:
123 # -------------
124 #
125 # interface Ethernet1/4
126 # no lldp receive
127 # lldp tlv-set management-address 192.168.122.64
128 # lldp tlv-set vlan 12
129
130
131 # Using replaced
132
133 # Before state:
134 # ------------
135 #
136 # interface Ethernet1/4
137 # no lldp receive
138 # lldp tlv-set management-address 192.168.122.64
139 # interface Ethernet1/5
140 # no lldp transmit
141 # lldp tlv-set vlan 10
142
143 - name: Replace LLDP configuration on interfaces with given configuration
144 cisco.nxos.nxos_lldp_interfaces:
145 config:
146 - name: Ethernet1/4
147 transmit: false
148 tlv_set:
149 vlan: 2
150 state: replaced
151
152
153 # After state:
154 # -----------
155 #
156 # interface Ethernet1/4
157 # no lldp transmit
158 # lldp tlv_set vlan 2
159 # interface Ethernet1/5
160 # no lldp transmit
161 # lldp tlv-set vlan 10
162
163
164 # Using overridden
165
166 # Before state:
167 # ------------
168 #
169 # interface Ethernet1/4
170 # no lldp receive
171 # lldp tlv-set management-address 192.168.122.64
172 # interface Ethernet1/5
173 # no lldp transmit
174 # lldp tlv-set vlan 10
175
176 - name: Override LLDP configuration on all interfaces with given configuration
177 cisco.nxos.nxos_lldp_interfaces:
178 config:
179 - name: Ethernet1/7
180 receive: false
181 tlv_set:
182 vlan: 12
183 state: overridden
184
185
186 # After state:
187 # -----------
188 #
189 # interface Ethernet1/7
190 # no lldp receive
191 # lldp tlv_set vlan 12
192
193
194 # Using deleted
195
196 # Before state:
197 # ------------
198 #
199 # interface Ethernet1/4
200 # lldp tlv-set management vlan 24
201 # no lldp transmit
202 # interface mgmt0
203 # no lldp receive
204
205 - name: Delete LLDP interfaces configuration
206 cisco.nxos.nxos_lldp_interfaces:
207 state: deleted
208
209 # After state:
210 # ------------
211 #
212 """
213 RETURN = """
214 before:
215 description: The configuration prior to the model invocation.
216 returned: always
217 type: list
218 sample: >
219 The configuration returned will always be in the same format
220 of the parameters above.
221 after:
222 description: The resulting configuration model invocation.
223 returned: when changed
224 type: list
225 sample: >
226 The configuration returned will always be in the same format
227 of the parameters above.
228 commands:
229 description: The set of commands pushed to the remote device.
230 returned: always
231 type: list
232 sample: ['interface Ethernet1/2', 'lldp receive', 'lldp tlv-set vlan 12']
233 """
234
235 from ansible.module_utils.basic import AnsibleModule
236
237 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_interfaces.lldp_interfaces import (
238 Lldp_interfacesArgs,
239 )
240 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lldp_interfaces.lldp_interfaces import (
241 Lldp_interfaces,
242 )
243
244
245 def main():
246 """
247 Main entry point for module execution
248
249 :returns: the result form module invocation
250 """
251 module = AnsibleModule(
252 argument_spec=Lldp_interfacesArgs.argument_spec,
253 supports_check_mode=True,
254 )
255
256 result = Lldp_interfaces(module).execute_module()
257 module.exit_json(**result)
258
259
260 if __name__ == "__main__":
261 main()