Skip to content

Commit

Permalink
Merge pull request #278 from jvanderaa/update_deps_for_new_release
Browse files Browse the repository at this point in the history
Updates to py3.8 and updates deps
  • Loading branch information
jvanderaa authored Aug 26, 2022
2 parents aa6754a + b912da8 commit ef4bbf7
Show file tree
Hide file tree
Showing 13 changed files with 1,445 additions and 1,324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
python-version: ["3.8", "3.9"]
runs-on: "ubuntu-20.04"
env:
PYTHON_VER: "${{ matrix.python-version }}"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VER="3.7"
ARG PYTHON_VER="3.8"

FROM python:${PYTHON_VER}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: "."
dockerfile: "Dockerfile"
args:
PYTHON_VER: "3.7.7"
PYTHON_VER: "3.8.9"
stdin_open: true
tty: true
env_file:
Expand Down
10 changes: 9 additions & 1 deletion network_importer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import_ips = true
import_prefixes = true
# import_cabling = "lldp" # Valid options are ["lldp", "cdp", "config", false]
# import_intf_status = false # If set as False, interface status will be ignore all together
# import_vlans = "config" # Valid options are ["cli", "config", true, false]
#############################################################
# IMPORTANT FOR VLAN IMPORT
#
# FOR IMPORT VLANS, PLEASE RUN CHECK MODE FIRST. If you get way too many VLANs on that, then the recommendation
# is to use "cli" as the import mode rather than config.
#
#############################################################
# import_vlans = "cli" # Valid options are ["cli", "config", true, false]
excluded_platforms_cabling = ["cisco_asa"]

# Directory where the configurations can be find, organized in Batfish format
Expand All @@ -20,6 +27,7 @@ backend = "nautobot" # Valid options are ["nautobot", "netbox"]
# The information to connect to Nautobot needs to be provided, either in the config file or as environment variables
# These settings are specific to the Nautobot inventory, please check the documentation of your inventory for the
# exist list of of available settings.
# For the address, include the scheme (http/https)
# address = "" # Alternative Env Variable : NAUTOBOT_ADDRESS
# token = "" # Alternative Env Variable : NAUTOBOT_TOKEN
# verify_ssl = true # Alternative Env Variable : NAUTOBOT_VERIFY_SSL
Expand Down
2 changes: 1 addition & 1 deletion network_importer/adapters/nautobot_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def load(self):
nb_device = result["device"]
site_name = nb_device["site"].get("slug")

if site_name not in sites.keys():
if site_name not in sites:
site = self.site(name=site_name, remote_id=nb_device["site"].get("id"))
sites[site_name] = site
self.add(site)
Expand Down
5 changes: 4 additions & 1 deletion network_importer/adapters/nautobot_api/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ def __init__(
if self.settings.filter is not None:
build_filter_params(self.settings.filter.split((",")), self.filter_parameters)

if self.limit == "False": # Click sends limit in as a string, not a boolean.
self.limit = False

if self.limit:
if "=" not in self.limit:
self.filter_parameters["name"] = self.limit
else:
build_filter_params(self.limit.split((",")), self.filter_parameters)

if "exclude" not in self.filter_parameters.keys():
if "exclude" not in self.filter_parameters:
self.filter_parameters["exclude"] = "config_context"

# Instantiate nautobot session using pynautobot
Expand Down
2 changes: 1 addition & 1 deletion network_importer/adapters/netbox_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def load(self):
nb_device = result["device"]
site_name = nb_device["site"].get("slug")

if site_name not in sites.keys():
if site_name not in sites:
site = self.site(name=site_name, remote_id=nb_device["site"].get("id"))
sites[site_name] = site
self.add(site)
Expand Down
5 changes: 4 additions & 1 deletion network_importer/adapters/netbox_api/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ def __init__(
if self.settings.filter is not None:
build_filter_params(self.settings.filter.split((",")), self.filter_parameters)

if self.limit == "False": # Click sends limit in as a string, not a boolean.
self.limit = False

if self.limit:
if "=" not in self.limit:
self.filter_parameters["name"] = self.limit
else:
build_filter_params(self.limit.split((",")), self.filter_parameters)

if "exclude" not in self.filter_parameters.keys():
if "exclude" not in self.filter_parameters:
self.filter_parameters["exclude"] = "config_context"

# Instantiate netbox session using pynetbox
Expand Down
3 changes: 2 additions & 1 deletion network_importer/adapters/network_importer/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def load(self):

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

if host.site_name not in sites.keys():
# Check that the host site_name is in the sites dictionary.
if host.site_name not in sites:
site = self.site(name=host.site_name)
sites[host.site_name] = site
self.add(site)
Expand Down
6 changes: 4 additions & 2 deletions network_importer/processors/get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def subtask_instance_started(self, task: Task, host: Host) -> None:

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

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

host.has_config = True

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

if host.name in self.previous_md5 and self.previous_md5[host.name] == self.current_md5[host.name]:
Expand Down
Loading

0 comments on commit ef4bbf7

Please sign in to comment.