mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Replace is_connected_endpoint
with simple isinstance
check
It was only used in a single location anyway…
This commit is contained in:
@ -300,9 +300,6 @@ class CircuitTermination(CableTermination):
|
|||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# But they are a possible connected endpoint
|
|
||||||
is_connected_endpoint = True
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['circuit', 'term_side']
|
ordering = ['circuit', 'term_side']
|
||||||
unique_together = ['circuit', 'term_side']
|
unique_together = ['circuit', 'term_side']
|
||||||
|
@ -86,9 +86,6 @@ class CableTermination(models.Model):
|
|||||||
object_id_field='termination_b_id'
|
object_id_field='termination_b_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Whether this class can be a connected endpoint
|
|
||||||
is_connected_endpoint = True
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
@ -897,9 +894,6 @@ class FrontPort(CableTermination, ComponentModel):
|
|||||||
|
|
||||||
csv_headers = ['device', 'name', 'type', 'rear_port', 'rear_port_position', 'description']
|
csv_headers = ['device', 'name', 'type', 'rear_port', 'rear_port_position', 'description']
|
||||||
|
|
||||||
# Whether this class can be a connected endpoint
|
|
||||||
is_connected_endpoint = False
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('device', '_name')
|
ordering = ('device', '_name')
|
||||||
unique_together = (
|
unique_together = (
|
||||||
@ -967,9 +961,6 @@ class RearPort(CableTermination, ComponentModel):
|
|||||||
|
|
||||||
csv_headers = ['device', 'name', 'type', 'positions', 'description']
|
csv_headers = ['device', 'name', 'type', 'positions', 'description']
|
||||||
|
|
||||||
# Whether this class can be a connected endpoint
|
|
||||||
is_connected_endpoint = False
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('device', '_name')
|
ordering = ('device', '_name')
|
||||||
unique_together = ('device', 'name')
|
unique_together = ('device', 'name')
|
||||||
|
@ -4,7 +4,7 @@ from django.db.models.signals import post_save, pre_delete
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from .choices import CableStatusChoices
|
from .choices import CableStatusChoices
|
||||||
from .models import Cable, Device, VirtualChassis
|
from .models import Cable, Device, FrontPort, RearPort, VirtualChassis
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=VirtualChassis)
|
@receiver(post_save, sender=VirtualChassis)
|
||||||
@ -63,7 +63,8 @@ def update_connected_endpoints(instance, **kwargs):
|
|||||||
endpoint_a = path[0][0]
|
endpoint_a = path[0][0]
|
||||||
endpoint_b = path[-1][2] if not split_ends and not position_stack else None
|
endpoint_b = path[-1][2] if not split_ends and not position_stack else None
|
||||||
|
|
||||||
if getattr(endpoint_a, 'is_connected_endpoint', False) and getattr(endpoint_b, 'is_connected_endpoint', False):
|
# Patch panel ports are not connected endpoints, everything else is
|
||||||
|
if not isinstance(endpoint_a, (FrontPort, RearPort)) and not isinstance(endpoint_b, (FrontPort, RearPort)):
|
||||||
logger.debug("Updating path endpoints: {} <---> {}".format(endpoint_a, endpoint_b))
|
logger.debug("Updating path endpoints: {} <---> {}".format(endpoint_a, endpoint_b))
|
||||||
endpoint_a.connected_endpoint = endpoint_b
|
endpoint_a.connected_endpoint = endpoint_b
|
||||||
endpoint_a.connection_status = path_status
|
endpoint_a.connection_status = path_status
|
||||||
|
Reference in New Issue
Block a user