Skip to content

Commit

Permalink
Add Set example
Browse files Browse the repository at this point in the history
  • Loading branch information
remingtonc committed Apr 1, 2020
1 parent 369c668 commit b4144e6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ This library wraps gNMI functionality to ease usage with Cisco implementations i
- [Output](#output-1)
- [Set](#set)
- [Usage](#usage-3)
- [Output](#output-2)
- [Subscribe](#subscribe)
- [Usage](#usage-4)
- [Output](#output-2)
- [Output](#output-3)
- [Licensing](#licensing)
- [Issues](#issues)
- [Related Projects](#related-projects)
Expand Down Expand Up @@ -376,7 +377,7 @@ INFO:root:notification {
```

### Set
This command has not been validated. Please note that `Set` operations may be destructive to operations and should be tested in lab conditions.
Please note that `Set` operations may be destructive to operations and should be tested in lab conditions. Behavior is not fully validated.

#### Usage
```
Expand Down Expand Up @@ -422,6 +423,51 @@ optional arguments:
-debug Print debug messages.
```

#### Output
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).

`config.json`
```json
{
"openconfig-interfaces:interfaces": {
"interface": [
{
"name": "Loopback9339"
}
]
}
}
```

```
[cisco-gnmi-python] cisco-gnmi set redacted:57500 -os "IOS XR" -auto_ssl_target_override -update_json_config config.json
Username: admin
Password:
WARNING:root:Overriding SSL option from certificate could increase MITM susceptibility!
INFO:root:response {
path {
origin: "openconfig-interfaces"
elem {
name: "interfaces"
}
}
message {
}
op: UPDATE
}
message {
}
timestamp: 1585715036783451369
```

And on IOS XR...a loopback interface!
```
...
interface Loopback9339
!
...
```

### Subscribe
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. :)
```
Expand Down
2 changes: 1 addition & 1 deletion src/cisco_gnmi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def load_json_file(filename):
config = None
with open(filename, "r") as config_fd:
config = json.load(config_fd)
return config
return json.dumps(config)

if args.update_json_config or args.replace_json_config:
kwargs = {}
Expand Down

0 comments on commit b4144e6

Please sign in to comment.