You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
-
# netcompare
1
+
# jdiff
2
2
3
-
The `netcompare` is a light-weight library to examine structured data. `netcompare` provides an interface to intelligently compare json data objects as well as test for the presence (or absence) of keys, and to examine and compare their values.
3
+
The `jdiff` is a light-weight library to examine structured data. `jdiff` provides an interface to intelligently compare json data objects as well as test for the presence (or absence) of keys, and to examine and compare their values.
4
4
5
5
The library heavily relies on [jmespath](https://jmespath.org/) for traversing the json object and finding the value(s) to be evaluated. More on that [here](#customized-jmespath).
6
6
7
7
## Usage
8
8
9
-
A `netcompare` Check accepts two objects as input: the reference object, and the comparison object. The reference object is used as the intended or accepted state and it's keys and values are compared against the comparison object.
9
+
A `jdiff` Check accepts two objects as input: the reference object, and the comparison object. The reference object is used as the intended or accepted state and it's keys and values are compared against the comparison object.
10
10
11
-
`netcompare` does not collect the data for you, it simply works on data passed into it. This allows for maximum flexibility in collecting the data.
11
+
`jdiff` does not collect the data for you, it simply works on data passed into it. This allows for maximum flexibility in collecting the data.
12
12
13
13
For instance, the reference state can be collected from the network directly using any method that returns structured data: ansible, napalm, nornir to name a few. You could also choose to generate the reference state from an SoT, such as [Nautobot](https://github.com/nautobot/nautobot/), and have a true intended state.
14
14
15
-
`netcompare` is perfectly suited to work with data gathered from network devices via show commands, Ansible playbooks, as well as in applications such as [Nautobot](https://github.com/nautobot/nautobot/), or [Netbox](https://github.com/netbox-community/netbox). `netcompare` is focused on being the 'plumbing' behind a full network automation validation solution.
15
+
`jdiff` is perfectly suited to work with data gathered from network devices via show commands, Ansible playbooks, as well as in applications such as [Nautobot](https://github.com/nautobot/nautobot/), or [Netbox](https://github.com/netbox-community/netbox). `jdiff` is focused on being the 'plumbing' behind a full network automation validation solution.
16
16
17
17
### Testing data structures
18
18
@@ -29,9 +29,9 @@ Briefly, these tests, or `CheckTypes`, are provided to test the objects, to aide
1. The reference state object is assembled. The structured data may be collected from:
@@ -41,13 +41,13 @@ Briefly, these tests, or `CheckTypes`, are provided to test the objects, to aide
41
41
42
42
2. The Network Engineer makes changes to the network, whether it is an upgrade, peering change, or migration.
43
43
3. The comparison state is collected, typically directly from the network, but any method is acceptable.
44
-
4. The reference state is then compared to the current state using the netcompare library.
44
+
4. The reference state is then compared to the current state using the jdiff library.
45
45
46
46
## Library Architecture
47
47
48
-
||
48
+
||
49
49
|:---:|
50
-
|**`netcompare` architecture**|
50
+
|**`jdiff` architecture**|
51
51
52
52
An instance of `CheckType` object must be created first before passing one of the below check types as an argument:
53
53
@@ -63,7 +63,7 @@ my_check = "exact_match"
63
63
check = CheckType.init(my_check)
64
64
```
65
65
66
-
Next, define a json object as reference data, as well as a JMESPATH expression to extract the value wanted and pass them to `get_value` method. Be aware! `netcompare` works with a customized version of JMESPATH. More on that [below](#customized-jmespath).
66
+
Next, define a json object as reference data, as well as a JMESPATH expression to extract the value wanted and pass them to `get_value` method. Be aware! `jdiff` works with a customized version of JMESPATH. More on that [below](#customized-jmespath).
Since `netcompare` works with json objects as data inputs, JMESPATH was the obvious choice for traversing the data and extracting the value(s) to compare.
91
+
Since `jdiff` works with json objects as data inputs, JMESPATH was the obvious choice for traversing the data and extracting the value(s) to compare.
92
92
93
93
However, JMESPATH comes with a limitation where is not possible to define a `key` to which the `value` belongs to.
94
94
@@ -142,7 +142,7 @@ A JMESPATH expression to extract `state` is shown below.
142
142
```
143
143
144
144
How can we understand that `Idle` is relative to peer 7.7.7.7 and `Connected` to peer `10.1.0.0` ?
145
-
We could index the output but that would require some post-processing of the data. For that reason, `netcompare` use a customized version of JMESPATH where it is possible to define a reference key for the value(s) wanted. The reference key must be within `$` sign anchors and defined in a list, together with the value(s):
145
+
We could index the output but that would require some post-processing of the data. For that reason, `jdiff` use a customized version of JMESPATH where it is possible to define a reference key for the value(s) wanted. The reference key must be within `$` sign anchors and defined in a list, together with the value(s):
>>><netcompare.check_types.ExactMatchType object at 0x10ac00f10>
227
+
>>><jdiff.check_types.ExactMatchType object at 0x10ac00f10>
228
228
>>># Extract the wanted value from pre_dat to later compare with post_data. As we want compare all the body (excluding "interfaceStatistics"), we do not need to define any reference key
0 commit comments