mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fix up connection lists (pending additional work)
This commit is contained in:
@ -1150,7 +1150,20 @@ class CableFilterSet(BaseFilterSet):
|
||||
return queryset
|
||||
|
||||
|
||||
class ConsoleConnectionFilterSet(BaseFilterSet):
|
||||
class ConnectionFilterSet:
|
||||
|
||||
def filter_site(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
return queryset
|
||||
return queryset.filter(device__site__slug=value)
|
||||
|
||||
def filter_device(self, queryset, name, value):
|
||||
if not value:
|
||||
return queryset
|
||||
return queryset.filter(device_id__in=value)
|
||||
|
||||
|
||||
class ConsoleConnectionFilterSet(ConnectionFilterSet, BaseFilterSet):
|
||||
site = django_filters.CharFilter(
|
||||
method='filter_site',
|
||||
label='Site (slug)',
|
||||
@ -1167,22 +1180,8 @@ class ConsoleConnectionFilterSet(BaseFilterSet):
|
||||
model = ConsolePort
|
||||
fields = ['name']
|
||||
|
||||
# TODO: Fix filters
|
||||
# def filter_site(self, queryset, name, value):
|
||||
# if not value.strip():
|
||||
# return queryset
|
||||
# return queryset.filter(connected_endpoint__device__site__slug=value)
|
||||
#
|
||||
# def filter_device(self, queryset, name, value):
|
||||
# if not value:
|
||||
# return queryset
|
||||
# return queryset.filter(
|
||||
# Q(**{'{}__in'.format(name): value}) |
|
||||
# Q(**{'connected_endpoint__{}__in'.format(name): value})
|
||||
# )
|
||||
|
||||
|
||||
class PowerConnectionFilterSet(BaseFilterSet):
|
||||
class PowerConnectionFilterSet(ConnectionFilterSet, BaseFilterSet):
|
||||
site = django_filters.CharFilter(
|
||||
method='filter_site',
|
||||
label='Site (slug)',
|
||||
@ -1199,22 +1198,8 @@ class PowerConnectionFilterSet(BaseFilterSet):
|
||||
model = PowerPort
|
||||
fields = ['name']
|
||||
|
||||
# TODO: Fix filters
|
||||
# def filter_site(self, queryset, name, value):
|
||||
# if not value.strip():
|
||||
# return queryset
|
||||
# return queryset.filter(_connected_poweroutlet__device__site__slug=value)
|
||||
#
|
||||
# def filter_device(self, queryset, name, value):
|
||||
# if not value:
|
||||
# return queryset
|
||||
# return queryset.filter(
|
||||
# Q(**{'{}__in'.format(name): value}) |
|
||||
# Q(**{'_connected_poweroutlet__{}__in'.format(name): value})
|
||||
# )
|
||||
|
||||
|
||||
class InterfaceConnectionFilterSet(BaseFilterSet):
|
||||
class InterfaceConnectionFilterSet(ConnectionFilterSet, BaseFilterSet):
|
||||
site = django_filters.CharFilter(
|
||||
method='filter_site',
|
||||
label='Site (slug)',
|
||||
@ -1231,23 +1216,6 @@ class InterfaceConnectionFilterSet(BaseFilterSet):
|
||||
model = Interface
|
||||
fields = []
|
||||
|
||||
# TODO: Fix filters
|
||||
# def filter_site(self, queryset, name, value):
|
||||
# if not value.strip():
|
||||
# return queryset
|
||||
# return queryset.filter(
|
||||
# Q(device__site__slug=value) |
|
||||
# Q(_connected_interface__device__site__slug=value)
|
||||
# )
|
||||
#
|
||||
# def filter_device(self, queryset, name, value):
|
||||
# if not value:
|
||||
# return queryset
|
||||
# return queryset.filter(
|
||||
# Q(**{'{}__in'.format(name): value}) |
|
||||
# Q(**{'_connected_interface__{}__in'.format(name): value})
|
||||
# )
|
||||
|
||||
|
||||
class PowerPanelFilterSet(BaseFilterSet):
|
||||
q = django_filters.CharFilter(
|
||||
|
@ -67,10 +67,6 @@ INTERFACE_TAGGED_VLANS = """
|
||||
{% endfor %}
|
||||
"""
|
||||
|
||||
PATH_STATUS = """
|
||||
<span class="label label-{% if value %}success{% else %}danger{% endif %}">{% if value %}Connected{% else %}Not Connected{% endif %}</span>
|
||||
"""
|
||||
|
||||
|
||||
#
|
||||
# Regions
|
||||
@ -831,17 +827,16 @@ class ConsoleConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Console Port'
|
||||
)
|
||||
path_status = tables.TemplateColumn(
|
||||
reachable = BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
template_code=PATH_STATUS,
|
||||
verbose_name='Path Status'
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
|
||||
add_prefetch = False
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ConsolePort
|
||||
fields = ('console_server', 'console_server_port', 'device', 'name', 'path_status')
|
||||
fields = ('device', 'name', 'console_server', 'console_server_port', 'reachable')
|
||||
|
||||
|
||||
class PowerConnectionTable(BaseTable):
|
||||
@ -864,17 +859,16 @@ class PowerConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Power Port'
|
||||
)
|
||||
path_status = tables.TemplateColumn(
|
||||
reachable = BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
template_code=PATH_STATUS,
|
||||
verbose_name='Path Status'
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
|
||||
add_prefetch = False
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = PowerPort
|
||||
fields = ('pdu', 'outlet', 'device', 'name', 'path_status')
|
||||
fields = ('device', 'name', 'pdu', 'outlet', 'reachable')
|
||||
|
||||
|
||||
class InterfaceConnectionTable(BaseTable):
|
||||
@ -900,17 +894,16 @@ class InterfaceConnectionTable(BaseTable):
|
||||
linkify=True,
|
||||
verbose_name='Interface B'
|
||||
)
|
||||
path_status = tables.TemplateColumn(
|
||||
reachable = BooleanColumn(
|
||||
accessor=Accessor('_path__is_active'),
|
||||
template_code=PATH_STATUS,
|
||||
verbose_name='Path Status'
|
||||
verbose_name='Reachable'
|
||||
)
|
||||
|
||||
add_prefetch = False
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Interface
|
||||
fields = ('device_a', 'interface_a', 'device_b', 'interface_b', 'path_status')
|
||||
fields = ('device_a', 'interface_a', 'device_b', 'interface_b', 'reachable')
|
||||
|
||||
|
||||
#
|
||||
|
@ -2088,7 +2088,7 @@ class ConsoleConnectionsListView(ObjectListView):
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
'Connected' if obj._path.is_active else 'Not Connected',
|
||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
@ -2115,7 +2115,7 @@ class PowerConnectionsListView(ObjectListView):
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
'Connected' if obj._path.is_active else 'Not Connected',
|
||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
@ -2148,7 +2148,7 @@ class InterfaceConnectionsListView(ObjectListView):
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
'Connected' if obj._path.is_active else 'Not Connected',
|
||||
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
|
Reference in New Issue
Block a user