Skip to content

Do not add VID 0 to diffsync store #283

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

Merged
merged 3 commits into from
Dec 14, 2024
Merged
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
1 change: 1 addition & 0 deletions changes/283.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed adding invalid VLAN 0 to Diffsync Store causing Sync Data job to fail.
Original file line number Diff line number Diff line change
Expand Up @@ -602,26 +602,28 @@ def load_vlans(self):
model_type="vlan",
)
continue
# check for untagged vlan and add if necessary
if interface_data["untagged_vlan"]:
try:
network_vlan = self.vlan(
adapter=self,
name=interface_data["untagged_vlan"]["name"],
vid=interface_data["untagged_vlan"]["id"],
location__name=location_names.get(hostname, ""),
)
self.add(network_vlan)
except diffsync.exceptions.ObjectAlreadyExists:
continue
except Exception as err: # pylint: disable=broad-exception-caught
self._handle_general_load_exception(
error=err,
hostname=hostname,
data=device_data,
model_type="vlan",
)
continue
# check for untagged vlan and add if necessary, skip VLAN 0
if interface_data["untagged_vlan"] and interface_data["untagged_vlan"].get("id") == "0":
self.job.logger.warning("Interface with untagged vlan 0 found. Skipping untagged vlan load.")
continue
try:
network_vlan = self.vlan(
adapter=self,
name=interface_data["untagged_vlan"]["name"],
vid=interface_data["untagged_vlan"]["id"],
location__name=location_names.get(hostname, ""),
)
self.add(network_vlan)
except diffsync.exceptions.ObjectAlreadyExists:
continue
except Exception as err: # pylint: disable=broad-exception-caught
self._handle_general_load_exception(
error=err,
hostname=hostname,
data=device_data,
model_type="vlan",
)
continue

def load_vrfs(self):
"""Load vrfs into the Diffsync store."""
Expand Down Expand Up @@ -711,13 +713,17 @@ def load_untagged_vlan_to_interface(self):
# for interface in device_data["interfaces"]:
for interface_name, interface_data in device_data["interfaces"].items():
try:
if interface_data["untagged_vlan"] and interface_data["untagged_vlan"].get("id") == "0":
self.job.logger.warning("Interface with untagged vlan 0 found. Skipping untagged vlan load.")
continue
network_untagged_vlan_to_interface = self.untagged_vlan_to_interface(
adapter=self,
device__name=hostname,
name=interface_name,
untagged_vlan=interface_data["untagged_vlan"],
)
self.add(network_untagged_vlan_to_interface)

except Exception as err: # pylint: disable=broad-exception-caught
self._handle_general_load_exception(
error=err,
Expand Down