mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 02:58:17 -06:00
Update connection status when tracing
This commit is contained in:
parent
304eccd7e2
commit
a6d8f30f74
@ -1,6 +1,9 @@
|
||||
from django.db.models.signals import post_save, pre_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
from circuits.models import CircuitTermination
|
||||
from dcim.constants import CONNECTION_STATUS_PLANNED, CONNECTION_STATUS_CONNECTED
|
||||
from dcim.models import Interface
|
||||
from .models import Cable, Device, VirtualChassis
|
||||
|
||||
|
||||
@ -90,6 +93,15 @@ def update_endpoints(endpoints, without_cable=None):
|
||||
for item in sublist if item
|
||||
][1:]
|
||||
|
||||
if not endpoints or not isinstance(endpoints[-1], (Interface, CircuitTermination)):
|
||||
# This corresponds with the old model: interfaces and circuit terminations are considered "real endpoints"
|
||||
endpoint.connection_status = None
|
||||
else:
|
||||
endpoint.connection_status = CONNECTION_STATUS_CONNECTED if all([
|
||||
cable and cable.status == CONNECTION_STATUS_CONNECTED
|
||||
for left, cable, right in path
|
||||
]) else CONNECTION_STATUS_PLANNED
|
||||
|
||||
endpoint.connected_endpoint = endpoints[-1] if endpoints else None
|
||||
endpoint.via_endpoints = endpoints[:-1]
|
||||
endpoint.save()
|
||||
|
Loading…
Reference in New Issue
Block a user