Fixes #2353: Handle DoesNotExist exception when deleting a device with connected interfaces
This commit is contained in:
@@ -2072,6 +2072,7 @@ class InterfaceConnection(models.Model):
|
||||
(self.interface_a, self.interface_b),
|
||||
(self.interface_b, self.interface_a),
|
||||
)
|
||||
|
||||
for interface, peer_interface in interfaces:
|
||||
if action == OBJECTCHANGE_ACTION_DELETE:
|
||||
connection_data = {
|
||||
@@ -2082,11 +2083,17 @@ class InterfaceConnection(models.Model):
|
||||
'connected_interface': peer_interface.pk,
|
||||
'connection_status': self.connection_status
|
||||
}
|
||||
|
||||
try:
|
||||
parent_obj = interface.parent
|
||||
except ObjectDoesNotExist:
|
||||
parent_obj = None
|
||||
|
||||
ObjectChange(
|
||||
user=user,
|
||||
request_id=request_id,
|
||||
changed_object=interface,
|
||||
related_object=interface.parent,
|
||||
related_object=parent_obj,
|
||||
action=OBJECTCHANGE_ACTION_UPDATE,
|
||||
object_data=serialize_object(interface, extra=connection_data)
|
||||
).save()
|
||||
|
Reference in New Issue
Block a user