1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes : Handle DoesNotExist exception when deleting a device with connected interfaces

This commit is contained in:
Jeremy Stretch
2018-08-22 10:35:48 -04:00
parent 66400a98f1
commit dbbf7ab664
2 changed files with 9 additions and 1 deletions

@ -8,6 +8,7 @@ v2.4.4 (FUTURE)
## Bug Fixes
* [#2353](https://github.com/digitalocean/netbox/issues/2353) - Handle `DoesNotExist` exception when deleting a device with connected interfaces
* [#2354](https://github.com/digitalocean/netbox/issues/2354) - Increased maximum MTU for interfaces to 65536 bytes
* [#2355](https://github.com/digitalocean/netbox/issues/2355) - Added item count to inventory tab on device view
* [#2368](https://github.com/digitalocean/netbox/issues/2368) - Record change in device changelog when altering cluster assignment

@ -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()