Skip to content

Commit d582257

Browse files
committed
Add gnmcli README section
1 parent 0cd6cbe commit d582257

File tree

1 file changed

+194
-1
lines changed

1 file changed

+194
-1
lines changed

README.md

Lines changed: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ This library wraps gNMI functionality to ease usage with Cisco implementations i
88
```bash
99
pip install cisco-gnmi
1010
python -c "import cisco_gnmi; print(cisco_gnmi)"
11+
gnmcli --help
1112
```
1213

13-
This library covers the gNMI defined `capabilities`, `get`, `set`, and `subscribe` RPCs, and helper clients provide OS-specific recommendations. As commonalities and differences are identified this library will be refactored as necessary.
14+
This library covers the gNMI defined `Capabilities`, `Get`, `Set`, and `Subscribe` RPCs, and helper clients provide OS-specific recommendations. A CLI is also available. As commonalities and differences are identified between OS functionality this library will be refactored as necessary.
1415

1516
It is *highly* recommended that users of the library learn [Google Protocol Buffers](https://developers.google.com/protocol-buffers/) syntax to significantly ease usage. Understanding how to read Protocol Buffers, and reference [`gnmi.proto`](https://github.com/openconfig/gnmi/blob/master/proto/gnmi/gnmi.proto), will be immensely useful for utilizing gNMI and any other gRPC interface.
1617

18+
### gnmcli
19+
Since `v1.0.5` a gNMI CLI is available when this module is installed. `Capabilities`, `Subscribe`, `Get`, and rudimentary `Set` are supported. The CLI may be useful for simply interacting with a Cisco gNMI service, and also serves as a reference for how to use this `cisco_gnmi` library. CLI usage is documented at the bottom of this README in [gnmcli Usage](#gnmcli-usage).
20+
1721
### ClientBuilder
1822
Since `v1.0.0` a builder pattern is available with `ClientBuilder`. `ClientBuilder` provides several `set_*` methods which define the intended `Client` connectivity and a `construct` method to construct and return the desired `Client`. There are several major methods involved here:
1923

@@ -181,6 +185,195 @@ If a new `gnmi.proto` definition is released, use `update_protos.sh` to recompil
181185
./update_protos.sh
182186
```
183187

188+
### gnmicli Usage
189+
The below details the current `gnmcli` usage options.
190+
191+
```
192+
gnmcli --help
193+
usage:
194+
gnmcli <rpc> [<args>]
195+
196+
Supported RPCs:
197+
capabilities
198+
subscribe
199+
get
200+
set
201+
202+
See <rpc> --help for RPC options.
203+
204+
205+
gNMI CLI demonstrating library usage.
206+
207+
positional arguments:
208+
rpc gNMI RPC to perform against network element.
209+
210+
optional arguments:
211+
-h, --help show this help message and exit
212+
```
213+
214+
#### Capabilities
215+
```
216+
gnmcli capabilities --help
217+
usage: gnmcli [-h] [-os {None,IOS XR,NX-OS,IOS XE}]
218+
[-root_certificates ROOT_CERTIFICATES]
219+
[-private_key PRIVATE_KEY]
220+
[-certificate_chain CERTIFICATE_CHAIN]
221+
[-ssl_target_override SSL_TARGET_OVERRIDE]
222+
[-auto_ssl_target_override] [-debug]
223+
netloc
224+
225+
Performs Capabilities RPC against network element.
226+
227+
positional arguments:
228+
netloc <host>:<port>
229+
230+
optional arguments:
231+
-h, --help show this help message and exit
232+
-os {None,IOS XR,NX-OS,IOS XE}
233+
OS to use.
234+
-root_certificates ROOT_CERTIFICATES
235+
Root certificates for secure connection.
236+
-private_key PRIVATE_KEY
237+
Private key for secure connection.
238+
-certificate_chain CERTIFICATE_CHAIN
239+
Certificate chain for secure connection.
240+
-ssl_target_override SSL_TARGET_OVERRIDE
241+
gRPC SSL target override option.
242+
-auto_ssl_target_override
243+
Root certificates for secure connection.
244+
-debug Print debug messages
245+
```
246+
247+
#### Get
248+
```
249+
gnmcli get --help
250+
usage: gnmcli [-h] [-xpath XPATH]
251+
[-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]]
252+
[-data_type [{ALL,CONFIG,STATE,OPERATIONAL}]] [-dump_json]
253+
[-os {None,IOS XR,NX-OS,IOS XE}]
254+
[-root_certificates ROOT_CERTIFICATES]
255+
[-private_key PRIVATE_KEY]
256+
[-certificate_chain CERTIFICATE_CHAIN]
257+
[-ssl_target_override SSL_TARGET_OVERRIDE]
258+
[-auto_ssl_target_override] [-debug]
259+
netloc
260+
261+
Performs Get RPC against network element.
262+
263+
positional arguments:
264+
netloc <host>:<port>
265+
266+
optional arguments:
267+
-h, --help show this help message and exit
268+
-xpath XPATH XPaths to Get.
269+
-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]
270+
gNMI subscription encoding.
271+
-data_type [{ALL,CONFIG,STATE,OPERATIONAL}]
272+
gNMI GetRequest DataType
273+
-dump_json Dump as JSON instead of textual protos.
274+
-os {None,IOS XR,NX-OS,IOS XE}
275+
OS to use.
276+
-root_certificates ROOT_CERTIFICATES
277+
Root certificates for secure connection.
278+
-private_key PRIVATE_KEY
279+
Private key for secure connection.
280+
-certificate_chain CERTIFICATE_CHAIN
281+
Certificate chain for secure connection.
282+
-ssl_target_override SSL_TARGET_OVERRIDE
283+
gRPC SSL target override option.
284+
-auto_ssl_target_override
285+
Root certificates for secure connection.
286+
-debug Print debug messages
287+
```
288+
289+
#### Subscribe
290+
Subscribe currently only supports a sampled stream. `ON_CHANGE` is possible but not implemented in the CLI, yet. :)
291+
```
292+
gnmcli subscribe --help
293+
usage: gnmcli [-h] [-xpath XPATH] [-interval INTERVAL] [-dump_file DUMP_FILE]
294+
[-dump_json] [-sync_stop]
295+
[-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]]
296+
[-os {None,IOS XR,NX-OS,IOS XE}]
297+
[-root_certificates ROOT_CERTIFICATES]
298+
[-private_key PRIVATE_KEY]
299+
[-certificate_chain CERTIFICATE_CHAIN]
300+
[-ssl_target_override SSL_TARGET_OVERRIDE]
301+
[-auto_ssl_target_override] [-debug]
302+
netloc
303+
304+
Performs Subscribe RPC against network element.
305+
306+
positional arguments:
307+
netloc <host>:<port>
308+
309+
optional arguments:
310+
-h, --help show this help message and exit
311+
-xpath XPATH XPath to subscribe to.
312+
-interval INTERVAL Sample interval in seconds for Subscription.
313+
-dump_file DUMP_FILE Filename to dump to. Defaults to stdout.
314+
-dump_json Dump as JSON instead of textual protos.
315+
-sync_stop Stop on sync_response.
316+
-encoding [{JSON,BYTES,PROTO,ASCII,JSON_IETF}]
317+
gNMI subscription encoding.
318+
-os {None,IOS XR,NX-OS,IOS XE}
319+
OS to use.
320+
-root_certificates ROOT_CERTIFICATES
321+
Root certificates for secure connection.
322+
-private_key PRIVATE_KEY
323+
Private key for secure connection.
324+
-certificate_chain CERTIFICATE_CHAIN
325+
Certificate chain for secure connection.
326+
-ssl_target_override SSL_TARGET_OVERRIDE
327+
gRPC SSL target override option.
328+
-auto_ssl_target_override
329+
Root certificates for secure connection.
330+
-debug Print debug messages
331+
```
332+
333+
#### Set
334+
```
335+
gnmcli set --help
336+
usage: gnmcli [-h] [-update_json_config UPDATE_JSON_CONFIG]
337+
[-replace_json_config REPLACE_JSON_CONFIG]
338+
[-delete_xpath DELETE_XPATH] [-no_ietf] [-dump_json]
339+
[-os {None,IOS XR,NX-OS,IOS XE}]
340+
[-root_certificates ROOT_CERTIFICATES]
341+
[-private_key PRIVATE_KEY]
342+
[-certificate_chain CERTIFICATE_CHAIN]
343+
[-ssl_target_override SSL_TARGET_OVERRIDE]
344+
[-auto_ssl_target_override] [-debug]
345+
netloc
346+
347+
Performs Set RPC against network element.
348+
349+
positional arguments:
350+
netloc <host>:<port>
351+
352+
optional arguments:
353+
-h, --help show this help message and exit
354+
-update_json_config UPDATE_JSON_CONFIG
355+
JSON-modeled config to apply as an update.
356+
-replace_json_config REPLACE_JSON_CONFIG
357+
JSON-modeled config to apply as an update.
358+
-delete_xpath DELETE_XPATH
359+
XPaths to delete.
360+
-no_ietf JSON is not IETF conformant.
361+
-dump_json Dump as JSON instead of textual protos.
362+
-os {None,IOS XR,NX-OS,IOS XE}
363+
OS to use.
364+
-root_certificates ROOT_CERTIFICATES
365+
Root certificates for secure connection.
366+
-private_key PRIVATE_KEY
367+
Private key for secure connection.
368+
-certificate_chain CERTIFICATE_CHAIN
369+
Certificate chain for secure connection.
370+
-ssl_target_override SSL_TARGET_OVERRIDE
371+
gRPC SSL target override option.
372+
-auto_ssl_target_override
373+
Root certificates for secure connection.
374+
-debug Print debug messages
375+
```
376+
184377
## Licensing
185378
`cisco-gnmi-python` is licensed as [Apache License, Version 2.0](LICENSE).
186379

0 commit comments

Comments
 (0)