Skip to content

Commit 115a8b1

Browse files
authored
Merge pull request #222 from networktocode/develop-3.0
Merge 3.0 branch into develop
2 parents 5e7020e + 2add353 commit 115a8b1

File tree

100 files changed

+6221
-1020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6221
-1020
lines changed

.circleci/config.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
version: 2.1
3+
aliases:
4+
- &linting_and_unit_tests
5+
- "linting"
6+
- "test"
7+
- &linting_test
8+
- "linting"
9+
- &unit_test
10+
- "test"
11+
executors:
12+
linux:
13+
docker:
14+
- image: "circleci/python:3.7.10"
15+
orbs:
16+
# The python orb contains a set of prepackaged CircleCI configuration you can use repeatedly in your configuration
17+
# files
18+
# Orb commands and jobs help you with common scripting around a language/tool
19+
# so you dont have to copy and paste it everywhere.
20+
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python
21+
python: "circleci/python@1.2"
22+
workflows:
23+
TestFlow: # This is the name of the workflow, feel free to change it to better match your workflow.
24+
# Inside the workflow, you define the jobs you want to run.
25+
# For more details on extending your workflow, see the configuration docs:
26+
# https://circleci.com/docs/2.0/configuration-reference/#workflows
27+
jobs:
28+
- "linting"
29+
- test:
30+
requires: *linting_test
31+
- "integration_nautobot":
32+
requires: *unit_test
33+
- "integration_netbox28":
34+
requires: *unit_test
35+
- "integration_netbox29":
36+
requires: *unit_test
37+
- "integration_netbox210":
38+
requires: *unit_test
39+
40+
jobs:
41+
linting:
42+
docker:
43+
- image: "circleci/python:3.7.10" # primary container for the build job
44+
environment:
45+
INVOKE_LOCAL: "True"
46+
steps:
47+
- "checkout"
48+
# - python/install-packages:
49+
# pkg-manager: poetry
50+
- run:
51+
command: "pip install --upgrade wheel pip"
52+
name: "Upgrade Pip"
53+
- run:
54+
command: "pip install invoke poetry toml"
55+
name: "Install pip packages"
56+
- run:
57+
command: "poetry config virtualenvs.create false"
58+
name: "Poetry config virtual envs"
59+
- run:
60+
command: "poetry config installer.parallel false"
61+
name: "Poetry config parallel"
62+
- run:
63+
command: "poetry install --no-interaction --no-ansi --no-root"
64+
name: "Install application"
65+
- run:
66+
command: "invoke black"
67+
- run:
68+
command: "invoke bandit"
69+
- run:
70+
command: "invoke pydocstyle"
71+
- run:
72+
command: "invoke flake8"
73+
- run:
74+
command: "invoke yamllint"
75+
- run:
76+
command: "invoke pylint"
77+
test:
78+
machine:
79+
image: "ubuntu-2004:202104-01"
80+
steps:
81+
- "checkout"
82+
- run:
83+
name: "Change to Python 3.7 package on system"
84+
command: |
85+
pyenv versions
86+
pyenv global 3.9.4
87+
which pip
88+
pip -V
89+
- run:
90+
name: "Install python packages"
91+
command: "pip install --upgrade wheel pip toml invoke"
92+
- run:
93+
name: "Build Test Image"
94+
command: "invoke build-image --nocache"
95+
- run:
96+
name: "Run Unit Tests"
97+
command: "invoke pytest"
98+
integration_nautobot:
99+
machine:
100+
image: "ubuntu-2004:202104-01"
101+
steps:
102+
- "checkout"
103+
- run:
104+
name: "Nautobot Test"
105+
command: |
106+
pyenv versions
107+
pyenv global 3.9.4
108+
which pip
109+
pip -V
110+
pip install --upgrade pip wheel
111+
pip install invoke toml poetry pynautobot ansible==2.10.7
112+
ansible-galaxy collection install networktocode.nautobot
113+
poetry config virtualenvs.create false
114+
poetry config installer.parallel false
115+
poetry install
116+
invoke nautobot-integration-tests
117+
environment:
118+
NAUTOBOT_VERSION: "1.0.1"
119+
integration_netbox210:
120+
machine:
121+
image: "ubuntu-2004:202104-01"
122+
steps:
123+
- "checkout"
124+
- run:
125+
name: "NetBox 2.10 Test"
126+
command: |
127+
pyenv versions
128+
pyenv global 3.9.4
129+
which pip
130+
pip -V
131+
pip install invoke toml poetry pynetbox ansible==2.10.7
132+
ansible-galaxy collection install git+https://github.com/netbox-community/ansible_modules.git,v3.0.0
133+
poetry config virtualenvs.create false
134+
poetry config installer.parallel false
135+
poetry install
136+
invoke integration-tests
137+
environment:
138+
NETBOX_VERSION: "v2.10"
139+
integration_netbox29:
140+
machine:
141+
image: "ubuntu-2004:202104-01"
142+
steps:
143+
- "checkout"
144+
- run:
145+
name: "NetBox 2.9 Test"
146+
command: |
147+
pyenv versions
148+
pyenv global 3.9.4
149+
which pip
150+
pip -V
151+
pip install invoke toml poetry pynetbox ansible==2.10.7
152+
ansible-galaxy collection install git+https://github.com/netbox-community/ansible_modules.git,v3.0.0
153+
poetry config virtualenvs.create false
154+
poetry config installer.parallel false
155+
poetry install
156+
invoke integration-tests
157+
environment:
158+
NETBOX_VERSION: "v2.9"
159+
integration_netbox28:
160+
machine:
161+
image: "ubuntu-2004:202104-01"
162+
steps:
163+
- "checkout"
164+
- run:
165+
name: "NetBox 2.8 Test"
166+
command: |
167+
pyenv versions
168+
pyenv global 3.9.4
169+
which pip
170+
pip -V
171+
pip install invoke toml poetry pynetbox ansible==2.10.7
172+
ansible-galaxy collection install git+https://github.com/netbox-community/ansible_modules.git,v3.0.0
173+
poetry config virtualenvs.create false
174+
poetry config installer.parallel false
175+
poetry install
176+
invoke integration-tests
177+
environment:
178+
NETBOX_VERSION: "v2.8"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,4 @@ dmypy.json
149149
.pyre/
150150

