Skip to content

Commit 96b3c91

Browse files
authored
Merge pull request #72 from networktocode-llc/lvrfrc87
Rename lib in jdiff
2 parents d5763ef + 1de3d92 commit 96b3c91

24 files changed

+58
-58
lines changed

.bandit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ skips: []
33
# No need to check for security issues in the test scripts!
44
exclude_dirs:
55
- "./tests/"
6-
- "./netcompare/tests/"
6+
- "./jdiff/tests/"

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
name: 🐛 Bug Report
3-
about: Report a reproducible bug in the current release of netcompare
3+
about: Report a reproducible bug in the current release of jdiff
44
---
55

66
### Environment
77
* Python version: <!-- Example: 3.7.7 -->
8-
* netcompare version: <!-- Example: 1.0.0 -->
8+
* jdiff version: <!-- Example: 1.0.0 -->
99

1010
<!-- What did you expect to happen? -->
1111
### Expected Behavior

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ about: Propose a new feature or enhancement
55
---
66

77
### Environment
8-
* netcompare version: <!-- Example: 1.0.0 -->
8+
* jdiff version: <!-- Example: 1.0.0 -->
99

1010
<!--
1111
Describe in detail the new functionality you are proposing.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: # yamllint disable-line rule:truthy rule:comments
55
- "pull_request"
66

77
env:
8-
IMAGE_NAME: "netcompare"
8+
IMAGE_NAME: "jdiff"
99

1010
jobs:
1111
black:

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# netcompare
1+
# jdiff
22

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.
44

55
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

77
## Usage
88

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.
1010

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.
1212

1313
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.
1414

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.
1616

1717
### Testing data structures
1818

@@ -29,9 +29,9 @@ Briefly, these tests, or `CheckTypes`, are provided to test the objects, to aide
2929

3030
## Workflow
3131

32-
| ![netcompare workflow](./docs/images/workflow.png) |
32+
| ![jdiff workflow](./docs/images/workflow.png) |
3333
|:---:|
34-
| **`netcompare` workflow** |
34+
| **`jdiff` workflow** |
3535

3636

3737
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
4141

4242
2. The Network Engineer makes changes to the network, whether it is an upgrade, peering change, or migration.
4343
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.
4545

4646
## Library Architecture
4747

48-
| ![netcompare HLD](./docs/images/hld.png) |
48+
| ![jdiff HLD](./docs/images/hld.png) |
4949
|:---:|
50-
| **`netcompare` architecture** |
50+
| **`jdiff` architecture** |
5151

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

@@ -63,7 +63,7 @@ my_check = "exact_match"
6363
check = CheckType.init(my_check)
6464
```
6565

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).
6767

6868
```python
6969
bgp_pre_change = "./pre/bgp.json"
@@ -88,7 +88,7 @@ results = check.evaluate(post_value, pre_value, **evaluate_args)
8888

8989
## Customized JMESPATH
9090

91-
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.
9292

9393
However, JMESPATH comes with a limitation where is not possible to define a `key` to which the `value` belongs to.
9494

@@ -142,7 +142,7 @@ A JMESPATH expression to extract `state` is shown below.
142142
```
143143

144144
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):
146146

147147
```python
148148
"result[0].vrfs.default.peerList[*].[$peerAddress$,state]
@@ -166,7 +166,7 @@ Examples:
166166

167167

168168
```python
169-
>>> from netcompare import CheckType
169+
>>> from jdiff import CheckType
170170
>>> pre_data = {
171171
"jsonrpc": "2.0",
172172
"id": "EapiExplorer-1",
@@ -224,7 +224,7 @@ Examples:
224224
>>> # Create an instance of CheckType object with 'exact_match' as check-type argument.
225225
>>> my_check = CheckType.init(check_type="exact_match")
226226
>>> my_check
227-
>>> <netcompare.check_types.ExactMatchType object at 0x10ac00f10>
227+
>>> <jdiff.check_types.ExactMatchType object at 0x10ac00f10>
228228
>>> # 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
229229
>>> pre_value = my_check.get_value(output=pre_data, path=my_jmspath, exclude=exclude_fields)
230230
>>> pre_value
@@ -256,7 +256,7 @@ Let's see a better way to run `exact_match` for this specific case. Since we are
256256
```
257257
Targeting only the `interfaceStatus` key, we would need to define a reference key (in this case `$name$`), we would not define any exclusion list.
258258

259-
The anchor logic for the reference key applies to all check-types available in `netcompare`
259+
The anchor logic for the reference key applies to all check-types available in `jdiff`
260260

261261

262262
### Tolerance
@@ -329,7 +329,7 @@ Lets have a look to a couple of examples:
329329
>>> pre_value = my_check.get_value(pre_data, my_jmspath)
330330
>>> post_value = my_check.get_value(post_data, my_jmspath)
331331
>>> actual_results = my_check.evaluate(post_value, pre_value, **my_tolerance_arguments)
332-
>>> # Netcompare returns the value that are not within the 10%
332+
>>> # jdiff returns the value that are not within the 10%
333333
>>> actual_results
334334
({'10.1.0.0': {'accepted_prefixes': {'new_value': 500, 'old_value': 900}, 'received_prefixes': {'new_value': 599, 'old_value': 999}, 'sent_prefixes': {'new_value': 511, 'old_value': 1011}}}, False)
335335
>>> # Let's difine a higher tolerance
@@ -443,7 +443,7 @@ Let's run an example where we want to check the `burnedInAddress` key has a stri
443443
>>> # What if we want "no-match"?
444444
>>> regex_args = {"regex": "(?:[0-9a-fA-F]:?){12}", "mode": "no-match"}
445445
>>> result = check.evaluate(value, **regex_args)
446-
>>> # Netcompare return the failing data as the regex match the value
446+
>>> # jdiff return the failing data as the regex match the value
447447
>>> result
448448
({'Management1': {'burnedInAddress': '08:00:27:e6:b2:f8'}}, False)
449449
```
File renamed without changes.

netcompare/check_types.py renamed to jdiff/check_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CheckType(ABC):
1919
"""Check Type Base Abstract Class."""
2020

2121
@staticmethod
22-
def init(check_type: str):
22+
def create(check_type: str):
2323
"""Factory pattern to get the appropriate CheckType implementation.
2424
2525
Args:
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)