Skip to content

Commit ef4bbf7

Browse files
authored
Merge pull request #278 from jvanderaa/update_deps_for_new_release
Updates to py3.8 and updates deps
2 parents aa6754a + b912da8 commit ef4bbf7

File tree

13 files changed

+1445
-1324
lines changed

13 files changed

+1445
-1324
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
strategy:
109109
fail-fast: true
110110
matrix:
111-
python-version: ["3.6", "3.7", "3.8", "3.9"]
111+
python-version: ["3.8", "3.9"]
112112
runs-on: "ubuntu-20.04"
113113
env:
114114
PYTHON_VER: "${{ matrix.python-version }}"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VER="3.7"
1+
ARG PYTHON_VER="3.8"
22

33
FROM python:${PYTHON_VER}
44

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
context: "."
88
dockerfile: "Dockerfile"
99
args:
10-
PYTHON_VER: "3.7.7"
10+
PYTHON_VER: "3.8.9"
1111
stdin_open: true
1212
tty: true
1313
env_file:

network_importer.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import_ips = true
33
import_prefixes = true
44
# import_cabling = "lldp" # Valid options are ["lldp", "cdp", "config", false]
55
# import_intf_status = false # If set as False, interface status will be ignore all together
6-
# import_vlans = "config" # Valid options are ["cli", "config", true, false]
6+
#############################################################
7+
# IMPORTANT FOR VLAN IMPORT
8+
#
9+
# FOR IMPORT VLANS, PLEASE RUN CHECK MODE FIRST. If you get way too many VLANs on that, then the recommendation
10+
# is to use "cli" as the import mode rather than config.
11+
#
12+
#############################################################
13+
# import_vlans = "cli" # Valid options are ["cli", "config", true, false]
714
excluded_platforms_cabling = ["cisco_asa"]
815

916
# Directory where the configurations can be find, organized in Batfish format
@@ -20,6 +27,7 @@ backend = "nautobot" # Valid options are ["nautobot", "netbox"]
2027
# The information to connect to Nautobot needs to be provided, either in the config file or as environment variables
2128
# These settings are specific to the Nautobot inventory, please check the documentation of your inventory for the
2229
# exist list of of available settings.
30+
# For the address, include the scheme (http/https)
2331
# address = "" # Alternative Env Variable : NAUTOBOT_ADDRESS
2432
# token = "" # Alternative Env Variable : NAUTOBOT_TOKEN
2533
# verify_ssl = true # Alternative Env Variable : NAUTOBOT_VERIFY_SSL

network_importer/adapters/nautobot_api/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def load(self):
123123
nb_device = result["device"]
124124
site_name = nb_device["site"].get("slug")
125125

126-
if site_name not in sites.keys():
126+
if site_name not in sites:
127127
site = self.site(name=site_name, remote_id=nb_device["site"].get("id"))
128128
sites[site_name] = site
129129
self.add(site)

network_importer/adapters/nautobot_api/inventory.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ def __init__(
4242
if self.settings.filter is not None:
4343
build_filter_params(self.settings.filter.split((",")), self.filter_parameters)
4444

45+
if self.limit == "False": # Click sends limit in as a string, not a boolean.
46+
self.limit = False
47+
4548
if self.limit:
4649
if "=" not in self.limit:
4750
self.filter_parameters["name"] = self.limit
4851
else:
4952
build_filter_params(self.limit.split((",")), self.filter_parameters)
5053

51-
if "exclude" not in self.filter_parameters.keys():
54+
if "exclude" not in self.filter_parameters:
5255
self.filter_parameters["exclude"] = "config_context"
5356

5457
# Instantiate nautobot session using pynautobot

network_importer/adapters/netbox_api/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def load(self):
130130
nb_device = result["device"]
131131
site_name = nb_device["site"].get("slug")
132132

133-
if site_name not in sites.keys():
133+
if site_name not in sites:
134134
site = self.site(name=site_name, remote_id=nb_device["site"].get("id"))
135135
sites[site_name] = site
136136
self.add(site)

network_importer/adapters/netbox_api/inventory.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ def __init__(
4040
if self.settings.filter is not None:
4141
build_filter_params(self.settings.filter.split((",")), self.filter_parameters)
4242

43+
if self.limit == "False": # Click sends limit in as a string, not a boolean.
44+
self.limit = False
45+
4346
if self.limit:
4447
if "=" not in self.limit:
4548
self.filter_parameters["name"] = self.limit
4649
else:
4750
build_filter_params(self.limit.split((",")), self.filter_parameters)
4851

49-
if "exclude" not in self.filter_parameters.keys():
52+
if "exclude" not in self.filter_parameters:
5053
self.filter_parameters["exclude"] = "config_context"
5154

5255
# Instantiate netbox session using pynetbox

network_importer/adapters/network_importer/adapter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def load(self):
5555

5656
self.nornir.inventory.hosts[hostname].has_config = True
5757

58-
if host.site_name not in sites.keys():
58+
# Check that the host site_name is in the sites dictionary.
59+
if host.site_name not in sites:
5960
site = self.site(name=host.site_name)
6061
sites[host.site_name] = site
6162
self.add(site)

network_importer/processors/get_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def subtask_instance_started(self, task: Task, host: Host) -> None:
8888

8989
if os.path.exists(self.config_filename[host.name]):
9090
current_config = Path(self.config_filename[host.name]).read_text()
91-
self.previous_md5[host.name] = hashlib.md5(current_config.encode("utf-8")).hexdigest()
91+
# Bandit skip as the MD5 is used for hash value only, not for security.
92+
self.previous_md5[host.name] = hashlib.md5(current_config.encode("utf-8")).hexdigest() # nosec
9293

9394
def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult) -> None:
9495
"""Verify the configuration returned and store it to disk.
@@ -137,7 +138,8 @@ def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult
137138

138139
host.has_config = True
139140

140-
self.current_md5[host.name] = hashlib.md5(conf.encode("utf-8")).hexdigest()
141+
# Skipping the Bandit test as MD5 is used for hash test, not for secure encryption.
142+
self.current_md5[host.name] = hashlib.md5(conf.encode("utf-8")).hexdigest() # nosec
141143
# changed = False
142144

143145
if host.name in self.previous_md5 and self.previous_md5[host.name] == self.current_md5[host.name]:

0 commit comments

Comments
 (0)