diff --git a/CHANGELOG.md b/CHANGELOG.md index f2fba454f..cb9c9ba67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index f10221b0b..b558d5007 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -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: diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 89e786a1b..8c6ed9650 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -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 diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 860a3aa44..8ee50c423 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -682,7 +682,8 @@ Rear Port Position Description - Connected Cable + Cable + Connection @@ -735,7 +736,8 @@ Type Positions Description - Connected Cable + Cable + Connection diff --git a/netbox/templates/dcim/inc/frontport.html b/netbox/templates/dcim/inc/frontport.html index 568eaa38e..3ac87e090 100644 --- a/netbox/templates/dcim/inc/frontport.html +++ b/netbox/templates/dcim/inc/frontport.html @@ -23,14 +23,20 @@ {# Description #} {{ frontport.description|placeholder }} - {# Cable #} - - {% if frontport.cable %} + {# Cable/connection #} + {% if frontport.cable %} + {{ frontport.cable }} - {% else %} + + {% with far_end=frontport.get_cable_peer %} + {{ far_end.parent }} + {{ far_end }} + {% endwith %} + {% else %} + Not connected - {% endif %} - + + {% endif %} {# Actions #} diff --git a/netbox/templates/dcim/inc/rearport.html b/netbox/templates/dcim/inc/rearport.html index 77ddbb78a..fc6b5c1df 100644 --- a/netbox/templates/dcim/inc/rearport.html +++ b/netbox/templates/dcim/inc/rearport.html @@ -22,14 +22,20 @@ {# Description #} {{ rearport.description|placeholder }} - {# Cable #} - - {% if rearport.cable %} + {# Cable/connection #} + {% if rearport.cable %} + {{ rearport.cable }} - {% else %} + + {% with far_end=rearport.get_cable_peer %} + {{ far_end.parent }} + {{ far_end }} + {% endwith %} + {% else %} + Not connected - {% endif %} - + + {% endif %} {# Actions #}