Skip to content

Commit 04890dc

Browse files
authored
Merge pull request #53 from networktocode/dga-examples-nautobot
Add new example with pynautobot
2 parents b692957 + e47dd69 commit 04890dc

File tree

13 files changed

+2021
-4
lines changed

13 files changed

+2021
-4
lines changed

examples/example1/backend_a.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# pylint: disable=wrong-import-order
1919
from diffsync import DiffSync
20-
from models import Site, Device, Interface
20+
from models import Site, Device, Interface # pylint: disable=no-name-in-module
2121

2222
DATA = {
2323
"nyc": {

examples/example1/backend_b.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# pylint: disable=wrong-import-order
1919
from diffsync import DiffSync
20-
from models import Site, Device, Interface
20+
from models import Site, Device, Interface # pylint: disable=no-name-in-module
2121

2222
DATA = {
2323
"atl": {

examples/example1/backend_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# pylint: disable=wrong-import-order
1919
from diffsync import DiffSync
20-
from models import Site, Device, Interface
20+
from models import Site, Device, Interface # pylint: disable=no-name-in-module
2121

2222
DATA = {
2323
"nyc": {

examples/example3/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# Example 3
3+
4+
This is a simple example to show how DiffSync can be used to compare and synchronize data with a remote system like [Nautobot](https://nautobot.readthedocs.io) via a REST API.
5+
6+
For this example, we have a shared model for Region and Country defined in `models.py`.
7+
A country must be part of a region and has an attribute to capture its population.
8+
9+
The comparison and synchronization of dataset is done between a local JSON file and the [public instance of Nautobot](https://demo.nautobot.com).
10+
11+
12+
## Install the requirements
13+
14+
to use this example you must have some dependencies installed, please make sure to run
15+
```
16+
pip install -r requirements.txt
17+
```
18+
19+
## Setup the environment
20+
21+
By default this example will interact with the public sandbox of Nautobot at https://demo.nautobot.com but you can use your own version of Nautobot by providing a new URL and a new API token using the environment variables `NAUTOBOT_URL` & `NAUTOBOT_TOKEN`
22+
23+
```
24+
export NAUTOBOT_URL = "https://demo.nautobot.com"
25+
export NAUTOBOT_TOKEN = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
26+
```
27+
28+
## Try the example
29+
30+
The first time you run this example, a lot of changes should be reported between Nautobot and the local data because by default the demo instance doesn't have the subregion defined.
31+
After the first sync, on subsequent runs, the diff should show no changes.
32+
At this point, `Diffsync` will be able to identify and fix all changes in Nautobot. You can try to add/update or delete any country in Nautobot and DiffSync will automatically catch it and it will fix it with running in sync mode.
33+
34+
```
35+
### DIFF Compare the data between Nautobot and the local JSON file.
36+
python main.py --diff
37+
38+
### SYNC Update the list of country in Nautobot.
39+
python main.py --sync
40+
```
41+

0 commit comments

Comments
 (0)