Closed steven-douilliet closed 1 month ago
This is already in the code as long as you're using site
, facility
, or location
in your Extensibility Attributes on the VLAN. You can see it being handled here. Are you saying that you aren't seeing this work as expected?
This is already in the code as long as you're using
site
,facility
, orlocation
in your Extensibility Attributes on the VLAN. You can see it being handled here. Are you saying that you aren't seeing this work as expected?
Hello, yes, I can confirm.
Set the location ID to the obj.location_id
attribute won't establish the association between the location and the VLAN due to the location field in the VLAN Model being a many-to-many field:
# It works:
location = Location.objects.get(
id=diffsync.location_map[attr_value]
)
obj.locations.add(location_obj)
# It doesn't work:
obj.location_id = diffsync.location_map[attr_value]
obj.save()
Possibly related: https://github.com/nautobot/nautobot/pull/5581 (included in 2.2.3 and later)
So the problem is you're expecting every VLAN and Location to be associated together but that wasn't supported until 2.2.3. We can't use that until we have our next big update that forces 2.2.x minimum.
I updated to version 2.2.4, and locations are now syncing correctly. Thanks!
Environment
Expected Behavior
I expected VLAN synchronization from Infoblox to Nautobot, including:
During synchronization, VLANs should be automatically updated or created with the above attributes.
Except for the VLAN ID and VLAN name, all other attributes are set using extended attributes from Infoblox.
Observed Behavior
VLANs are updated or created, and all attributes are set except for the location. Locations already exist in Nautobot but are not bound to VLANs.
Steps to Reproduce
The VLAN will be created based on Infoblox data, but its locations will not be set.
Cause
The root cause is the diffsync model of Nautobot.
Completing the location_id attribute does not associate the location with the VLAN. The VLAN model has a locations field, which is a many-to-many field, and it is here that the location must be set.
Workaround
Create a generic function to process VLAN locations:
Updated created and updated methods of the NautobotVlan class