-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v2.11.5
Python version
3.7
Steps to Reproduce
- Start with NetBox v2.11.4 or earlier
- Create a VRF
- Create one or more prefixes within that VRF
- Upgrade to NetBox v2.11.5
Expected Behavior
The upgrade should complete successfully.
Observed Behavior
A ValueError exception is raised due to a bug in the way VRFs are retrieved in the migration:
ValueError: Cannot query "VRF object (1)": Must be "VRF" instance.
It seems that Django does not like using the "faked" VRF instance returned by apps.get_model() for filtering. It's being cast as a string by filter() rather than its numeric ID beign evaluated.
VRF = apps.get_model('ipam', 'VRF')
...
# Iterate through all VRFs, rebuilding each
for vrf in VRF.objects.all():
rebuild_prefixes(vrf)Altering the migration to reference the ID directly resolves the issue:
rebuild_prefixes(vrf.pk)$ ./manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization
Running migrations:
Applying ipam.0048_prefix_populate_depth_children...
Updating 3157 prefixes...
OK
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application