Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If interface-mode doesnt isnt set but there are tagged vlans - set the tagged nautobot attribute #299

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
To use this local branch:
```
git clone https://github.com/craigcpj/network-importer.git
pip install network-importer/
```
# Network Importer

The network importer is a tool/library to analyze and/or synchronize an existing network with a Network Source of Truth (SOT), it's designed to be idempotent and by default it's only showing the difference between the running network and the remote SOT.
Expand Down
7 changes: 6 additions & 1 deletion network_importer/adapters/nautobot_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def convert_vlan_list_to_nids(vlan_uids):
nb_params["mode"] = "access"
elif "switchport_mode" in attrs and attrs["switchport_mode"] == "TRUNK":
nb_params["mode"] = "tagged"
elif ("switchport_mode" in attrs and attrs["switchport_mode"] == "NONE") and attrs["mode"] == "L3_SUB_VLAN":
LOGGER.info("NB_PARAMS: %s", nb_params)
LOGGER.info("ATTRS: %s", attrs)
nb_params["mode"] = "tagged"

# if is None:
# intf_properties["enabled"] = intf.active
Expand Down Expand Up @@ -651,11 +655,12 @@ def create(cls, diffsync: "DiffSync", ids: dict, attrs: dict) -> Optional["DiffS
)
if not interface_a:
LOGGER.info(
"Unable to create Cable %s in %s, unable to find the interface %s %s",
"CABLE: Unable to create Cable %s in %s, unable to find the interface %s %s %s",
item.get_unique_id(),
diffsync.name,
ids["device_a_name"],
ids["interface_a_name"],
item,
)
return item

Expand Down
3 changes: 3 additions & 0 deletions network_importer/adapters/network_importer/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from network_importer.inventory import reachable_devs, valid_and_reachable_devs
from network_importer.tasks import check_if_reachable, warning_not_reachable
from network_importer.drivers import dispatcher
from nornir_napalm.plugins.tasks import napalm_get
from network_importer.processors.get_neighbors import GetNeighbors, hosts_for_cabling
from network_importer.processors.get_vlans import GetVlans
from network_importer.utils import (
Expand Down Expand Up @@ -404,9 +405,11 @@ def load_batfish_cable(self):
for link in p2p_links.frame().itertuples():

if link.Interface.hostname not in device_names:
LOGGER.debug("A SIDE DEVICE NOT IN: %s / %s", link.Interface.hostname, device_names)
continue

if link.Remote_Interface.hostname not in device_names:
LOGGER.debug("Z SIDE DEVICE NOT IN: %s / %s", link.Remote_Interface.hostname, device_names)
continue

cable = self.cable(
Expand Down
2 changes: 1 addition & 1 deletion network_importer/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NetworkImporterHost(Host):
site_name: Optional[str]
"""Name of the site this device belong to."""

is_reacheable: Optional[bool]
is_reachable: Optional[bool] = ""
"""Global Flag to indicate if we are able to connect to a device"""

status: Optional[str] = "ok"
Expand Down