Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_bfd_interfaces.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2019 Cisco and/or its affiliates.
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 """
26 The module file for nxos_bfd_interfaces
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: nxos_bfd_interfaces
37 short_description: BFD interfaces resource module
38 description: Manages attributes of Bidirectional Forwarding Detection (BFD) on the
39 interface.
40 version_added: 1.0.0
41 author: Chris Van Heuveln (@chrisvanheuveln)
42 notes:
43 - Tested against NX-OS 7.0(3)I5(1).
44 - Unsupported for Cisco MDS
45 - Feature bfd should be enabled for this module.
46 options:
47 running_config:
48 description:
49 - This option is used only with state I(parsed).
50 - The value of this option should be the output received from the NX-OS device
51 by executing the command B(show running-config | section '^interface|^feature
52 bfd').
53 - The state I(parsed) reads the configuration from C(running_config) option and
54 transforms it into Ansible structured data as per the resource module's argspec
55 and the value is then returned in the I(parsed) key within the result.
56 type: str
57 config:
58 description: The provided configuration
59 type: list
60 elements: dict
61 suboptions:
62 name:
63 type: str
64 description: The name of the interface.
65 bfd:
66 type: str
67 description:
68 - Enable/Disable Bidirectional Forwarding Detection (BFD) on the interface.
69 choices:
70 - enable
71 - disable
72 echo:
73 type: str
74 description:
75 - Enable/Disable BFD Echo functionality on the interface.
76 choices:
77 - enable
78 - disable
79 state:
80 description:
81 - The state of the configuration after module completion
82 type: str
83 choices:
84 - merged
85 - replaced
86 - overridden
87 - deleted
88 - gathered
89 - rendered
90 - parsed
91 default: merged
92
93 """
94 EXAMPLES = """
95 # Using deleted
96
97 - name: Configure interfaces
98 cisco.nxos.nxos_bfd_interfaces:
99 state: deleted
100
101
102 # Using merged
103
104 - name: Configure interfaces
105 cisco.nxos.nxos_bfd_interfaces:
106 config:
107 - name: Ethernet1/1
108 bfd: enable
109 echo: enable
110 - name: Ethernet1/2
111 bfd: disable
112 echo: disable
113 state: merged
114
115
116 # Using overridden
117
118 - name: Configure interfaces
119 cisco.nxos.nxos_bfd_interfaces:
120 config:
121 - name: Ethernet1/1
122 bfd: enable
123 echo: enable
124 - name: Ethernet1/2
125 bfd: disable
126 echo: disable
127 state: overridden
128
129
130 # Using replaced
131
132 - name: Configure interfaces
133 cisco.nxos.nxos_bfd_interfaces:
134 config:
135 - name: Ethernet1/1
136 bfd: enable
137 echo: enable
138 - name: Ethernet1/2
139 bfd: disable
140 echo: disable
141 state: replaced
142
143 # Using rendered
144
145 - name: Use rendered state to convert task input to device specific commands
146 cisco.nxos.nxos_bfd_interfaces:
147 config:
148 - name: Ethernet1/800
149 bfd: enable
150 echo: enable
151 - name: Ethernet1/801
152 bfd: disable
153 echo: disable
154 state: rendered
155
156 # Task Output (redacted)
157 # -----------------------
158
159 # rendered:
160 # - "interface Ethernet1/800"
161 # - "bfd"
162 # - "bfd echo"
163 # - "interface Ethernet1/801"
164 # - "no bfd"
165 # - "no bfd echo"
166
167 # Using parsed
168
169 # parsed.cfg
170 # ------------
171
172 # feature bfd
173 # interface Ethernet1/800
174 # no switchport
175 # no bfd
176 # no bfd echo
177 # interface Ethernet1/801
178 # no switchport
179 # no bfd
180 # interface Ethernet1/802
181 # no switchport
182 # no bfd echo
183 # interface mgmt0
184 # ip address dhcp
185 # vrf member management
186
187 - name: Use parsed state to convert externally supplied config to structured format
188 cisco.nxos.nxos_bfd_interfaces:
189 running_config: "{{ lookup('file', 'parsed.cfg') }}"
190 state: parsed
191
192 # Task output (redacted)
193 # -----------------------
194
195 # parsed:
196 # - bfd: disable
197 # echo: disable
198 # name: Ethernet1/800
199 # - bfd: disable
200 # echo: enable
201 # name: Ethernet1/801
202 # - bfd: enable
203 # echo: disable
204 # name: Ethernet1/802
205 # - bfd: enable
206 # echo: enable
207 # name: mgmt0
208
209 # Using gathered
210
211 # Existing device config state
212 # -------------------------------
213
214 # feature bfd
215 # interface Ethernet1/1
216 # no switchport
217 # no bfd
218 # interface Ethernet1/2
219 # no switchport
220 # no bfd echo
221 # interface mgmt0
222 # ip address dhcp
223 # vrf member management
224
225 - name: Gather bfd_interfaces facts from the device using nxos_bfd_interfaces
226 cisco.nxos.nxos_bfd_interfaces:
227 state: gathered
228
229 # Task output (redacted)
230 # -----------------------
231 # gathered:
232 # - name: Ethernet1/1
233 # bfd: disable
234 # echo: enable
235 # - name: Ethernet1/3
236 # echo: disable
237 # bfd: enable
238 # - name: mgmt0
239 # bfd: enable
240 # echo: enable
241 """
242 RETURN = """
243 before:
244 description: The configuration as structured data prior to module invocation.
245 returned: always
246 type: list
247 sample: >
248 The configuration returned will always be in the same format
249 of the parameters above.
250 after:
251 description: The configuration as structured data after module completion.
252 returned: when changed
253 type: list
254 sample: >
255 The configuration returned will always be in the same format
256 of the parameters above.
257 commands:
258 description: The set of commands pushed to the remote device.
259 returned: always
260 type: list
261 sample: ['interface Ethernet1/1', 'no bfd', 'no bfd echo']
262 """
263
264
265 from ansible.module_utils.basic import AnsibleModule
266
267 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bfd_interfaces.bfd_interfaces import (
268 Bfd_interfacesArgs,
269 )
270 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bfd_interfaces.bfd_interfaces import (
271 Bfd_interfaces,
272 )
273
274
275 def main():
276 """
277 Main entry point for module execution
278
279 :returns: the result form module invocation
280 """
281 required_if = [
282 ("state", "merged", ("config",)),
283 ("state", "replaced", ("config",)),
284 ("state", "overridden", ("config",)),
285 ("state", "rendered", ("config",)),
286 ("state", "parsed", ("running_config",)),
287 ]
288 mutually_exclusive = [("config", "running_config")]
289
290 module = AnsibleModule(
291 argument_spec=Bfd_interfacesArgs.argument_spec,
292 required_if=required_if,
293 mutually_exclusive=mutually_exclusive,
294 supports_check_mode=True,
295 )
296
297 result = Bfd_interfaces(module).execute_module()
298 module.exit_json(**result)
299
300
301 if __name__ == "__main__":
302 main()