mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #14532: Device/VM change record should accurately reflect when primary/OOB IP is deleted
This commit is contained in:
@ -56,8 +56,12 @@ def clear_primary_ip(instance, **kwargs):
|
|||||||
"""
|
"""
|
||||||
field_name = f'primary_ip{instance.family}'
|
field_name = f'primary_ip{instance.family}'
|
||||||
if device := Device.objects.filter(**{field_name: instance}).first():
|
if device := Device.objects.filter(**{field_name: instance}).first():
|
||||||
|
device.snapshot()
|
||||||
|
setattr(device, field_name, None)
|
||||||
device.save()
|
device.save()
|
||||||
if virtualmachine := VirtualMachine.objects.filter(**{field_name: instance}).first():
|
if virtualmachine := VirtualMachine.objects.filter(**{field_name: instance}).first():
|
||||||
|
virtualmachine.snapshot()
|
||||||
|
setattr(virtualmachine, field_name, None)
|
||||||
virtualmachine.save()
|
virtualmachine.save()
|
||||||
|
|
||||||
|
|
||||||
@ -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.
|
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():
|
if device := Device.objects.filter(oob_ip=instance).first():
|
||||||
|
device.snapshot()
|
||||||
|
device.oob_ip = None
|
||||||
device.save()
|
device.save()
|
||||||
|
Reference in New Issue
Block a user