Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook prechange snapshot missing when primary IP assigned or unassigned #12617

Closed
AesoSpadez opened this issue May 15, 2023 · 3 comments · Fixed by #12990
Closed

Webhook prechange snapshot missing when primary IP assigned or unassigned #12617

AesoSpadez opened this issue May 15, 2023 · 3 comments · Fixed by #12990
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@AesoSpadez
Copy link

NetBox version

v3.5.1

Python version

3.10

Steps to Reproduce

  1. Create a webhook - Content type DCIM > Device, events Updates, any URL, and the rest blank/defaults.
  2. Create a device (and all the prerequisite objects: Site, Role, Manufacturer, Type) - All defaults
  3. If no interfaces on the device type, add one.
  4. From the interfaces view of the device, add an IP address to the new interface - Check the 'Make this the primary' box.
  5. Go to the admin portal, find the webhook in the finished or failed jobs lists of the default queue.

Expected Behavior

The value of the prechange key of snapshots should have the prechange object data.

Observed Behavior

The value of the prechange key of snapshots is None.

@AesoSpadez AesoSpadez added the type: bug A confirmed report of unexpected behavior in the application label May 15, 2023
@kkthxbye-code kkthxbye-code added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label May 16, 2023
@kkthxbye-code
Copy link
Contributor

I'm pretty sure parent.snapshot() should just be added after L360 here:

def save(self, *args, **kwargs):
ipaddress = super().save(*args, **kwargs)
# Assign/clear this IPAddress as the primary for the associated Device/VirtualMachine.
interface = self.instance.assigned_object
if type(interface) in (Interface, VMInterface):
parent = interface.parent_object
if self.cleaned_data['primary_for_parent']:
if ipaddress.address.version == 4:
parent.primary_ip4 = ipaddress
else:
parent.primary_ip6 = ipaddress
parent.save()
elif ipaddress.address.version == 4 and parent.primary_ip4 == ipaddress:
parent.primary_ip4 = None
parent.save()
elif ipaddress.address.version == 6 and parent.primary_ip6 == ipaddress:
parent.primary_ip6 = None
parent.save()
return ipaddress

Open for contributors, otherwise I'll take it when I get the time.

@AesoSpadez
Copy link
Author

I've been meaning to get started contributing anyways and this seems about as straight-forward a change as one could hope for. I can take a shot at a PR if you want to assign the issue to me.

@arthanson arthanson added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels May 16, 2023
@arthanson
Copy link
Collaborator

Sounds good @AesoSpadez assigning it to you.

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: accepted This issue has been accepted for implementation labels Jun 23, 2023
@abhi1693 abhi1693 self-assigned this Jun 23, 2023
@abhi1693 abhi1693 added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jun 23, 2023
abhi1693 added a commit that referenced this issue Jun 23, 2023
jeremystretch pushed a commit that referenced this issue Jul 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants