Skip to content

Commit b4144e6

Browse files
committed
Add Set example
1 parent 369c668 commit b4144e6

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ This library wraps gNMI functionality to ease usage with Cisco implementations i
2727
- [Output](#output-1)
2828
- [Set](#set)
2929
- [Usage](#usage-3)
30+
- [Output](#output-2)
3031
- [Subscribe](#subscribe)
3132
- [Usage](#usage-4)
32-
- [Output](#output-2)
33+
- [Output](#output-3)
3334
- [Licensing](#licensing)
3435
- [Issues](#issues)
3536
- [Related Projects](#related-projects)
@@ -376,7 +377,7 @@ INFO:root:notification {
376377
```
377378

378379
### Set
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+
Please note that `Set` operations may be destructive to operations and should be tested in lab conditions. Behavior is not fully validated.
380381

381382
#### Usage
382383
```
@@ -422,6 +423,51 @@ optional arguments:
422423
-debug Print debug messages.
423424
```
424425

426+
#### Output
427+
Let's create a harmless loopback interface based from [`openconfig-interfaces.yang`](https://github.com/openconfig/public/blob/master/release/models/interfaces/openconfig-interfaces.yang).
428+
429+
`config.json`
430+
```json
431+
{
432+
"openconfig-interfaces:interfaces": {
433+
"interface": [
434+
{
435+
"name": "Loopback9339"
436+
}
437+
]
438+
}
439+
}
440+
```
441+
442+
```
443+
[cisco-gnmi-python] cisco-gnmi set redacted:57500 -os "IOS XR" -auto_ssl_target_override -update_json_config config.json
444+
Username: admin
445+
Password:
446+
WARNING:root:Overriding SSL option from certificate could increase MITM susceptibility!
447+
INFO:root:response {
448+
path {
449+
origin: "openconfig-interfaces"
450+
elem {
451+
name: "interfaces"
452+
}
453+
}
454+
message {
455+
}
456+
op: UPDATE
457+
}
458+
message {
459+
}
460+
timestamp: 1585715036783451369
461+
```
462+
463+
And on IOS XR...a loopback interface!
464+
```
465+
...
466+
interface Loopback9339
467+
!
468+
...
469+
```
470+
425471
### Subscribe
426472
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. :)
427473
```

src/cisco_gnmi/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def load_json_file(filename):
239239
config = None
240240
with open(filename, "r") as config_fd:
241241
config = json.load(config_fd)
242-
return config
242+
return json.dumps(config)
243243

244244
if args.update_json_config or args.replace_json_config:
245245
kwargs = {}

0 commit comments

Comments
 (0)