File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,12 @@ def clear_primary_ip(instance, **kwargs):
5656 """
5757 field_name = f'primary_ip{ instance .family } '
5858 if device := Device .objects .filter (** {field_name : instance }).first ():
59+ device .snapshot ()
60+ setattr (device , field_name , None )
5961 device .save ()
6062 if virtualmachine := VirtualMachine .objects .filter (** {field_name : instance }).first ():
63+ virtualmachine .snapshot ()
64+ setattr (virtualmachine , field_name , None )
6165 virtualmachine .save ()
6266
6367
@@ -67,4 +71,6 @@ def clear_oob_ip(instance, **kwargs):
6771 When an IPAddress is deleted, trigger save() on any Devices for which it was a OOB IP.
6872 """
6973 if device := Device .objects .filter (oob_ip = instance ).first ():
74+ device .snapshot ()
75+ device .oob_ip = None
7076 device .save ()
You can’t perform that action at this time.
0 commit comments