Skip to content

Commit

Permalink
Fixes #14532: Device/VM change record should accurately reflect when …
Browse files Browse the repository at this point in the history
…primary/OOB IP is deleted
  • Loading branch information
jeremystretch committed Dec 22, 2023
1 parent c289dda commit 0d08205
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netbox/ipam/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ def clear_primary_ip(instance, **kwargs):
"""
field_name = f'primary_ip{instance.family}'
if device := Device.objects.filter(**{field_name: instance}).first():
device.snapshot()
setattr(device, field_name, None)
device.save()
if virtualmachine := VirtualMachine.objects.filter(**{field_name: instance}).first():
virtualmachine.snapshot()
setattr(virtualmachine, field_name, None)
virtualmachine.save()


Expand All @@ -67,4 +71,6 @@ def clear_oob_ip(instance, **kwargs):
When an IPAddress is deleted, trigger save() on any Devices for which it was a OOB IP.
"""
if device := Device.objects.filter(oob_ip=instance).first():
device.snapshot()
device.oob_ip = None
device.save()

0 comments on commit 0d08205

Please sign in to comment.