Skip to content

Commit e8344a3

Browse files
committed
update readme from suggestions
1 parent 0a64bc6 commit e8344a3

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

README.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,53 @@
11
# netcompare
22

3-
This library is meant to be a light-weight way to compare structured output. `netcompare` is a python library targeted at intelligently deep diffing structured data objects of json type.
3+
The `netcompare` is a light-weight way 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.
44

5-
`netcompare` also provides some basic testing of key/values within data structures.
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).
66

7-
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 later.
7+
## Usage
88

9-
## Use Cases
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.
1010

11-
`netcompare` is meant to be a building block used within testing frameworks. Originally devised specifically to test structured data returned from network device show commands, `netcompare` is designed to deeply and intelligently diff data structures while also providing tests for specific values in the data structure. `netcompare` evolved to be agnostic from the collection of that data and can compare and test and type of data structure.
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. For instance, the reference state can be collected from the network directly, a common use case for checking the network before and after a change. 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.
1212

13-
With that said, it is perfectly suited to diff data gathered from network devices via show commands, Ansible playbooks, in Django based applications such as Nautobot or Netbox, and is targeted at being the 'plumbing' behind a full network automation validation solution.
13+
This also allows maximum flexibility in how the data is collected: ansible, napalm, nornir, and any other mechanism used to collect data may be used.
1414

15-
`netcompare` was developed for checking the state of the network before and after a change; however, `netcompare` is also well suited for comparing intended state derived from a Source-of-Truth or other source of intended state.
16-
17-
The intended usage is to collect structured `show` command output before and after a change window. Prior to closing the change window, the results are compared to help determine if the change was successful as intended and if the network is in an acceptable state. The output can be stored with the change's documentation for easy reference and proof of completion.
18-
19-
With `netcompare` we've left the collection of the data up to you, to easily fit within your preferred method.
15+
`netcompare` is perfectly suited to work with data gathered from networ devices via show command, 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.
2016

2117
### Testing data structures
2218

23-
Briefly, these tests are provided to test the objects, to aide in determining the status of the data.
19+
Briefly, these tests, or `CheckTypes`, are provided to test the objects, to aide in determining the status of the data.
2420

25-
- `exact_match`: the keys and values much match between the two objects
21+
- `exact_match`: the keys and values much match, exactly, between the two objects
2622
- `tolerance`: the keys must match and the values can differ according to the 'tolerance' value provided
27-
- `parameter_match`: provide a known good key/value 'parameter' and check for it's presence or absence in the provided objects
28-
- `regex`: provide a regex and check for the presence or absence of a match in the provided object
29-
- `operator`: evaluate or compare values with a number of different operators: 'in', 'bool', 'string', and numerical comparison with 'int' and 'float'
23+
- `parameter_match`: a reference key and value is provided and it's presence (or absence) is checked in the provided object
24+
- `regex`: a reference regex pattern is provided and it's presence (or absence) is checked for a match in the provided object
25+
- `operator`: similar to parameter match, but the reference includes several different possible operators: 'in', 'bool', 'string', and numerical comparison with 'int' and 'float' to check against
3026

27+
`CheckTypes` are explained in more detail in the [CheckTypes Explained section](#check-types-explained).
3128

3229

3330
## Workflow
3431

35-
![netcompare workflow](./docs/images/workflow.png)
32+
| ![netcompare workflow](./docs/images/workflow.png) |
33+
|:---:|
34+
| **`netcompare` workflow** |
35+
36+
37+
1. The reference state object is assembled. The structured data may be collected from:
38+
39+
- an SoT
40+
- Directly from the network using any Automation that returns structured data
41+
42+
2. The Network Engineer makes changes to the network, whether it is an upgrade, peering change, or migration.
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.
3645

3746
## Library Architecture
3847

39-
![netcompare HLD](./docs/images/hld.png)
48+
| ![netcompare HLD](./docs/images/hld.png) |
49+
|:---:|
50+
| **`netcompare` architecture** |
4051

4152
An instance of `CheckType` object must be created first before passing one of the below check types as an argument:
4253

@@ -52,7 +63,7 @@ my_check = "exact_match"
5263
check = CheckType.init(my_check)
5364
```
5465

55-
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 later.
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).
5667

5768
```python
5869
bgp_pre_change = "./pre/bgp.json"
@@ -144,7 +155,7 @@ That would give us...
144155

145156
```
146157

147-
## Check Types Explained
158+
## `CheckTypes` Explained
148159

149160
### exact_match
150161

0 commit comments

Comments
 (0)