Interface snapshot won't allow changes to be made on the object #5412

Closed
opened 2025-12-29 19:27:40 +01:00 by adam · 6 comments
Owner

Originally created by @zshorvat on GitHub (Sep 23, 2021).

NetBox version

v2.11.12

Python version

3.7

Steps to Reproduce

When using custom scripts:

  1. Request details of new LAG, including member-interfaces in the form via MultiObjectVar
  2. Create LAG, save the new object
  3. Loop through desired the member-interfaces,
  • take snapshot of member-interface object
  • set LAG, tagged/untagged VLANs on the member-interface from the new LAG object
  • save member-interface

Expected Behavior

All attempted changes should be applied, pre-change and post-change view in the change-log should reflect what was updated on the object.

Observed Behavior

Changes don't seem to take effect, only the last_updated value is changed but all the other attributes stay intact, pre and post change values are the same.

Once I remove the snapshot, the changes are correctly applied.

Originally created by @zshorvat on GitHub (Sep 23, 2021). ### NetBox version v2.11.12 ### Python version 3.7 ### Steps to Reproduce When using custom scripts: 1. Request details of new LAG, including member-interfaces in the form via MultiObjectVar 2. Create LAG, save the new object 3. Loop through desired the member-interfaces, - take snapshot of member-interface object - set LAG, tagged/untagged VLANs on the member-interface from the new LAG object - save member-interface ### Expected Behavior All attempted changes should be applied, pre-change and post-change view in the change-log should reflect what was updated on the object. ### Observed Behavior Changes don't seem to take effect, only the last_updated value is changed but all the other attributes stay intact, pre and post change values are the same. Once I remove the snapshot, the changes are correctly applied.
adam added the type: bug label 2025-12-29 19:27:40 +01:00
adam closed this issue 2025-12-29 19:27:40 +01:00
Author
Owner

@DanSheps commented on GitHub (Sep 23, 2021):

What do you mean by snapshot?

@DanSheps commented on GitHub (Sep 23, 2021): What do you mean by snapshot?
Author
Owner

@zshorvat commented on GitHub (Sep 23, 2021):

Saving the pre-change status of the object, like in the snippet below:

for memberintf in data['interfaces']:
            memberintf.snapshot()

            memberintf.lag=vpc
            memberintf.mode=vpc.mode
            if vpc.untagged_vlan:
                memberintf.untagged_vlan = vpc.untagged_vlan
            else:
                memberintf.untagged_vlan = None

            memberintf.custom_field_data = vpc.custom_field_data

            for trunkedvlan in vpc.tagged_vlans.all():
                memberintf.tagged_vlans.add(trunkedvlan)

            memberintf.save()

@zshorvat commented on GitHub (Sep 23, 2021): Saving the pre-change status of the object, like in the snippet below: ``` for memberintf in data['interfaces']: memberintf.snapshot() memberintf.lag=vpc memberintf.mode=vpc.mode if vpc.untagged_vlan: memberintf.untagged_vlan = vpc.untagged_vlan else: memberintf.untagged_vlan = None memberintf.custom_field_data = vpc.custom_field_data for trunkedvlan in vpc.tagged_vlans.all(): memberintf.tagged_vlans.add(trunkedvlan) memberintf.save() ```
Author
Owner

@DanSheps commented on GitHub (Sep 24, 2021):

Are you on 2.11.12?

If so, caching was removed in 3.0.0 and that is likely the issue as you are not invalidating the cache. We saw a lot of issues with cache invalidation.

@DanSheps commented on GitHub (Sep 24, 2021): Are you on 2.11.12? If so, caching was removed in 3.0.0 and that is likely the issue as you are not invalidating the cache. We saw a lot of issues with cache invalidation.
Author
Owner

@zshorvat commented on GitHub (Sep 24, 2021):

Yes, I'm on 2.11.12. Is there a way to disable caching there?

BTW, I have re-arranged my code a little, figured I was saving one of the interface objects in one too many places and now change-log shows the info I wanted.

@zshorvat commented on GitHub (Sep 24, 2021): Yes, I'm on 2.11.12. Is there a way to disable caching there? BTW, I have re-arranged my code a little, figured I was saving one of the interface objects in one too many places and now change-log shows the info I wanted.
Author
Owner

@DanSheps commented on GitHub (Sep 25, 2021):

CACHE_TIMEOUT=0 I believe

@DanSheps commented on GitHub (Sep 25, 2021): CACHE_TIMEOUT=0 I believe
Author
Owner

@jeremystretch commented on GitHub (Sep 26, 2021):

Closing this out as v2.11.12 is no longer being worked on. Please upgrade to v3.0.3 or later.

@jeremystretch commented on GitHub (Sep 26, 2021): Closing this out as v2.11.12 is no longer being worked on. Please upgrade to v3.0.3 or later.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5412