Skip to content

Commit ba742f2

Browse files
committed
Update for gRPC dial-in example
1 parent f5c4d87 commit ba742f2

File tree

1 file changed

+43
-142
lines changed

1 file changed

+43
-142
lines changed

_tutorials/2016-07-25-configuring-model-driven-telemetry-mdt-with-yang.md

+43-142
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Cisco-IOS-XR-telemetry-model-driven-cfg
4949
{{ output | markdownify }}
5050
</div>
5151

52-
The first model is the [OpenConfig telemetry model](https://github.com/openconfig/public/blob/master/release/models/telemetry/openconfig-telemetry.yang) and the second is the XR native telemetry model. If you look at them in detail, you will notice that the native model closely follows the OpenConfig model. In fact, the two are more or less functionally equivalent, although the native model will let you do things that are supported by IOS XR but not defined by OpenConfig (like disable TLS). In this tutorial, I'll focus on openconfig-telemetry, but you could do everything with Cisco-IOS-XR-telemetry-model-driven-cfg as well.
52+
The first model is the [OpenConfig telemetry model](https://github.com/openconfig/public/blob/master/release/models/telemetry/openconfig-telemetry.yang) and the second is the XR native telemetry model. If you look at them in detail, you will notice that the native model closely follows the OpenConfig model, although the native model will let you do things that are supported by IOS XR but not defined by OpenConfig (like disable TLS). In this tutorial, I'll focus on openconfig-telemetry, but you could do everything with Cisco-IOS-XR-telemetry-model-driven-cfg as well.
5353

5454
The NETCONF \<get-schema\> operation will give you the contents of the schema but the full YANG output can be really verbose and overwhelming, so I'll pipe the output to the [pyang](https://github.com/mbj4668/pyang) utility for a compact tree view with the following bit of code:
5555

@@ -163,7 +163,7 @@ module: openconfig-telemetry
163163

164164
You can spend a lot of time understanding the intricacies of YANG and all the details, but all we really need to know for now is that the model has three major sections:
165165

166-
- The **destination-group** tells the router where to send telemetry data and how.
166+
- The **destination-group** tells the router where to send telemetry data and how. Only needed for dial-out configuration.
167167
- The **sensor-group** identifies a list of YANG models that the router should stream.
168168
- The **subscription** ties together the destination-group and the sensor-group.
169169

@@ -188,20 +188,20 @@ Script Output:
188188

189189
```
190190
<?xml version="1.0"?>
191-
<rpc-reply message-id="urn:uuid:b92e495e-9027-4cb6-8e36-2efdbf7ce2ab" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
191+
<rpc-reply message-id="urn:uuid:939c718e-81ee-43ec-9733-565aa53fedb2" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
192192
<data>
193193
<telemetry-system xmlns="http://openconfig.net/yang/telemetry">
194194
<sensor-groups>
195195
<sensor-group>
196-
<sensor-group-id>SGroup1</sensor-group-id>
196+
<sensor-group-id>SGroup3</sensor-group-id>
197197
<config>
198-
<sensor-group-id>SGroup1</sensor-group-id>
198+
<sensor-group-id>SGroup3</sensor-group-id>
199199
</config>
200200
<sensor-paths>
201201
<sensor-path>
202-
<path>Cisco-IOS-XR-infra-statsd-oper:infra-statistics%2finterfaces%2finterface%2flatest%2fgeneric-counters</path>
202+
<path>openconfig-interfaces:interfaces%2finterface</path>
203203
<config>
204-
<path>Cisco-IOS-XR-infra-statsd-oper:infra-statistics%2finterfaces%2finterface%2flatest%2fgeneric-counters</path>
204+
<path>openconfig-interfaces:interfaces%2finterface</path>
205205
</config>
206206
</sensor-path>
207207
</sensor-paths>
@@ -210,53 +210,27 @@ Script Output:
210210
<subscriptions>
211211
<persistent>
212212
<subscription>
213-
<subscription-id>Sub1</subscription-id>
213+
<subscription-id>Sub3</subscription-id>
214214
<config>
215-
<subscription-id>Sub1</subscription-id>
215+
<subscription-id>Sub3</subscription-id>
216216
</config>
217217
<sensor-profiles>
218218
<sensor-profile>
219-
<sensor-group>SGroup1</sensor-group>
219+
<sensor-group>SGroup3</sensor-group>
220220
<config>
221-
<sensor-group>SGroup1</sensor-group>
221+
<sensor-group>SGroup3</sensor-group>
222222
<sample-interval>30000</sample-interval>
223223
</config>
224224
</sensor-profile>
225225
</sensor-profiles>
226-
<destination-groups>
227-
<destination-group>
228-
<group-id>DGroup1</group-id>
229-
<config>
230-
<group-id>DGroup1</group-id>
231-
</config>
232-
</destination-group>
233-
</destination-groups>
234226
</subscription>
235227
</persistent>
236228
</subscriptions>
237-
<destination-groups>
238-
<destination-group>
239-
<group-id>DGroup1</group-id>
240-
<config>
241-
<group-id>DGroup1</group-id>
242-
</config>
243-
<destinations>
244-
<destination>
245-
<destination-address>172.30.8.4</destination-address>
246-
<config>
247-
<destination-address>172.30.8.4</destination-address>
248-
<destination-port>5432</destination-port>
249-
<destination-protocol>tcp</destination-protocol>
250-
</config>
251-
<destination-port>5432</destination-port>
252-
</destination>
253-
</destinations>
254-
</destination-group>
255-
</destination-groups>
256229
</telemetry-system>
257230
</data>
258231
</rpc-reply>
259232
233+
260234
```
261235
{% endcapture %}
262236

@@ -266,29 +240,23 @@ Script Output:
266240

267241
So what does all that mean to the router? It breaks down into three parts which you'll recall from the YANG model above:
268242

269-
- The **destination-group** tells the router where to send telemetry data and how. If you parse the XML above, you'll see that the router has a destination group named "DGroup 1" that goes to 172.30.8.4 port 5432 using the self-describing GPB encoding.
270-
- The **sensor-group** identifies a list of YANG models that the router should stream. In this case, the router has a sensor-group called "SGroup1" that will send interface statistics data from the Cisco-IOS-XR-infra-statsd-oper YANG model.
271-
- The **subscription** ties together the destination-group and the sensor-group. This router has a subscription name "Sub1" that will send the list of models in SGroup1 to the destinations in DGroup1 at an interval of 30 second (30000 milleseconds).
243+
- The **destination-group** tells the router where to send telemetry data and how. The absence of a destination-group in the output above alerts us to the fact that this is a dial-in configuration (the collector will initiate the session to the router).
244+
- The **sensor-group** identifies a list of YANG models that the router should stream. In this case, the router has a sensor-group called "SGroup3" that will send interface statistics data from the OpenConfig Interfaces YANG model.
245+
- The **subscription** ties together the destination-group and the sensor-group. This router has a subscription name "Sub3" that will send the list of models in SGroup3 at an interval of 30 second (30000 milleseconds).
272246

273-
If you read the [earlier tutorial](https://xrdocs.github.io/telemetry/tutorials/2016-07-21-configuring-model-driven-telemetry-mdt/) on configuring MDT with CLI, you might recognize this as the same as the TCP Dial-Out configuration described there. If you missed that thrilling installment, the XML above is the YANG equivalent of this CLI:
247+
If you read the [earlier tutorial](https://xrdocs.github.io/telemetry/tutorials/2016-07-21-configuring-model-driven-telemetry-mdt/) on configuring MDT with CLI, you might recognize this as the same as the gRPC dial-in configuration described there. If you missed that thrilling installment, the XML above is the YANG equivalent of this CLI:
274248

275249
{% capture "output" %}
276250
CLI Output:
277251

278252
```
279-
telemetry model-driven
280-
destination-group DGroup1
281-
address family ipv4 172.30.8.4 port 5432
282-
encoding self-describing-gpb
283-
protocol tcp
284-
!
253+
telemetry model-driven
254+
sensor-group SGroup3
255+
sensor-path openconfig-interfaces:interfaces/interface
285256
!
286-
sensor-group SGroup1
287-
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
257+
subscription Sub3
258+
sensor-group-id SGroup3 sample-interval 30000
288259
!
289-
subscription Sub1
290-
sensor-group-id SGroup1 sample-interval 30000
291-
destination-id DGroup1
292260
```
293261

294262
{% endcapture %}
@@ -299,47 +267,24 @@ telemetry model-driven
299267

300268
## Edit-Config
301269

302-
So let's say we want to add a second destination (to `2001:db8:0:100::b`) to DGroup1 and a second model to SGroup1 (Cisco-IOS-XR-ipv4-arp-oper). We can do that with the following NETCONF operations:
270+
So let's say we want to add a second model to SGroup3 (Cisco-IOS-XR-ipv4-arp-oper). We can do that with the following NETCONF operations:
303271

304272
```python
305273
edit_data = '''
306274
<config>
307275
<telemetry-system xmlns="http://openconfig.net/yang/telemetry">
308276
<sensor-groups>
309277
<sensor-group>
310-
<sensor-group-id>SGroup1</sensor-group-id>
311-
<config>
312-
<sensor-group-id>SGroup1</sensor-group-id>
313-
</config>
278+
<sensor-group-id>SGroup3</sensor-group-id>
314279
<sensor-paths>
315280
<sensor-path>
316-
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
317281
<config>
318282
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
319283
</config>
320284
</sensor-path>
321285
</sensor-paths>
322286
</sensor-group>
323287
</sensor-groups>
324-
<destination-groups>
325-
<destination-group>
326-
<group-id>DGroup1</group-id>
327-
<config>
328-
<group-id>DGroup1</group-id>
329-
</config>
330-
<destinations>
331-
<destination>
332-
<destination-address>2001:db8:0:100::b</destination-address>
333-
<config>
334-
<destination-address>2001:db8:0:100::b</destination-address>
335-
<destination-port>5432</destination-port>
336-
<destination-protocol>grpc</destination-protocol>
337-
</config>
338-
<destination-port>5432</destination-port>
339-
</destination>
340-
</destinations>
341-
</destination-group>
342-
</destination-groups>
343288
</config>
344289
'''
345290

@@ -354,32 +299,34 @@ c = xr.get_config(source='running', filter=('subtree', filter))
354299
print(c)
355300
```
356301

357-
... we'll see that SGroup1 and DGroup1 have the new additions.
302+
... we'll see that SGroup3 has the new addition.
358303

359304

360305
{% capture "output" %}
361306
Script Output:
362307

363308
```
364-
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
309+
<?xml version="1.0"?>
310+
<rpc-reply message-id="urn:uuid:abd0a7ee-5f06-4754-b2a3-dae6e3d797aa" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
311+
<data>
365312
<telemetry-system xmlns="http://openconfig.net/yang/telemetry">
366313
<sensor-groups>
367314
<sensor-group>
368-
<sensor-group-id>SGroup1</sensor-group-id>
315+
<sensor-group-id>SGroup3</sensor-group-id>
369316
<config>
370-
<sensor-group-id>SGroup1</sensor-group-id>
317+
<sensor-group-id>SGroup3</sensor-group-id>
371318
</config>
372319
<sensor-paths>
373320
<sensor-path>
374-
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
321+
<path>openconfig-interfaces:interfaces%2finterface</path>
375322
<config>
376-
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
323+
<path>openconfig-interfaces:interfaces%2finterface</path>
377324
</config>
378325
</sensor-path>
379326
<sensor-path>
380-
<path>Cisco-IOS-XR-infra-statsd-oper:infra-statistics%2finterfaces%2finterface%2flatest%2fgeneric-counters</path>
327+
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
381328
<config>
382-
<path>Cisco-IOS-XR-infra-statsd-oper:infra-statistics%2finterfaces%2finterface%2flatest%2fgeneric-counters</path>
329+
<path>Cisco-IOS-XR-ipv4-arp-oper:arp%2fnodes%2fnode%2fentries%2fentry</path>
383330
</config>
384331
</sensor-path>
385332
</sensor-paths>
@@ -388,60 +335,25 @@ Script Output:
388335
<subscriptions>
389336
<persistent>
390337
<subscription>
391-
<subscription-id>Sub1</subscription-id>
338+
<subscription-id>Sub3</subscription-id>
392339
<config>
393-
<subscription-id>Sub1</subscription-id>
340+
<subscription-id>Sub3</subscription-id>
394341
</config>
395342
<sensor-profiles>
396343
<sensor-profile>
397-
<sensor-group>SGroup1</sensor-group>
344+
<sensor-group>SGroup3</sensor-group>
398345
<config>
399-
<sensor-group>SGroup1</sensor-group>
346+
<sensor-group>SGroup3</sensor-group>
400347
<sample-interval>30000</sample-interval>
401348
</config>
402349
</sensor-profile>
403350
</sensor-profiles>
404-
<destination-groups>
405-
<destination-group>
406-
<group-id>DGroup1</group-id>
407-
<config>
408-
<group-id>DGroup1</group-id>
409-
</config>
410-
</destination-group>
411-
</destination-groups>
412351
</subscription>
413352
</persistent>
414353
</subscriptions>
415-
<destination-groups>
416-
<destination-group>
417-
<group-id>DGroup1</group-id>
418-
<config>
419-
<group-id>DGroup1</group-id>
420-
</config>
421-
<destinations>
422-
<destination>
423-
<destination-address>172.30.8.4</destination-address>
424-
<config>
425-
<destination-address>172.30.8.4</destination-address>
426-
<destination-port>5432</destination-port>
427-
<destination-protocol>tcp</destination-protocol>
428-
</config>
429-
<destination-port>5432</destination-port>
430-
</destination>
431-
<destination>
432-
<destination-address>2001:db8:0:100::b</destination-address>
433-
<config>
434-
<destination-address>2001:db8:0:100::b</destination-address>
435-
<destination-port>5432</destination-port>
436-
<destination-protocol>grpc</destination-protocol>
437-
</config>
438-
<destination-port>5432</destination-port>
439-
</destination>
440-
</destinations>
441-
</destination-group>
442-
</destination-groups>
443354
</telemetry-system>
444355
</data>
356+
</rpc-reply>
445357
446358
```
447359
{% endcapture %}
@@ -457,25 +369,14 @@ CLI Output:
457369

458370
```
459371
RP/0/RP0/CPU0:SunC#show run telemetry model-driven
460-
Mon Jul 25 19:27:26.632 UTC
372+
Mon Aug 8 20:09:57.149 UTC
461373
telemetry model-driven
462-
destination-group DGroup1
463-
address family ipv4 172.30.8.4 port 5432
464-
encoding self-describing-gpb
465-
protocol tcp
466-
!
467-
address family ipv6 2001:db8:0:100::b port 5432
468-
encoding self-describing-gpb
469-
protocol grpc
470-
!
471-
!
472-
sensor-group SGroup1
374+
sensor-group SGroup3
375+
sensor-path openconfig-interfaces:interfaces/interface
473376
sensor-path Cisco-IOS-XR-ipv4-arp-oper:arp/nodes/node/entries/entry
474-
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
475377
!
476-
subscription Sub1
477-
sensor-group-id SGroup1 sample-interval 30000
478-
destination-id DGroup1
378+
subscription Sub3
379+
sensor-group-id SGroup3 sample-interval 30000
479380
!
480381
!
481382
```

0 commit comments

Comments
 (0)