Merge pull request #10227 from netbox-community/10217-cable-trace-split

Fixes #10217: Handle exception when trace splits to multiple rear ports
This commit is contained in:
Jeremy Stretch 2022-08-31 10:25:41 -04:00 committed by GitHub
commit 8c35ebbb7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View File

@ -677,6 +677,12 @@ class CablePath(models.Model):
""" """
Return all available next segments in a split cable path. Return all available next segments in a split cable path.
""" """
rearports = self.path_objects[-1] nodes = self.path_objects[-1]
return FrontPort.objects.filter(rear_port__in=rearports) # RearPort splitting to multiple FrontPorts with no stack position
if type(nodes[0]) is RearPort:
return FrontPort.objects.filter(rear_port__in=nodes)
# Cable terminating to multiple FrontPorts mapped to different
# RearPorts connected to different cables
elif type(nodes[0]) is FrontPort:
return RearPort.objects.filter(pk__in=[fp.rear_port_id for fp in nodes])

View File

@ -22,16 +22,18 @@
<h3 class="text-danger">Path split!</h3> <h3 class="text-danger">Path split!</h3>
<p>Select a node below to continue:</p> <p>Select a node below to continue:</p>
<ul class="text-start"> <ul class="text-start">
{% for next_node in path.get_split_nodes %} {% for next_node in path.get_split_nodes %}
{% if next_node.cable %} {% if next_node.cable %}
<li> {% with viewname=next_node|viewname:"trace" %}
<a href="{% url 'dcim:frontport_trace' pk=next_node.pk %}">{{ next_node }}</a> <li>
(Cable {{ next_node.cable|linkify }}) <a href="{% url viewname pk=next_node.pk %}">{{ next_node|meta:"verbose_name"|bettertitle }} {{ next_node }}</a>
</li> (Cable {{ next_node.cable|linkify }})
{% else %} </li>
<li class="text-muted">{{ next_node }}</li> {% endwith %}
{% endif %} {% else %}
{% endfor %} <li class="text-muted">{{ next_node }}</li>
{% endif %}
{% endfor %}
</ul> </ul>
{% else %} {% else %}
<h3 class="text-center text-success">Trace Completed</h3> <h3 class="text-center text-success">Trace Completed</h3>