Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_telemetry.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_telemetry
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: nxos_telemetry
37 short_description: TELEMETRY resource module
38 description: Manages Telemetry Monitoring Service (TMS) configuration
39 version_added: 1.0.0
40 author: Mike Wiebe (@mikewiebe)
41 notes:
42 - Supported on N9k Version 7.0(3)I7(5) and later.
43 - Unsupported for Cisco MDS
44 options:
45 config:
46 description: The provided configuration
47 type: dict
48 suboptions:
49 certificate:
50 type: dict
51 description:
52 - Certificate SSL/TLS and hostname values.
53 - Value must be a dict defining values for keys (key and hostname).
54 suboptions:
55 key:
56 description:
57 - Certificate key
58 type: str
59 hostname:
60 description:
61 - Certificate hostname
62 type: str
63 compression:
64 type: str
65 description:
66 - Destination profile compression method.
67 choices:
68 - gzip
69 source_interface:
70 type: str
71 description:
72 - Destination profile source interface.
73 - Valid value is a str representing the source interface name.
74 vrf:
75 type: str
76 description:
77 - Destination profile vrf.
78 - Valid value is a str representing the vrf name.
79 destination_groups:
80 type: list
81 description:
82 - List of telemetry destination groups.
83 elements: raw
84 suboptions:
85 id:
86 type: str
87 description:
88 - Destination group identifier.
89 - Value must be an integer or string representing the destination group identifier.
90 destination:
91 type: dict
92 description:
93 - Group destination ipv4, port, protocol and encoding values.
94 - Value must be a dict defining values for keys (ip, port, protocol, encoding).
95 suboptions:
96 ip:
97 type: str
98 description:
99 - Destination group IP address.
100 port:
101 type: int
102 description:
103 - Destination group port number.
104 protocol:
105 type: str
106 description:
107 - Destination group protocol.
108 choices:
109 - HTTP
110 - TCP
111 - UDP
112 - gRPC
113 encoding:
114 type: str
115 description:
116 - Destination group encoding.
117 choices:
118 - GPB
119 - JSON
120 sensor_groups:
121 type: list
122 description:
123 - List of telemetry sensor groups.
124 elements: raw
125 suboptions:
126 id:
127 type: str
128 description:
129 - Sensor group identifier.
130 - Value must be a integer or a string representing the sensor group identifier.
131 data_source:
132 type: str
133 description:
134 - Telemetry data source.
135 choices:
136 - NX-API
137 - DME
138 - YANG
139 path:
140 type: dict
141 description:
142 - Telemetry sensor path.
143 - Value must be a dict defining values for keys (name, depth, filter_condition,
144 query_condition).
145 - Mandatory Keys (name)
146 - Optional Keys (depth, filter_condition, query_condition)
147 suboptions:
148 name:
149 type: str
150 description:
151 - Sensor group path name.
152 depth:
153 type: str
154 description:
155 - Sensor group depth.
156 filter_condition:
157 type: str
158 description:
159 - Sensor group filter condition.
160 query_condition:
161 type: str
162 description:
163 - Sensor group query condition.
164 subscriptions:
165 type: list
166 description:
167 - List of telemetry subscriptions.
168 elements: raw
169 suboptions:
170 id:
171 type: str
172 description:
173 - Subscription identifier.
174 - Value must be an integer or string representing the subscription identifier.
175 destination_group:
176 type: str
177 description:
178 - Associated destination group.
179 sensor_group:
180 type: dict
181 description:
182 - Associated sensor group.
183 - Value must be a dict defining values for keys (id, sample_interval).
184 suboptions:
185 id:
186 type: str
187 description:
188 - Associated sensor group id.
189 sample_interval:
190 type: int
191 description:
192 - Associated sensor group id sample interval.
193 state:
194 description:
195 - Final configuration state
196 type: str
197 choices:
198 - merged
199 - replaced
200 - deleted
201 - gathered
202 - overridden
203 default: merged
204
205 """
206 EXAMPLES = """
207 # Using deleted
208 # This action will delete all telemetry configuration on the device
209
210 - name: Delete Telemetry Configuration
211 cisco.nxos.nxos_telemetry:
212 state: deleted
213
214
215 # Using merged
216 # This action will merge telemetry configuration defined in the playbook with
217 # telemetry configuration that is already on the device.
218
219 - name: Merge Telemetry Configuration
220 cisco.nxos.nxos_telemetry:
221 config:
222 certificate:
223 key: /bootflash/server.key
224 hostname: localhost
225 compression: gzip
226 source_interface: Ethernet1/1
227 vrf: management
228 destination_groups:
229 - id: 2
230 destination:
231 ip: 192.168.0.2
232 port: 50001
233 protocol: gRPC
234 encoding: GPB
235 - id: 55
236 destination:
237 ip: 192.168.0.55
238 port: 60001
239 protocol: gRPC
240 encoding: GPB
241 sensor_groups:
242 - id: 1
243 data_source: NX-API
244 path:
245 name: '"show lldp neighbors detail"'
246 depth: 0
247 - id: 55
248 data_source: DME
249 path:
250 name: sys/ch
251 depth: unbounded
252 filter_condition: ne(eqptFt.operSt,"ok")
253 subscriptions:
254 - id: 5
255 destination_group: 55
256 sensor_group:
257 id: 1
258 sample_interval: 1000
259 - id: 6
260 destination_group: 2
261 sensor_group:
262 id: 55
263 sample_interval: 2000
264 state: merged
265
266
267 # Using replaced
268 # This action will replace telemetry configuration on the device with the
269 # telemetry configuration defined in the playbook.
270
271 - name: Replace Telemetry Configuration
272 cisco.nxos.nxos_telemetry:
273 config:
274 certificate:
275 key: /bootflash/server.key
276 hostname: localhost
277 compression: gzip
278 source_interface: Ethernet1/1
279 vrf: management
280 destination_groups:
281 - id: 2
282 destination:
283 ip: 192.168.0.2
284 port: 50001
285 protocol: gRPC
286 encoding: GPB
287 subscriptions:
288 - id: 5
289 destination_group: 55
290 state: replaced
291
292 # Using overridden
293 # This action will override all telemetry configuration on the device with the
294 # telemetry configuration defined in the playbook.
295
296 - name: Override Telemetry Configuration
297 cisco.nxos.nxos_telemetry:
298 config:
299 certificate:
300 key: /bootflash/server.key
301 hostname: localhost
302 compression: gzip
303 source_interface: Ethernet1/1
304 vrf: management
305 destination_groups:
306 - id: 2
307 destination:
308 ip: 192.168.0.2
309 port: 50001
310 protocol: gRPC
311 encoding: GPB
312 subscriptions:
313 - id: 5
314 destination_group: 55
315 state: overridden
316 """
317 RETURN = """
318 before:
319 description: The configuration as structured data prior to module invocation.
320 returned: always
321 type: dict
322 sample: >
323 The configuration returned will always be in the same format
324 of the parameters above.
325 after:
326 description: The configuration as structured data after module completion.
327 returned: when changed
328 type: dict
329 sample: >
330 The configuration returned will always be in the same format
331 of the parameters above.
332 commands:
333 description: The set of commands pushed to the remote device.
334 returned: always
335 type: list
336 sample: ['command 1', 'command 2', 'command 3']
337 """
338
339
340 from ansible.module_utils.basic import AnsibleModule
341
342 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.telemetry.telemetry import (
343 TelemetryArgs,
344 )
345 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.telemetry.telemetry import (
346 Telemetry,
347 )
348
349
350 def main():
351 """
352 Main entry point for module execution
353
354 :returns: the result form module invocation
355 """
356 module = AnsibleModule(argument_spec=TelemetryArgs.argument_spec, supports_check_mode=True)
357
358 result = Telemetry(module).execute_module()
359 module.exit_json(**result)
360
361
362 if __name__ == "__main__":
363 main()