mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
Improve handling of links with multi-terminations
This commit is contained in:
parent
de216aadf7
commit
359b366b27
@ -551,8 +551,12 @@ class CablePath(models.Model):
|
||||
is_complete = False
|
||||
is_split = True
|
||||
|
||||
# Step 4: Record the links
|
||||
path.append([object_to_path_node(link) for link in links])
|
||||
# Step 4: Record the links, keeping cables in order to allow for SVG rendering
|
||||
cables = []
|
||||
for link in links:
|
||||
if object_to_path_node(link) not in cables:
|
||||
cables.append(object_to_path_node(link))
|
||||
path.append(cables)
|
||||
|
||||
# Step 5: Update the path status if a link is not connected
|
||||
links_status = [link.status for link in links if link.status != LinkStatusChoices.STATUS_CONNECTED]
|
||||
@ -782,3 +786,15 @@ class CablePath(models.Model):
|
||||
return [
|
||||
ct.get_peer_termination() for ct in nodes
|
||||
]
|
||||
|
||||
def get_asymmetric_nodes(self):
|
||||
"""
|
||||
Return all available next segments in a split cable path.
|
||||
"""
|
||||
from circuits.models import CircuitTermination
|
||||
asymmetric_nodes = []
|
||||
for nodes in self.path_objects:
|
||||
if type(nodes[0]) in [RearPort, FrontPort, CircuitTermination]:
|
||||
asymmetric_nodes.extend([node for node in nodes if node.link is None])
|
||||
|
||||
return asymmetric_nodes
|
||||
|
@ -50,9 +50,7 @@ class CablePathTestCase(TestCase):
|
||||
path.append([object_to_path_node(node) for node in step])
|
||||
else:
|
||||
path.append([object_to_path_node(step)])
|
||||
|
||||
cablepath = CablePath.objects.filter(path=path, **kwargs).first()
|
||||
return cablepath
|
||||
return CablePath.objects.filter(path=path, **kwargs).first()
|
||||
|
||||
def assertPathExists(self, nodes, **kwargs):
|
||||
"""
|
||||
@ -333,7 +331,7 @@ class CablePathTestCase(TestCase):
|
||||
is_active=True
|
||||
)
|
||||
path2 = self.assertPathExists(
|
||||
((interface3, interface4), (cable1, cable1), (interface1, interface2)),
|
||||
((interface3, interface4), cable1, (interface1, interface2)),
|
||||
is_complete=True,
|
||||
is_active=True
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user