Explorar el Código

Fixes #3644: Fix exception when connecting a cable to a RearPort with no corresponding FrontPort

Jeremy Stretch hace 6 años
padre
commit
f25e2a1922
Se han modificado 3 ficheros con 8 adiciones y 1 borrados
  1. 1 0
      docs/release-notes/version-2.6.md
  2. 6 0
      netbox/dcim/models.py
  3. 1 1
      netbox/dcim/signals.py

+ 1 - 0
docs/release-notes/version-2.6.md

@@ -11,6 +11,7 @@
 ## Bug Fixes
 ## Bug Fixes
 
 
 * [#3312](https://github.com/netbox-community/netbox/issues/3312) - Fix validation error when editing power cables in bulk
 * [#3312](https://github.com/netbox-community/netbox/issues/3312) - Fix validation error when editing power cables in bulk
+* [#3644](https://github.com/netbox-community/netbox/issues/3644) - Fix exception when connecting a cable to a RearPort with no corresponding FrontPort
 * [#3669](https://github.com/netbox-community/netbox/issues/3669) - Include `weight` field in prefix/VLAN role form
 * [#3669](https://github.com/netbox-community/netbox/issues/3669) - Include `weight` field in prefix/VLAN role form
 * [#3674](https://github.com/netbox-community/netbox/issues/3674) - Include comments on PowerFeed view
 * [#3674](https://github.com/netbox-community/netbox/issues/3674) - Include comments on PowerFeed view
 * [#3679](https://github.com/netbox-community/netbox/issues/3679) - Fix link for assigned ipaddress in interface page
 * [#3679](https://github.com/netbox-community/netbox/issues/3679) - Fix link for assigned ipaddress in interface page

+ 6 - 0
netbox/dcim/models.py

@@ -98,6 +98,8 @@ class CableTermination(models.Model):
         object_id_field='termination_b_id'
         object_id_field='termination_b_id'
     )
     )
 
 
+    is_path_endpoint = True
+
     class Meta:
     class Meta:
         abstract = True
         abstract = True
 
 
@@ -2444,6 +2446,8 @@ class FrontPort(CableTermination, ComponentModel):
         validators=[MinValueValidator(1), MaxValueValidator(64)]
         validators=[MinValueValidator(1), MaxValueValidator(64)]
     )
     )
 
 
+    is_path_endpoint = False
+
     objects = NaturalOrderingManager()
     objects = NaturalOrderingManager()
     tags = TaggableManager(through=TaggedItem)
     tags = TaggableManager(through=TaggedItem)
 
 
@@ -2506,6 +2510,8 @@ class RearPort(CableTermination, ComponentModel):
         validators=[MinValueValidator(1), MaxValueValidator(64)]
         validators=[MinValueValidator(1), MaxValueValidator(64)]
     )
     )
 
 
+    is_path_endpoint = False
+
     objects = NaturalOrderingManager()
     objects = NaturalOrderingManager()
     tags = TaggableManager(through=TaggedItem)
     tags = TaggableManager(through=TaggedItem)
 
 

+ 1 - 1
netbox/dcim/signals.py

@@ -45,7 +45,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 getattr(endpoint_a, 'is_path_endpoint', False) and getattr(endpoint_b, 'is_path_endpoint', False):
         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()