mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #2825: Include directly connected device for front/rear ports
This commit is contained in:
parent
ae0c8deec2
commit
59f8f0c7ea
@ -3,6 +3,7 @@ v2.5.5 (FUTURE)
|
||||
## Enhancements
|
||||
|
||||
* [#2809](https://github.com/digitalocean/netbox/issues/2809) - Remove VRF child prefixes table; link to main prefixes view
|
||||
* [#2825](https://github.com/digitalocean/netbox/issues/2825) - Include directly connected device for front/rear ports
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
|
@ -3,7 +3,7 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
from dcim.constants import CONNECTION_STATUS_CHOICES, CONNECTION_STATUS_CONNECTED, STATUS_CLASSES
|
||||
from dcim.constants import CONNECTION_STATUS_CHOICES, STATUS_CLASSES
|
||||
from dcim.fields import ASNField
|
||||
from dcim.models import CableTermination
|
||||
from extras.models import CustomFieldModel, ObjectChange
|
||||
@ -283,6 +283,10 @@ class CircuitTermination(CableTermination):
|
||||
object_data=serialize_object(self)
|
||||
).save()
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self.circuit
|
||||
|
||||
def get_peer_termination(self):
|
||||
peer_side = 'Z' if self.term_side == 'A' else 'A'
|
||||
try:
|
||||
|
@ -68,6 +68,10 @@ class ComponentModel(models.Model):
|
||||
object_data=serialize_object(self)
|
||||
).save()
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return getattr(self, 'device', None)
|
||||
|
||||
|
||||
class CableTermination(models.Model):
|
||||
cable = models.ForeignKey(
|
||||
@ -162,6 +166,14 @@ class CableTermination(models.Model):
|
||||
|
||||
return path + next_segment
|
||||
|
||||
def get_cable_peer(self):
|
||||
if self.cable is None:
|
||||
return None
|
||||
if self._cabled_as_a:
|
||||
return self.cable.termination_b
|
||||
if self._cabled_as_b:
|
||||
return self.cable.termination_a
|
||||
|
||||
|
||||
#
|
||||
# Regions
|
||||
|
@ -682,7 +682,8 @@
|
||||
<th>Rear Port</th>
|
||||
<th>Position</th>
|
||||
<th>Description</th>
|
||||
<th>Connected Cable</th>
|
||||
<th>Cable</th>
|
||||
<th colspan="2">Connection</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -735,7 +736,8 @@
|
||||
<th>Type</th>
|
||||
<th>Positions</th>
|
||||
<th>Description</th>
|
||||
<th>Connected Cable</th>
|
||||
<th>Cable</th>
|
||||
<th colspan="2">Connection</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -23,14 +23,20 @@
|
||||
{# Description #}
|
||||
<td>{{ frontport.description|placeholder }}</td>
|
||||
|
||||
{# Cable #}
|
||||
<td>
|
||||
{# Cable/connection #}
|
||||
{% if frontport.cable %}
|
||||
<td>
|
||||
<a href="{{ frontport.cable.get_absolute_url }}">{{ frontport.cable }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">Not connected</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% with far_end=frontport.get_cable_peer %}
|
||||
<td><a href="{{ far_end.parent.get_absolute_url }}">{{ far_end.parent }}</a></td>
|
||||
<td>{{ far_end }}</td>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<td colspan="3">
|
||||
<span class="text-muted">Not connected</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{# Actions #}
|
||||
<td class="text-right">
|
||||
|
@ -22,14 +22,20 @@
|
||||
{# Description #}
|
||||
<td>{{ rearport.description|placeholder }}</td>
|
||||
|
||||
{# Cable #}
|
||||
<td>
|
||||
{# Cable/connection #}
|
||||
{% if rearport.cable %}
|
||||
<td>
|
||||
<a href="{{ rearport.cable.get_absolute_url }}">{{ rearport.cable }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">Not connected</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% with far_end=rearport.get_cable_peer %}
|
||||
<td><a href="{{ far_end.parent.get_absolute_url }}">{{ far_end.parent }}</a></td>
|
||||
<td>{{ far_end }}</td>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<td colspan="3">
|
||||
<span class="text-muted">Not connected</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{# Actions #}
|
||||
<td class="text-right">
|
||||
|
Loading…
Reference in New Issue
Block a user