mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #2683: Fix exception when connecting a cable to a RearPort with no corresponding FrontPort
This commit is contained in:
parent
edd763b1aa
commit
0d3b1bfca4
@ -12,6 +12,7 @@ v2.5.1 (FUTURE)
|
|||||||
* [#2676](https://github.com/digitalocean/netbox/issues/2676) - Fix exception when passing dictionary value to a ChoiceField
|
* [#2676](https://github.com/digitalocean/netbox/issues/2676) - Fix exception when passing dictionary value to a ChoiceField
|
||||||
* [#2678](https://github.com/digitalocean/netbox/issues/2678) - Fix error when viewing webhook in admin UI without write permission
|
* [#2678](https://github.com/digitalocean/netbox/issues/2678) - Fix error when viewing webhook in admin UI without write permission
|
||||||
* [#2680](https://github.com/digitalocean/netbox/issues/2680) - Disallow POST requests to `/dcim/interface-connections/` API endpoint
|
* [#2680](https://github.com/digitalocean/netbox/issues/2680) - Disallow POST requests to `/dcim/interface-connections/` API endpoint
|
||||||
|
* [#2683](https://github.com/digitalocean/netbox/issues/2683) - Fix exception when connecting a cable to a RearPort with no corresponding FrontPort
|
||||||
* [#2684](https://github.com/digitalocean/netbox/issues/2684) - Fix custom field filtering
|
* [#2684](https://github.com/digitalocean/netbox/issues/2684) - Fix custom field filtering
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -110,11 +110,14 @@ class CableTermination(models.Model):
|
|||||||
raise Exception("Invalid position for {} ({} positions): {})".format(
|
raise Exception("Invalid position for {} ({} positions): {})".format(
|
||||||
termination, termination.positions, position
|
termination, termination.positions, position
|
||||||
))
|
))
|
||||||
peer_port = FrontPort.objects.get(
|
try:
|
||||||
rear_port=termination,
|
peer_port = FrontPort.objects.get(
|
||||||
rear_port_position=position,
|
rear_port=termination,
|
||||||
)
|
rear_port_position=position,
|
||||||
return peer_port, 1
|
)
|
||||||
|
return peer_port, 1
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
return None, None
|
||||||
|
|
||||||
# Follow a circuit to its other termination
|
# Follow a circuit to its other termination
|
||||||
elif isinstance(termination, CircuitTermination) and follow_circuits:
|
elif isinstance(termination, CircuitTermination) and follow_circuits:
|
||||||
@ -2629,5 +2632,7 @@ class Cable(ChangeLoggedModel):
|
|||||||
path_status = CONNECTION_STATUS_PLANNED
|
path_status = CONNECTION_STATUS_PLANNED
|
||||||
break
|
break
|
||||||
|
|
||||||
# (A path end, B path end, connected/planned)
|
a_endpoint = a_path[-1][2]
|
||||||
return a_path[-1][2], b_path[-1][2], path_status
|
b_endpoint = b_path[-1][2]
|
||||||
|
|
||||||
|
return a_endpoint, b_endpoint, path_status
|
||||||
|
@ -37,7 +37,7 @@ def update_connected_endpoints(instance, **kwargs):
|
|||||||
|
|
||||||
# Check if this Cable has formed a complete path. If so, update both endpoints.
|
# Check if this Cable has formed a complete path. If so, update both endpoints.
|
||||||
endpoint_a, endpoint_b, path_status = instance.get_path_endpoints()
|
endpoint_a, endpoint_b, path_status = instance.get_path_endpoints()
|
||||||
if endpoint_a is not None and endpoint_b is not None:
|
if hasattr(endpoint_a, 'connected_endpoint') and hasattr(endpoint_b, 'connected_endpoint'):
|
||||||
endpoint_a.connected_endpoint = endpoint_b
|
endpoint_a.connected_endpoint = endpoint_b
|
||||||
endpoint_a.connection_status = path_status
|
endpoint_a.connection_status = path_status
|
||||||
endpoint_a.save()
|
endpoint_a.save()
|
||||||
@ -62,7 +62,7 @@ def nullify_connected_endpoints(instance, **kwargs):
|
|||||||
instance.termination_b.save()
|
instance.termination_b.save()
|
||||||
|
|
||||||
# If this Cable was part of a complete path, tear it down
|
# If this Cable was part of a complete path, tear it down
|
||||||
if endpoint_a is not None and endpoint_b is not None:
|
if hasattr(endpoint_a, 'connected_endpoint') and hasattr(endpoint_b, 'connected_endpoint'):
|
||||||
endpoint_a.connected_endpoint = None
|
endpoint_a.connected_endpoint = None
|
||||||
endpoint_a.connection_status = None
|
endpoint_a.connection_status = None
|
||||||
endpoint_a.save()
|
endpoint_a.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user