Skip to content

Commit 369c668

Browse files
committed
Add output examples and ToC
1 parent 8425605 commit 369c668

File tree

1 file changed

+124
-5
lines changed

1 file changed

+124
-5
lines changed

README.md

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@
44

55
This library wraps gNMI functionality to ease usage with Cisco implementations in Python programs. Derived from [openconfig/gnmi](https://github.com/openconfig/gnmi/tree/master/proto).
66

7+
- [cisco-gnmi-python](#cisco-gnmi-python)
8+
- [Usage](#usage)
9+
- [cisco-gnmi CLI](#cisco-gnmi-cli)
10+
- [ClientBuilder](#clientbuilder)
11+
- [Initialization Examples](#initialization-examples)
12+
- [Client](#client)
13+
- [NXClient](#nxclient)
14+
- [XEClient](#xeclient)
15+
- [XRClient](#xrclient)
16+
- [gNMI](#gnmi)
17+
- [Development](#development)
18+
- [Get Source](#get-source)
19+
- [Code Hygiene](#code-hygiene)
20+
- [Recompile Protobufs](#recompile-protobufs)
21+
- [CLI Usage](#cli-usage)
22+
- [Capabilities](#capabilities)
23+
- [Usage](#usage-1)
24+
- [Output](#output)
25+
- [Get](#get)
26+
- [Usage](#usage-2)
27+
- [Output](#output-1)
28+
- [Set](#set)
29+
- [Usage](#usage-3)
30+
- [Subscribe](#subscribe)
31+
- [Usage](#usage-4)
32+
- [Output](#output-2)
33+
- [Licensing](#licensing)
34+
- [Issues](#issues)
35+
- [Related Projects](#related-projects)
36+
737
## Usage
838
```bash
939
pip install cisco-gnmi
@@ -185,7 +215,7 @@ If a new `gnmi.proto` definition is released, use `update_protos.sh` to recompil
185215
./update_protos.sh
186216
```
187217

188-
### CLI Usage
218+
## CLI Usage
189219
The below details the current `cisco-gnmi` usage options. Please note that `Set` operations may be destructive to operations and should be tested in lab conditions.
190220

191221
```
@@ -216,12 +246,13 @@ optional arguments:
216246
-h, --help show this help message and exit
217247
```
218248

219-
#### Capabilities
249+
### Capabilities
220250
This command will output the `CapabilitiesResponse` to `stdout`.
221251
```
222252
cisco-gnmi capabilities 127.0.0.1:57500 -auto_ssl_target_override
223253
```
224254

255+
#### Usage
225256
```
226257
cisco-gnmi capabilities --help
227258
usage: cisco-gnmi [-h] [-os {None,IOS XR,NX-OS,IOS XE}]
@@ -255,12 +286,27 @@ optional arguments:
255286
-debug Print debug messages.
256287
```
257288

258-
#### Get
289+
#### Output
290+
```
291+
[cisco-gnmi-python] cisco-gnmi capabilities redacted:57500 -auto_ssl_target_override
292+
Username: admin
293+
Password:
294+
WARNING:root:Overriding SSL option from certificate could increase MITM susceptibility!
295+
INFO:root:supported_models {
296+
name: "Cisco-IOS-XR-qos-ma-oper"
297+
organization: "Cisco Systems, Inc."
298+
version: "2019-04-05"
299+
}
300+
...
301+
```
302+
303+
### Get
259304
This command will output the `GetResponse` to `stdout`. `-xpath` may be specified multiple times to specify multiple `Path`s for the `GetRequest`.
260305
```
261306
cisco-gnmi get 127.0.0.1:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
262307
```
263308

309+
#### Usage
264310
```
265311
usage: cisco-gnmi [-h] [-xpath XPATH]
266312
[-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]]
@@ -302,8 +348,37 @@ optional arguments:
302348
-debug Print debug messages.
303349
```
304350

305-
#### Set
351+
#### Output
352+
```
353+
[cisco-gnmi-python] cisco-gnmi get redacted:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
354+
Username: admin
355+
Password:
356+
WARNING:root:Overriding SSL option from certificate could increase MITM susceptibility!
357+
INFO:root:notification {
358+
timestamp: 1585607100869287743
359+
update {
360+
path {
361+
elem {
362+
name: "interfaces"
363+
}
364+
elem {
365+
name: "interface"
366+
}
367+
elem {
368+
name: "state"
369+
}
370+
elem {
371+
name: "counters"
372+
}
373+
}
374+
val {
375+
json_ietf_val: "{\"in-unicast-pkts\":\"0\",\"in-octets\":\"0\"...
376+
```
377+
378+
### Set
306379
This command has not been validated. Please note that `Set` operations may be destructive to operations and should be tested in lab conditions.
380+
381+
#### Usage
307382
```
308383
usage: cisco-gnmi [-h] [-update_json_config UPDATE_JSON_CONFIG]
309384
[-replace_json_config REPLACE_JSON_CONFIG]
@@ -347,12 +422,13 @@ optional arguments:
347422
-debug Print debug messages.
348423
```
349424

350-
#### Subscribe
425+
### Subscribe
351426
This command will output the `SubscribeResponse` to `stdout` or `-dump_file`. `-xpath` may be specified multiple times to specify multiple `Path`s for the `GetRequest`. Subscribe currently only supports a sampled stream. `ON_CHANGE` is possible but not implemented in the CLI, yet. :)
352427
```
353428
cisco-gnmi subscribe 127.0.0.1:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
354429
```
355430

431+
#### Usage
356432
```
357433
cisco-gnmi subscribe --help
358434
usage: cisco-gnmi [-h] [-xpath XPATH] [-interval INTERVAL] [-dump_file DUMP_FILE]
@@ -397,6 +473,49 @@ optional arguments:
397473
-debug Print debug messages.
398474
```
399475

476+
#### Output
477+
```
478+
[cisco-gnmi-python] cisco-gnmi subscribe redacted:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
479+
Username: admin
480+
Password:
481+
WARNING:root:Overriding SSL option from certificate could increase MITM susceptibility!
482+
INFO:root:Dumping responses to stdout as textual proto ...
483+
INFO:root:Subscribing to:
484+
/interfaces/interface/state/counters
485+
INFO:root:update {
486+
timestamp: 1585607768601000000
487+
prefix {
488+
origin: "openconfig"
489+
elem {
490+
name: "interfaces"
491+
}
492+
elem {
493+
name: "interface"
494+
key {
495+
key: "name"
496+
value: "Null0"
497+
}
498+
}
499+
elem {
500+
name: "state"
501+
}
502+
elem {
503+
name: "counters"
504+
}
505+
}
506+
update {
507+
path {
508+
elem {
509+
name: "in-octets"
510+
}
511+
}
512+
val {
513+
uint_val: 0
514+
}
515+
}
516+
...
517+
```
518+
400519
## Licensing
401520
`cisco-gnmi-python` is licensed as [Apache License, Version 2.0](LICENSE).
402521

0 commit comments

Comments
 (0)