mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Fix up connection lists (pending additional work)
This commit is contained in:
parent
b2066bc4b7
commit
50aecd02f4
@ -1150,7 +1150,20 @@ class CableFilterSet(BaseFilterSet):
|
|||||||
return queryset
|
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(
|
site = django_filters.CharFilter(
|
||||||
method='filter_site',
|
method='filter_site',
|
||||||
label='Site (slug)',
|
label='Site (slug)',
|
||||||
@ -1167,22 +1180,8 @@ class ConsoleConnectionFilterSet(BaseFilterSet):
|
|||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ['name']
|
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(ConnectionFilterSet, BaseFilterSet):
|
||||||
class PowerConnectionFilterSet(BaseFilterSet):
|
|
||||||
site = django_filters.CharFilter(
|
site = django_filters.CharFilter(
|
||||||
method='filter_site',
|
method='filter_site',
|
||||||
label='Site (slug)',
|
label='Site (slug)',
|
||||||
@ -1199,22 +1198,8 @@ class PowerConnectionFilterSet(BaseFilterSet):
|
|||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = ['name']
|
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(ConnectionFilterSet, BaseFilterSet):
|
||||||
class InterfaceConnectionFilterSet(BaseFilterSet):
|
|
||||||
site = django_filters.CharFilter(
|
site = django_filters.CharFilter(
|
||||||
method='filter_site',
|
method='filter_site',
|
||||||
label='Site (slug)',
|
label='Site (slug)',
|
||||||
@ -1231,23 +1216,6 @@ class InterfaceConnectionFilterSet(BaseFilterSet):
|
|||||||
model = Interface
|
model = Interface
|
||||||
fields = []
|
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):
|
class PowerPanelFilterSet(BaseFilterSet):
|
||||||
q = django_filters.CharFilter(
|
q = django_filters.CharFilter(
|
||||||
|
@ -67,10 +67,6 @@ INTERFACE_TAGGED_VLANS = """
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PATH_STATUS = """
|
|
||||||
<span class="label label-{% if value %}success{% else %}danger{% endif %}">{% if value %}Connected{% else %}Not Connected{% endif %}</span>
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Regions
|
# Regions
|
||||||
@ -831,17 +827,16 @@ class ConsoleConnectionTable(BaseTable):
|
|||||||
linkify=True,
|
linkify=True,
|
||||||
verbose_name='Console Port'
|
verbose_name='Console Port'
|
||||||
)
|
)
|
||||||
path_status = tables.TemplateColumn(
|
reachable = BooleanColumn(
|
||||||
accessor=Accessor('_path__is_active'),
|
accessor=Accessor('_path__is_active'),
|
||||||
template_code=PATH_STATUS,
|
verbose_name='Reachable'
|
||||||
verbose_name='Path Status'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_prefetch = False
|
add_prefetch = False
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ('console_server', 'console_server_port', 'device', 'name', 'path_status')
|
fields = ('device', 'name', 'console_server', 'console_server_port', 'reachable')
|
||||||
|
|
||||||
|
|
||||||
class PowerConnectionTable(BaseTable):
|
class PowerConnectionTable(BaseTable):
|
||||||
@ -864,17 +859,16 @@ class PowerConnectionTable(BaseTable):
|
|||||||
linkify=True,
|
linkify=True,
|
||||||
verbose_name='Power Port'
|
verbose_name='Power Port'
|
||||||
)
|
)
|
||||||
path_status = tables.TemplateColumn(
|
reachable = BooleanColumn(
|
||||||
accessor=Accessor('_path__is_active'),
|
accessor=Accessor('_path__is_active'),
|
||||||
template_code=PATH_STATUS,
|
verbose_name='Reachable'
|
||||||
verbose_name='Path Status'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_prefetch = False
|
add_prefetch = False
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = ('pdu', 'outlet', 'device', 'name', 'path_status')
|
fields = ('device', 'name', 'pdu', 'outlet', 'reachable')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceConnectionTable(BaseTable):
|
class InterfaceConnectionTable(BaseTable):
|
||||||
@ -900,17 +894,16 @@ class InterfaceConnectionTable(BaseTable):
|
|||||||
linkify=True,
|
linkify=True,
|
||||||
verbose_name='Interface B'
|
verbose_name='Interface B'
|
||||||
)
|
)
|
||||||
path_status = tables.TemplateColumn(
|
reachable = BooleanColumn(
|
||||||
accessor=Accessor('_path__is_active'),
|
accessor=Accessor('_path__is_active'),
|
||||||
template_code=PATH_STATUS,
|
verbose_name='Reachable'
|
||||||
verbose_name='Path Status'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_prefetch = False
|
add_prefetch = False
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = Interface
|
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._path.destination.name if obj._path.destination else None,
|
||||||
obj.device.identifier,
|
obj.device.identifier,
|
||||||
obj.name,
|
obj.name,
|
||||||
'Connected' if obj._path.is_active else 'Not Connected',
|
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
@ -2115,7 +2115,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,
|
||||||
'Connected' if obj._path.is_active else 'Not Connected',
|
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
@ -2148,7 +2148,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,
|
||||||
'Connected' if obj._path.is_active else 'Not Connected',
|
'Reachable' if obj._path.is_active else 'Not Reachable',
|
||||||
])
|
])
|
||||||
csv_data.append(csv)
|
csv_data.append(csv)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user