Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
nniehoff committed Sep 6, 2023
1 parent 6cf7638 commit c8d18c0
Show file tree
Hide file tree
Showing 28 changed files with 0 additions and 115 deletions.
1 change: 0 additions & 1 deletion network_importer/adapters/nautobot_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def load_nautobot_prefix(self, site):
prefixes = self.nautobot.ipam.prefixes.filter(site=site.name, status="active")

for nb_prefix in prefixes:

prefix = self.prefix(
prefix=nb_prefix.prefix,
site_name=site.name,
Expand Down
1 change: 0 additions & 1 deletion network_importer/adapters/netbox_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def load_netbox_prefix(self, site):
prefixes = self.netbox.ipam.prefixes.filter(site=site.name, status="active")

for nb_prefix in prefixes:

prefix = self.prefix(
prefix=nb_prefix.prefix,
site_name=site.name,
Expand Down
5 changes: 0 additions & 5 deletions network_importer/adapters/network_importer/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def load(self):

# Create all devices and site object from Nornir Inventory
for hostname, host in self.nornir.inventory.hosts.items():

if len(self.bfi.q.nodeProperties(nodes=f'"{hostname}"').answer()) == 0:
self.nornir.inventory.hosts[hostname].has_config = False
LOGGER.warning("Unable to find information for %s in Batfish, SKIPPING", hostname)
Expand Down Expand Up @@ -121,7 +120,6 @@ def load_batfish_device(self, device):
if config.SETTINGS.main.import_vlans:
bf_vlans = self.bfi.q.switchedVlanProperties(nodes=f'"{device.name}"').answer()
for bf_vlan in bf_vlans.frame().itertuples():

if config.SETTINGS.main.import_vlans in ["config", True]:
vlan, created = self.get_or_add(
self.vlan(name=f"vlan-{bf_vlan.VLAN_ID}", vid=bf_vlan.VLAN_ID, site_name=site.name)
Expand Down Expand Up @@ -402,7 +400,6 @@ def load_batfish_cable(self):
p2p_links = self.bfi.q.layer3Edges().answer()
existing_cables = []
for link in p2p_links.frame().itertuples():

if link.Interface.hostname not in device_names:
continue

Expand Down Expand Up @@ -544,9 +541,7 @@ def is_cable_side_valid(cable, side):

cables = self.get_all(self.cable)
for cable in list(cables):

for side in ["a", "z"]:

if not is_cable_side_valid(cable, side):
break

Expand Down
1 change: 0 additions & 1 deletion network_importer/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def order_children_interface(cls, children):
intfs_regs[action].append(child_name)

elif action in ["update", "create"]:

if "is_lag" in child.source_attrs and child.source_attrs["is_lag"]:
intfs_lags[action].append(child_name)
elif "is_lag_member" in child.source_attrs and child.source_attrs["is_lag_member"]:
Expand Down
1 change: 0 additions & 1 deletion network_importer/drivers/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def convert_cisco_genie_lldp_neighbors_details(device_name, data):

# intf_name = canonical_interface_name(intf_name)
for nei_intf_name in list(intf_data["port_id"].keys()):

# nei_intf_name_long = canonical_interface_name(nei_intf_name)
if is_interface_lag(nei_intf_name):
LOGGER.debug(
Expand Down
2 changes: 0 additions & 2 deletions network_importer/drivers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def get_neighbors(task: Task) -> Result: # pylint: disable=too-many-return-stat
LOGGER.debug("Executing get_neighbor for %s (%s)", task.host.name, task.host.platform)

if config.SETTINGS.main.import_cabling == "lldp":

try:
result = task.run(task=napalm_get, getters=["lldp_neighbors"])
except: # noqa: E722 # pylint: disable=bare-except
Expand All @@ -82,7 +81,6 @@ def get_neighbors(task: Task) -> Result: # pylint: disable=too-many-return-stat
return Result(host=task.host, result={"neighbors": neighbors})

if config.SETTINGS.main.import_cabling == "cdp":

try:
result = task.run(task=netmiko_send_command, command_string="show cdp neighbors detail", use_genie=True)
except NornirSubTaskError:
Expand Down
1 change: 0 additions & 1 deletion network_importer/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def print_all(self):
perflog_file_path = config.SETTINGS.logs.performance_log_directory + "/" + perflog_filename

with open(perflog_file_path, "w") as file_:

if self.nbr_devices:
file_.write(f"Report for {self.nbr_devices} devices\n")

Expand Down
1 change: 0 additions & 1 deletion network_importer/processors/get_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult

interfaces = list(result[0].result["neighbors"].keys())
for interface in interfaces:

neighbors = result[0].result["neighbors"][interface]

if len(neighbors) > 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@


def test_nautobot_get_device_tag_id():

device = NautobotDevice(
name="dev12", site_name="HQ", remote_id=32, device_tag_id="eb697742-364d-4714-b585-a267c64d7720"
)
assert device.get_device_tag_id() == "eb697742-364d-4714-b585-a267c64d7720"


def test_nautobot_get_device_tag_id_get_tag(requests_mock, nautobot_api_base):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/tag_01_list.json"))
requests_mock.get("http://mock_nautobot/api/extras/tags/?name=device%3Ddev1", json=data, status_code=200)

Expand All @@ -27,7 +25,6 @@ def test_nautobot_get_device_tag_id_get_tag(requests_mock, nautobot_api_base):


def test_get_device_tag_id_create_tag(requests_mock, nautobot_api_base, empty_nautobot_query):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/tag_01.json"))
requests_mock.get(
"http://mock_nautobot/api/extras/tags/?name=device%3Ddev1", json=empty_nautobot_query, status_code=200
Expand Down
10 changes: 0 additions & 10 deletions tests/unit/adapters/nautobot_api/models/test_nautobot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def assert_baseline(data):


def test_translate_attrs_for_nautobot_wrong_device(nautobot_api_base):

intf = NautobotInterface(device_name="HQ-CORE-SW01", name="ge-0/0/0")
nautobot_api_base.add(intf)

Expand All @@ -31,7 +30,6 @@ def test_translate_attrs_for_nautobot_wrong_device(nautobot_api_base):


def test_translate_attrs_for_nautobot_device_no_remote_id(nautobot_api_base):

nautobot_api_base.add(NautobotDevice(name="HQ-CORE-SW01", site_name="nyc"))
intf = NautobotInterface(device_name="HQ-CORE-SW01", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -41,7 +39,6 @@ def test_translate_attrs_for_nautobot_device_no_remote_id(nautobot_api_base):


def test_translate_attrs_for_nautobot_no_attrs(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans=True, backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -57,7 +54,6 @@ def test_translate_attrs_for_nautobot_no_attrs(nautobot_api_base):


def test_translate_attrs_for_nautobot_type(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans=True, backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -76,7 +72,6 @@ def test_translate_attrs_for_nautobot_type(nautobot_api_base):


def test_translate_attrs_for_nautobot_description(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans=True, backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -97,7 +92,6 @@ def test_translate_attrs_for_nautobot_description(nautobot_api_base):


def test_translate_attrs_for_nautobot_mode(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans=True, backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -120,7 +114,6 @@ def test_translate_attrs_for_nautobot_mode(nautobot_api_base):


def test_translate_attrs_for_nautobot_vlan(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="601077ce-ac88-4b36-bbc7-23d655dc3958")
nautobot_api_base.add(vlan)

Expand Down Expand Up @@ -168,7 +161,6 @@ def test_translate_attrs_for_nautobot_vlan(nautobot_api_base):


def test_translate_attrs_for_nautobot_vlan_false(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans=False, backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -189,7 +181,6 @@ def test_translate_attrs_for_nautobot_vlan_false(nautobot_api_base):


def test_translate_attrs_for_nautobot_vlan_no(nautobot_api_base):

config.load(config_data=dict(main=dict(import_vlans="no", backend="nautobot")))
intf = NautobotInterface(device_name="HQ-CORE-SW02", name="ge-0/0/0")
nautobot_api_base.add(intf)
Expand All @@ -210,7 +201,6 @@ def test_translate_attrs_for_nautobot_vlan_no(nautobot_api_base):


def test_translate_attrs_for_nautobot_lag_member(nautobot_api_base):

parent = NautobotInterface(
device_name="HQ-CORE-SW01", name="ge-0/0/4", remote_id="ea085648-5684-4362-a8dd-edfa151faaec"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def test_translate_attrs_for_nautobot_with_intf(nautobot_api_base):

ipaddr = NautobotIPAddress(
address="10.10.10.1/24",
device_name="HQ-CORE-SW02",
Expand All @@ -28,7 +27,6 @@ def test_translate_attrs_for_nautobot_with_intf(nautobot_api_base):


def test_translate_attrs_for_nautobot_wo_intf(nautobot_api_base):

ipaddr = NautobotIPAddress(
address="10.10.10.1/24",
device_name="HQ-CORE-SW02",
Expand Down Expand Up @@ -56,7 +54,6 @@ def test_create_from_pynautobot(nautobot_api_base):


def test_create_ip_address_interface(requests_mock, nautobot_api_base):

with open(f"{ROOT}/../fixtures/ip_address.json") as file:
data = yaml.safe_load(file)

Expand All @@ -72,7 +69,6 @@ def test_create_ip_address_interface(requests_mock, nautobot_api_base):


def test_create_ip_address_no_interface(requests_mock, nautobot_api_base):

with open(f"{ROOT}/../fixtures/ip_address.json") as file:
data = yaml.safe_load(file)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def test_translate_attrs_for_nautobot_default(nautobot_api_base):

prefix = NautobotPrefix(
diffsync=nautobot_api_base,
prefix="10.1.111.0/24",
Expand All @@ -23,7 +22,6 @@ def test_translate_attrs_for_nautobot_default(nautobot_api_base):


def test_translate_attrs_for_nautobot_with_vlan(nautobot_api_base):

prefix = NautobotPrefix(
diffsync=nautobot_api_base,
prefix="10.1.111.0/24",
Expand All @@ -43,7 +41,6 @@ def test_translate_attrs_for_nautobot_with_vlan(nautobot_api_base):


def test_translate_attrs_for_nautobot_with_absent_vlan(nautobot_api_base):

prefix = NautobotPrefix(
diffsync=nautobot_api_base,
prefix="10.1.111.0/24",
Expand All @@ -58,7 +55,6 @@ def test_translate_attrs_for_nautobot_with_absent_vlan(nautobot_api_base):


def test_create_prefix(requests_mock, nautobot_api_base):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/prefix_no_vlan.json"))

requests_mock.post("http://mock_nautobot/api/ipam/prefixes/", json=data, status_code=201)
Expand All @@ -72,7 +68,6 @@ def test_create_prefix(requests_mock, nautobot_api_base):


def test_update_prefix(requests_mock, nautobot_api_base):

data_no_vlan = yaml.safe_load(open(f"{ROOT}/../fixtures/prefix_no_vlan.json"))
data_vlan = yaml.safe_load(open(f"{ROOT}/../fixtures/prefix_vlan.json"))

Expand All @@ -87,7 +82,6 @@ def test_update_prefix(requests_mock, nautobot_api_base):


def test_create_prefix_with_vlan(requests_mock, nautobot_api_base):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/prefix_vlan.json"))

requests_mock.post("http://mock_nautobot/api/ipam/prefixes/", json=data, status_code=201)
Expand All @@ -101,7 +95,6 @@ def test_create_prefix_with_vlan(requests_mock, nautobot_api_base):


def test_translate_attrs_for_nautobot_w_vlan(nautobot_api_base):

prefix = NautobotPrefix(
diffsync=nautobot_api_base,
prefix="10.1.111.0/24",
Expand All @@ -118,7 +111,6 @@ def test_translate_attrs_for_nautobot_w_vlan(nautobot_api_base):


def test_translate_attrs_for_nautobot_wo_vlan(nautobot_api_base):

prefix = NautobotPrefix(
diffsync=nautobot_api_base,
prefix="10.1.111.0/24",
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/adapters/nautobot_api/models/test_nautobot_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def test_vlan_create_from_pynautobot(nautobot_api_base):


def test_vlan_create_from_pynautobot_with_tags(nautobot_api_base):

api = pynautobot.api(url="http://mock_nautobot", token="1234567890")

data = yaml.safe_load(open(f"{ROOT}/../fixtures/vlan_101_tags_01.json"))
Expand Down Expand Up @@ -52,7 +51,6 @@ def test_vlan_create_from_pynautobot_with_tags(nautobot_api_base):


def test_translate_attrs_for_nautobot_no_attrs(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="eb697742-364d-4714-b585-a267c64d7720")
nautobot_api_base.add(vlan)

Expand All @@ -66,7 +64,6 @@ def test_translate_attrs_for_nautobot_no_attrs(nautobot_api_base):


def test_translate_attrs_for_nautobot_with_partial_attrs(nautobot_api_base):

vlan = NautobotVlan(vid=100, name="MYVLAN", site_name="HQ", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand Down Expand Up @@ -96,7 +93,6 @@ def test_translate_attrs_for_nautobot_with_partial_attrs(nautobot_api_base):


def test_translate_attrs_for_nautobot_with_attrs(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand Down Expand Up @@ -127,7 +123,6 @@ def test_translate_attrs_for_nautobot_with_attrs(nautobot_api_base):


def test_translate_attrs_for_nautobot_with_missing_devices(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand All @@ -150,7 +145,6 @@ def test_translate_attrs_for_nautobot_with_missing_devices(nautobot_api_base):


def test_translate_attrs_for_nautobot_missing_site(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="NOTPRESENT", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand All @@ -160,7 +154,6 @@ def test_translate_attrs_for_nautobot_missing_site(nautobot_api_base):


def test_update_clean_tags_no_incoming_tags(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand All @@ -176,7 +169,6 @@ def test_update_clean_tags_no_incoming_tags(nautobot_api_base):


def test_update_clean_tags_with_incoming_tags(nautobot_api_base):

vlan = NautobotVlan(vid=100, site_name="HQ", remote_id="464a2de3-fd5e-4b65-a58d-e0a2a617c12e")
nautobot_api_base.add(vlan)

Expand Down
3 changes: 0 additions & 3 deletions tests/unit/adapters/netbox_api/models/test_netbox_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@


def test_get_device_tag_id(netbox_api_base):

device = NetboxDevice(name="dev1", site_name="HQ", remote_id=32, device_tag_id=12)
netbox_api_base.add(device)
assert device.get_device_tag_id() == 12


def test_get_device_tag_id_get_tag(requests_mock, netbox_api_base):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/netbox_29/tag_01_list.json"))
requests_mock.get("http://mock/api/extras/tags/?name=device%3Ddev1", json=data, status_code=200)

Expand All @@ -26,7 +24,6 @@ def test_get_device_tag_id_get_tag(requests_mock, netbox_api_base):


def test_get_device_tag_id_create_tag(requests_mock, netbox_api_base, empty_netbox_query):

data = yaml.safe_load(open(f"{ROOT}/../fixtures/netbox_29/tag_01.json"))
requests_mock.get("http://mock/api/extras/tags/?name=device%3Ddev1", json=empty_netbox_query, status_code=200)
requests_mock.post("http://mock/api/extras/tags/", json=data, status_code=201)
Expand Down
Loading

0 comments on commit c8d18c0

Please sign in to comment.