|
4 | 4 |
|
5 | 5 | 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).
|
6 | 6 |
|
| 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 | + |
7 | 37 | ## Usage
|
8 | 38 | ```bash
|
9 | 39 | pip install cisco-gnmi
|
@@ -185,7 +215,7 @@ If a new `gnmi.proto` definition is released, use `update_protos.sh` to recompil
|
185 | 215 | ./update_protos.sh
|
186 | 216 | ```
|
187 | 217 |
|
188 |
| -### CLI Usage |
| 218 | +## CLI Usage |
189 | 219 | 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.
|
190 | 220 |
|
191 | 221 | ```
|
@@ -216,12 +246,13 @@ optional arguments:
|
216 | 246 | -h, --help show this help message and exit
|
217 | 247 | ```
|
218 | 248 |
|
219 |
| -#### Capabilities |
| 249 | +### Capabilities |
220 | 250 | This command will output the `CapabilitiesResponse` to `stdout`.
|
221 | 251 | ```
|
222 | 252 | cisco-gnmi capabilities 127.0.0.1:57500 -auto_ssl_target_override
|
223 | 253 | ```
|
224 | 254 |
|
| 255 | +#### Usage |
225 | 256 | ```
|
226 | 257 | cisco-gnmi capabilities --help
|
227 | 258 | usage: cisco-gnmi [-h] [-os {None,IOS XR,NX-OS,IOS XE}]
|
@@ -255,12 +286,27 @@ optional arguments:
|
255 | 286 | -debug Print debug messages.
|
256 | 287 | ```
|
257 | 288 |
|
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 |
259 | 304 | This command will output the `GetResponse` to `stdout`. `-xpath` may be specified multiple times to specify multiple `Path`s for the `GetRequest`.
|
260 | 305 | ```
|
261 | 306 | cisco-gnmi get 127.0.0.1:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
|
262 | 307 | ```
|
263 | 308 |
|
| 309 | +#### Usage |
264 | 310 | ```
|
265 | 311 | usage: cisco-gnmi [-h] [-xpath XPATH]
|
266 | 312 | [-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]]
|
@@ -302,8 +348,37 @@ optional arguments:
|
302 | 348 | -debug Print debug messages.
|
303 | 349 | ```
|
304 | 350 |
|
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 |
306 | 379 | 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 |
307 | 382 | ```
|
308 | 383 | usage: cisco-gnmi [-h] [-update_json_config UPDATE_JSON_CONFIG]
|
309 | 384 | [-replace_json_config REPLACE_JSON_CONFIG]
|
@@ -347,12 +422,13 @@ optional arguments:
|
347 | 422 | -debug Print debug messages.
|
348 | 423 | ```
|
349 | 424 |
|
350 |
| -#### Subscribe |
| 425 | +### Subscribe |
351 | 426 | 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. :)
|
352 | 427 | ```
|
353 | 428 | cisco-gnmi subscribe 127.0.0.1:57500 -os "IOS XR" -xpath /interfaces/interface/state/counters -auto_ssl_target_override
|
354 | 429 | ```
|
355 | 430 |
|
| 431 | +#### Usage |
356 | 432 | ```
|
357 | 433 | cisco-gnmi subscribe --help
|
358 | 434 | usage: cisco-gnmi [-h] [-xpath XPATH] [-interval INTERVAL] [-dump_file DUMP_FILE]
|
@@ -397,6 +473,49 @@ optional arguments:
|
397 | 473 | -debug Print debug messages.
|
398 | 474 | ```
|
399 | 475 |
|
| 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 | + |
400 | 519 | ## Licensing
|
401 | 520 | `cisco-gnmi-python` is licensed as [Apache License, Version 2.0](LICENSE).
|
402 | 521 |
|
|
0 commit comments