@@ -295,11 +295,6 @@ def add_update_interface(self, interface_object, device_object, interface_data,
295295 if len (tagged_vlans ) > 0 :
296296 del interface_data ["tagged_vlans" ]
297297
298- # delete information about any vlans if sync is disable.
299- if disable_vlan_sync is True :
300- untagged_vlan = None
301- tagged_vlans = list ()
302-
303298 # get device tenant
304299 device_tenant = grab (device_object , "data.tenant" )
305300
@@ -312,11 +307,6 @@ def add_update_interface(self, interface_object, device_object, interface_data,
312307 else :
313308 interface_object .update (data = interface_data , source = self )
314309
315- # delete information about any vlans if sync is disable.
316- if disable_vlan_sync is True :
317- interface_object .unset_attribute ("untagged_vlan" )
318- interface_object .unset_attribute ("tagged_vlans" )
319-
320310 ip_address_objects = list ()
321311 matching_ip_prefixes = list ()
322312 # add all interface IPs
@@ -555,6 +545,11 @@ def add_update_interface(self, interface_object, device_object, interface_data,
555545 if untagged_vlan is not None or (untagged_vlan is None and len (tagged_vlans ) == 0 ):
556546 if matching_untagged_vlan is None and untagged_vlan is not None :
557547 matching_untagged_vlan = self .get_vlan_object_if_exists (untagged_vlan , site_name )
548+
549+ # don't sync newly discovered VLANs to NetBox
550+ if disable_vlan_sync is True and not isinstance (matching_untagged_vlan , NetBoxObject ):
551+ matching_untagged_vlan = None
552+
558553 elif matching_untagged_vlan is not None :
559554 log .debug2 (f"Found matching prefix VLAN { matching_untagged_vlan .get_display_name ()} for "
560555 f"untagged interface VLAN." )
@@ -575,7 +570,12 @@ def add_update_interface(self, interface_object, device_object, interface_data,
575570 else :
576571 matching_tagged_vlan = self .get_vlan_object_if_exists (tagged_vlan , site_name )
577572
578- compiled_tagged_vlans .append (matching_tagged_vlan )
573+ # don't sync newly discovered VLANs to NetBox
574+ if disable_vlan_sync is True and not isinstance (matching_tagged_vlan , NetBoxObject ):
575+ matching_tagged_vlan = None
576+
577+ if matching_tagged_vlan is not None :
578+ compiled_tagged_vlans .append (matching_tagged_vlan )
579579
580580 if len (compiled_tagged_vlans ) > 0 :
581581 vlan_interface_data ["tagged_vlans" ] = compiled_tagged_vlans
0 commit comments