-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI for `gnmidiff set-to-notifs <setrequest> <subscribe responses…
…>` (#786) * Add utility `flattenOCJSON` in package `gnmidiff` This is useful for comparing between two SetRequests whose contents are in JSON_IETF format. * improve coverage by a bit * WIP for SetRequestDiff * Add flag in flattenOCJSON to remove namespace from path * Complete DiffSetRequest * improve style & comments * address comments * SetRequestDiff -> SetRequestIntentDiff * Add Format function for SetRequestIntentDiff * `minimalSetRequestIntent(req *gpb.SetRequest)` * make output more compact * Schema-aware SetRequest Diff * fix corner case * Fix bug with prefix matching * add comment explaining why don't simply just pass in a ytypes.Schema * Basic `DiffSetRequestToNotifications` * Doesn't support Subscribe/STREAM since no deletes allowed. * Format function not yet added. Will fix these in follow-up PRs. * Improve style * Change parameter newSchemaFn -> schema for performance * fix for leaf-lists * fix leaf-lists * remove stale comment * Support non-conflicting deletes in DiffSetRequestIntent * Add test cases for handling deletes in SetRequest * Handle prefix paths in gnmidiff utilities * improve style * Add Format function for `SetToNotifsDiff` * Add test for DiffSetRequestToNotifications delete Not supported, so throws error. * CLI for diffing between two SetRequests * add copyright * Add CLI for `gnmidiff set-to-notifs <setrequest> <subscribe responses>` * add unmarshalling test * Add GetResponse support and a sample SetRequest file * Update README * add output to README * move Exit(1) to main.go * update comment * remove TODO * Improve struct sharing between diff objects * Add missing file * export setrequest parsing * export notifs parsing * move textprotos to own folder * add test * add doc-comments * update version supported
- Loading branch information
Showing
12 changed files
with
1,570 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
## Usage | ||
|
||
```bash | ||
go install ./gnmidiff | ||
$ go install ./gnmidiff | ||
|
||
gnmidiff setrequest setrequest_a.textproto setrequest_b.textproto | ||
$ gnmidiff setrequest cmd/demo/setrequest.textproto cmd/demo/setrequest2.textproto | ||
|
||
SetRequestIntentDiff(-A, +B): | ||
-------- deletes -------- | ||
+ /network-instances/network-instance[name=VrfBlue]: deleted | ||
-------- updates -------- | ||
m /system/config/hostname: | ||
- "violetsareblue" | ||
+ "rosesarered" | ||
|
||
$ gnmidiff set-to-notifs cmd/demo/setrequest.textproto cmd/demo/notifs.textproto | ||
|
||
SetToNotifsDiff(-want/SetRequest, +got/Notifications): | ||
- /lacp/interfaces/interface[name=Port-Channel9]/config/interval: "FAST" | ||
- /lacp/interfaces/interface[name=Port-Channel9]/config/name: "Port-Channel9" | ||
- /lacp/interfaces/interface[name=Port-Channel9]/name: "Port-Channel9" | ||
- /network-instances/network-instance[name=VrfBlue]/config/name: "VrfBlue" | ||
- /network-instances/network-instance[name=VrfBlue]/config/type: "openconfig-network-instance-types:L3VRF" | ||
- /network-instances/network-instance[name=VrfBlue]/name: "VrfBlue" | ||
m /system/config/hostname: | ||
- "violetsareblue" | ||
+ "rosesarered" | ||
|
||
$ gnmidiff set-to-notifs cmd/demo/setrequest.textproto cmd/demo/getresponse.textproto | ||
|
||
SetToNotifsDiff(-want/SetRequest, +got/Notifications): | ||
- /lacp/interfaces/interface[name=Port-Channel9]/config/interval: "FAST" | ||
- /lacp/interfaces/interface[name=Port-Channel9]/config/name: "Port-Channel9" | ||
- /lacp/interfaces/interface[name=Port-Channel9]/name: "Port-Channel9" | ||
- /network-instances/network-instance[name=VrfBlue]/config/name: "VrfBlue" | ||
- /network-instances/network-instance[name=VrfBlue]/config/type: "openconfig-network-instance-types:L3VRF" | ||
- /network-instances/network-instance[name=VrfBlue]/name: "VrfBlue" | ||
m /system/config/hostname: | ||
- "violetsareblue" | ||
+ "rosesarered" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,291 @@ | ||
notification: { | ||
timestamp: 1676419100456944135 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "ssh-server" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "protocol-version" | ||
} | ||
} | ||
val: { | ||
string_val: "V2" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676420328291197426 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "config" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesarered" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676419100456944135 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "ntp" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "enabled" | ||
} | ||
} | ||
val: { | ||
bool_val: false | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676419100456944135 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "ntp" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "enable-ntp-auth" | ||
} | ||
} | ||
val: { | ||
bool_val: false | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676419100456944135 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "ssh-server" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "enable" | ||
} | ||
} | ||
val: { | ||
bool_val: true | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676420328448197153 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesarered" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676419100459254468 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "boot-time" | ||
} | ||
} | ||
val: { | ||
uint_val: 1676419100459308639 | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676419100456944135 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "telnet-server" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "enable" | ||
} | ||
} | ||
val: { | ||
bool_val: false | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676422427135895887 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "config" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesareredd" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676422427269965151 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesareredd" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676422434342310772 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "config" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesarered" | ||
} | ||
} | ||
} | ||
notification: { | ||
timestamp: 1676422434479082363 | ||
prefix: { | ||
origin: "openconfig" | ||
target: "fakedut" | ||
} | ||
update: { | ||
path: { | ||
elem: { | ||
name: "system" | ||
} | ||
elem: { | ||
name: "state" | ||
} | ||
elem: { | ||
name: "hostname" | ||
} | ||
} | ||
val: { | ||
string_val: "rosesarered" | ||
} | ||
} | ||
} |
Oops, something went wrong.