Skip to content

Commit b8a1925

Browse files
Dav-CDavid Cates
and
David Cates
authored
update vlan adapter (#372)
* update vlan adapter * add changelog fragment * ruff * add debug message --------- Co-authored-by: David Cates <david.cates@chevron.com>
1 parent 439c761 commit b8a1925

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

changes/372.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed bug when loading Nautobot Vlans with multiple locations assigned. Only Vlans with 1 location will be considered for the sync.

nautobot_device_onboarding/diffsync/adapters/sync_network_data_adapters.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ def load_vlans(self):
138138
"""
139139
# TODO: update this to support multiple locations per VLAN after the setting for this feature has been added.
140140
location_ids = list(self.job.devices_to_load.values_list("location__id", flat=True))
141-
for vlan in VLAN.objects.filter(location__in=location_ids):
141+
for vlan in VLAN.objects.filter(locations__in=location_ids):
142+
if (
143+
vlan.locations.count() > 1
144+
): # TODO: A conditional check will be needed here to support multiple locations per VLAN
145+
if self.job.debug:
146+
self.job.logger.debug(
147+
f"Vlan {vlan.name} has multiple locations. Skipping Vlan load for {vlan.name}."
148+
)
149+
continue
142150
network_vlan = self.vlan(
143151
adapter=self,
144152
name=vlan.name,

0 commit comments

Comments
 (0)