mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Clean up console/power/interface connections views
This commit is contained in:
parent
6b3a1998c8
commit
a6e0ef8cd8
@ -1117,7 +1117,7 @@ class DeviceLLDPNeighborsView(ObjectView):
|
|||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
|
||||||
device = get_object_or_404(self.queryset, pk=pk)
|
device = get_object_or_404(self.queryset, pk=pk)
|
||||||
interfaces = device.vc_interfaces.restrict(request.user, 'view').prefetch_related('_path').exclude(
|
interfaces = device.vc_interfaces.restrict(request.user, 'view').prefetch_related('_path__destination').exclude(
|
||||||
type__in=NONCONNECTABLE_IFACE_TYPES
|
type__in=NONCONNECTABLE_IFACE_TYPES
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2087,7 +2087,7 @@ class CableBulkDeleteView(BulkDeleteView):
|
|||||||
|
|
||||||
class ConsoleConnectionsListView(ObjectListView):
|
class ConsoleConnectionsListView(ObjectListView):
|
||||||
queryset = ConsolePort.objects.prefetch_related(
|
queryset = ConsolePort.objects.prefetch_related(
|
||||||
'device', '_path__destination__device'
|
'device', '_path__destination'
|
||||||
).filter(_path__isnull=False).order_by('device')
|
).filter(_path__isnull=False).order_by('device')
|
||||||
filterset = filters.ConsoleConnectionFilterSet
|
filterset = filters.ConsoleConnectionFilterSet
|
||||||
filterset_form = forms.ConsoleConnectionFilterForm
|
filterset_form = forms.ConsoleConnectionFilterForm
|
||||||
@ -2097,7 +2097,7 @@ class ConsoleConnectionsListView(ObjectListView):
|
|||||||
def queryset_to_csv(self):
|
def queryset_to_csv(self):
|
||||||
csv_data = [
|
csv_data = [
|
||||||
# Headers
|
# Headers
|
||||||
','.join(['console_server', 'port', 'device', 'console_port', 'connection_status'])
|
','.join(['console_server', 'port', 'device', 'console_port', 'reachable'])
|
||||||
]
|
]
|
||||||
for obj in self.queryset:
|
for obj in self.queryset:
|
||||||
csv = csv_format([
|
csv = csv_format([
|
||||||
@ -2105,7 +2105,7 @@ class ConsoleConnectionsListView(ObjectListView):
|
|||||||
obj._path.destination.name if obj._path.destination else None,
|
obj._path.destination.name if obj._path.destination else None,
|
||||||
obj.device.identifier,
|
obj.device.identifier,
|
||||||
obj.name,
|
obj.name,
|
||||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
obj._path.is_active
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
@ -2114,7 +2114,7 @@ class ConsoleConnectionsListView(ObjectListView):
|
|||||||
|
|
||||||
class PowerConnectionsListView(ObjectListView):
|
class PowerConnectionsListView(ObjectListView):
|
||||||
queryset = PowerPort.objects.prefetch_related(
|
queryset = PowerPort.objects.prefetch_related(
|
||||||
'device', '_path__destination__device'
|
'device', '_path__destination'
|
||||||
).filter(_path__isnull=False).order_by('device')
|
).filter(_path__isnull=False).order_by('device')
|
||||||
filterset = filters.PowerConnectionFilterSet
|
filterset = filters.PowerConnectionFilterSet
|
||||||
filterset_form = forms.PowerConnectionFilterForm
|
filterset_form = forms.PowerConnectionFilterForm
|
||||||
@ -2124,7 +2124,7 @@ class PowerConnectionsListView(ObjectListView):
|
|||||||
def queryset_to_csv(self):
|
def queryset_to_csv(self):
|
||||||
csv_data = [
|
csv_data = [
|
||||||
# Headers
|
# Headers
|
||||||
','.join(['pdu', 'outlet', 'device', 'power_port', 'connection_status'])
|
','.join(['pdu', 'outlet', 'device', 'power_port', 'reachable'])
|
||||||
]
|
]
|
||||||
for obj in self.queryset:
|
for obj in self.queryset:
|
||||||
csv = csv_format([
|
csv = csv_format([
|
||||||
@ -2132,7 +2132,7 @@ class PowerConnectionsListView(ObjectListView):
|
|||||||
obj._path.destination.name if obj._path.destination else None,
|
obj._path.destination.name if obj._path.destination else None,
|
||||||
obj.device.identifier,
|
obj.device.identifier,
|
||||||
obj.name,
|
obj.name,
|
||||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
obj._path.is_active
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
@ -2141,7 +2141,7 @@ class PowerConnectionsListView(ObjectListView):
|
|||||||
|
|
||||||
class InterfaceConnectionsListView(ObjectListView):
|
class InterfaceConnectionsListView(ObjectListView):
|
||||||
queryset = Interface.objects.prefetch_related(
|
queryset = Interface.objects.prefetch_related(
|
||||||
'device', '_path__destination__device'
|
'device', '_path__destination'
|
||||||
).filter(
|
).filter(
|
||||||
# Avoid duplicate connections by only selecting the lower PK in a connected pair
|
# Avoid duplicate connections by only selecting the lower PK in a connected pair
|
||||||
_path__isnull=False,
|
_path__isnull=False,
|
||||||
@ -2156,7 +2156,7 @@ class InterfaceConnectionsListView(ObjectListView):
|
|||||||
csv_data = [
|
csv_data = [
|
||||||
# Headers
|
# Headers
|
||||||
','.join([
|
','.join([
|
||||||
'device_a', 'interface_a', 'device_b', 'interface_b', 'connection_status'
|
'device_a', 'interface_a', 'device_b', 'interface_b', 'reachable'
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
for obj in self.queryset:
|
for obj in self.queryset:
|
||||||
@ -2165,7 +2165,7 @@ class InterfaceConnectionsListView(ObjectListView):
|
|||||||
obj._path.destination.name if obj._path.destination else None,
|
obj._path.destination.name if obj._path.destination else None,
|
||||||
obj.device.identifier,
|
obj.device.identifier,
|
||||||
obj.name,
|
obj.name,
|
||||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
obj._path.is_active
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user