151151
*.env
152+
.vscode

.travis.yml

Lines changed: 0 additions & 123 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2020 Network to Code <info@networktocode.com>
1+
Copyright 2021 Network to Code <opensource@networktocode.com>
22
Network to Code, LLC
33

44
Licensed under the Apache License, Version 2.0 (the "License");

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The main use cases for the network importer:
1212
- [Configuration file](docs/configuration.md)
1313
- [Supported Features and Architecture](docs/architecture.md)
1414
- [Extensibility](docs/extensibility.md)
15+
- [Upgrade procedure](docs/upgrade.md)
1516

1617
## Questions
1718

docs/architecture.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
# Architecture
33

4-
Internally the network-importer is leveraging the [diffsync](https://github.com/networktocode/diffsync) library to compare the state of the network and the state of the Source of Truth. The diffsync library is designed to compare the state of 2 **adapters** based on a shared data-models.
4+
Internally the network-importer is leveraging the [diffsync](https://github.com/networktocode/diffsync) library to compare the state of the network and the state of the Source of Truth. [The diffsync library is designed to compare the state of 2 **adapters** based on a shared data-models](https://blog.networktocode.com/post/intro-to-diffing-and-syncing-data-with-diffsync/).
55

66
To communicate to the network devices, the network importer is leveraging [Nornir](https://github.com/nornir-automation/nornir) and incorporate a concept of **drivers** to easily add support for more platforms if needed.
77
By default the Network Importer supports 3 main actions to execute against the network devices:
88
- `get_config`: Retrieve the running configuration and store it in the `config_directory` folder.
9-
- `get_neighbors`: Retrieve the list of all neighbors, eiher from LLDP or CDP (based on the configuration)
9+
- `get_neighbors`: Retrieve the list of all neighbors, either from LLDP or CDP (based on the configuration)
1010
- `get_vlans`: Retrieve the list of vlans present on the device.
1111

1212
## Internal Datamodel
@@ -22,13 +22,35 @@ The internal/shared datamodel is defined in the [network_importer/models.py](../
2222

2323
> It's possible to extend the default models and add your own, please check the [extensibility section](extensibility.md) of the documentation
2424
25-
## Adapters
25+
## Backend, Adapters & Inventory
26+
27+
To operate the Network Importer needs 1 inventory and 2 adapters:
28+
- An inventory to get the list of devices to analyze and get the minimum information to connect to them (platform, address, cred
29+
entials ..)
30+
- One adapter to read the information from the network and one to read/write information to the Source of Truth backend.
31+
32+
Since the inventory is usually leveraging the SOT, the SOT adapter and the inventory are packaged into a **backend**. Both Nautobot and Netbox are supported as backend systems. When a specific backend is selected it will update both the SOT adapter and the inventory.
33+
With or without leveraging the default backends, it's possible to provide your own adapter or extend one of the default adapters.
34+
35+
> The base adapter for Network Importer is defined in [network_importer/adapters/base.py](../network_importer/adapters/base.py). The main difference with a standard diffsync adapter is that a Network Importer adapter needs to accept a NetworkImporter inventory (based on a Nornir inventory) as parameters at init time (nornir).
2636
27-
To operate the Network Importer needs 2 adapters.
37+
### Nautobot API Adapter
2838

29-
An adapter to read the information from the network and one to read/write information to Netbox via its Rest API are provided by default but it's possible to provide your own adapter or extend either or both default adapters.
39+
The Nautobot API adapter is designed to read the status of a Nautobot server over its Rest API and update Nautobot based on the status of the network.
3040

31-
> The base adapter for Network Importer is defined in [network_importer/adapters/base.py](../network_importer/adapters/base.py). The main difference with a standard diffsync adapter is that a Network Importer adapter needs to accept a nornir inventory as parameters at init time (nornir).
41+
The table below present the capabilities in term of : Read, Create, Update and Delete supported for each model by the netbox_api adapter.
42+
43+
| Model | Inherit from | Create | Read | Update | Delete |
44+
|--------------------|--------------|--------|--------|--------|--------|
45+
| NautobotSite | Site | No | Yes | No | No |
46+
| NautobotDevice | Device | No | Yes | No | No |
47+
| NautobotInterface | Interface | Yes | Yes | Yes | Yes |
48+
| NautobotIPAddress | IPAddress | Yes | Yes | Yes | Yes |
49+
| NautobotPrefix | Prefix | Yes | Yes | Yes | No |
50+
| NautobotVlan | Vlan | Yes | Yes | Yes | No |
51+
| NautobotCable | Cable | Yes | Yes | No | No |
52+
53+
> It's possible to extend the default models and add your own, please check the [extensibility section](extensibility.md) of the documentation
3254
3355
### NetBox API Adapter
3456

@@ -54,7 +76,7 @@ The Network Importer Adapter is designed to read the status of the network prima
5476

5577
## Drivers
5678

57-
The communicate with the network devices, the network importer is leveraging Nornir and support some drivers per platform to easily support more device type.
79+
The communicate with the network devices, the network-importer is leveraging Nornir and support some drivers per platform to easily support more device type.
5880

5981
Each driver, should support each of the following actions:
6082
- `get_config`: Retrieve the running configuration and store it in the `config_directory` folder.
@@ -72,7 +94,7 @@ By default, 4 drivers are available `default`, `cisco_default`, `juniper_junos`
7294
| juniper_junos | juniper_junos |
7395
| arista_eos | arista_eos |
7496

75-
> The name of the platform must match the name of the slug platform defined in NetBox for a given device
97+
> The name of the platform must match the name of the slug platform defined in the inventory for a given device
7698
7799
### Drivers available by default
78100

0 commit comments

Comments
 (0)