|
|
@@ -18,7 +18,7 @@ from tenancy.models import *
|
|
|
from utilities.choices import ColorChoices
|
|
|
from utilities.filters import (
|
|
|
ContentTypeFilter, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter, MultiValueWWNFilter,
|
|
|
- TreeNodeMultipleChoiceFilter,
|
|
|
+ NumericArrayFilter, TreeNodeMultipleChoiceFilter,
|
|
|
)
|
|
|
from virtualization.models import Cluster
|
|
|
from vpn.models import L2VPN
|
|
|
@@ -178,12 +178,11 @@ class SiteFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSe
|
|
|
queryset=ASN.objects.all(),
|
|
|
label=_('AS (ID)'),
|
|
|
)
|
|
|
+ time_zone = MultiValueCharFilter()
|
|
|
|
|
|
class Meta:
|
|
|
model = Site
|
|
|
- fields = (
|
|
|
- 'id', 'name', 'slug', 'facility', 'latitude', 'longitude', 'description'
|
|
|
- )
|
|
|
+ fields = ('id', 'name', 'slug', 'facility', 'latitude', 'longitude', 'description')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -447,10 +446,14 @@ class RackReservationFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
|
|
to_field_name='username',
|
|
|
label=_('User (name)'),
|
|
|
)
|
|
|
+ unit = NumericArrayFilter(
|
|
|
+ field_name='units',
|
|
|
+ lookup_expr='contains'
|
|
|
+ )
|
|
|
|
|
|
class Meta:
|
|
|
model = RackReservation
|
|
|
- fields = ['id', 'created', 'description']
|
|
|
+ fields = ('id', 'created', 'description')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -538,10 +541,22 @@ class DeviceTypeFilterSet(NetBoxModelFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = DeviceType
|
|
|
- fields = [
|
|
|
+ fields = (
|
|
|
'id', 'model', 'slug', 'part_number', 'u_height', 'exclude_from_utilization', 'is_full_depth',
|
|
|
'subdevice_role', 'airflow', 'weight', 'weight_unit', 'description',
|
|
|
- ]
|
|
|
+
|
|
|
+ # Counters
|
|
|
+ 'console_port_template_count',
|
|
|
+ 'console_server_port_template_count',
|
|
|
+ 'power_port_template_count',
|
|
|
+ 'power_outlet_template_count',
|
|
|
+ 'interface_template_count',
|
|
|
+ 'front_port_template_count',
|
|
|
+ 'rear_port_template_count',
|
|
|
+ 'device_bay_template_count',
|
|
|
+ 'module_bay_template_count',
|
|
|
+ 'inventory_item_template_count',
|
|
|
+ )
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -675,12 +690,15 @@ class DeviceTypeComponentFilterSet(django_filters.FilterSet):
|
|
|
method='search',
|
|
|
label=_('Search'),
|
|
|
)
|
|
|
- devicetype_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ device_type_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
queryset=DeviceType.objects.all(),
|
|
|
field_name='device_type_id',
|
|
|
label=_('Device type (ID)'),
|
|
|
)
|
|
|
|
|
|
+ # TODO: Remove in v4.1
|
|
|
+ devicetype_id = device_type_id
|
|
|
+
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
return queryset
|
|
|
@@ -691,32 +709,35 @@ class DeviceTypeComponentFilterSet(django_filters.FilterSet):
|
|
|
|
|
|
|
|
|
class ModularDeviceTypeComponentFilterSet(DeviceTypeComponentFilterSet):
|
|
|
- moduletype_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ module_type_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
queryset=ModuleType.objects.all(),
|
|
|
field_name='module_type_id',
|
|
|
label=_('Module type (ID)'),
|
|
|
)
|
|
|
|
|
|
+ # TODO: Remove in v4.1
|
|
|
+ moduletype_id = module_type_id
|
|
|
+
|
|
|
|
|
|
class ConsolePortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = ConsolePortTemplate
|
|
|
- fields = ['id', 'name', 'type', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'description')
|
|
|
|
|
|
|
|
|
class ConsoleServerPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = ConsoleServerPortTemplate
|
|
|
- fields = ['id', 'name', 'type', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'description')
|
|
|
|
|
|
|
|
|
class PowerPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerPortTemplate
|
|
|
- fields = ['id', 'name', 'type', 'maximum_draw', 'allocated_draw', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description')
|
|
|
|
|
|
|
|
|
class PowerOutletTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
@@ -724,10 +745,14 @@ class PowerOutletTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceType
|
|
|
choices=PowerOutletFeedLegChoices,
|
|
|
null_value=None
|
|
|
)
|
|
|
+ power_port_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ queryset=PowerPortTemplate.objects.all(),
|
|
|
+ label=_('Power port (ID)'),
|
|
|
+ )
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerOutletTemplate
|
|
|
- fields = ['id', 'name', 'type', 'feed_leg', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'feed_leg', 'description')
|
|
|
|
|
|
|
|
|
class InterfaceTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
@@ -751,7 +776,7 @@ class InterfaceTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeCo
|
|
|
|
|
|
class Meta:
|
|
|
model = InterfaceTemplate
|
|
|
- fields = ['id', 'name', 'type', 'enabled', 'mgmt_only', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'enabled', 'mgmt_only', 'description')
|
|
|
|
|
|
|
|
|
class FrontPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
@@ -762,7 +787,7 @@ class FrontPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeCo
|
|
|
|
|
|
class Meta:
|
|
|
model = FrontPortTemplate
|
|
|
- fields = ['id', 'name', 'type', 'color', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'color', 'rear_port_id', 'rear_port_position', 'description')
|
|
|
|
|
|
|
|
|
class RearPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeComponentFilterSet):
|
|
|
@@ -773,21 +798,21 @@ class RearPortTemplateFilterSet(ChangeLoggedModelFilterSet, ModularDeviceTypeCom
|
|
|
|
|
|
class Meta:
|
|
|
model = RearPortTemplate
|
|
|
- fields = ['id', 'name', 'type', 'color', 'positions', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'type', 'color', 'positions', 'description')
|
|
|
|
|
|
|
|
|
class ModuleBayTemplateFilterSet(ChangeLoggedModelFilterSet, DeviceTypeComponentFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = ModuleBayTemplate
|
|
|
- fields = ['id', 'name', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'position', 'description')
|
|
|
|
|
|
|
|
|
class DeviceBayTemplateFilterSet(ChangeLoggedModelFilterSet, DeviceTypeComponentFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = DeviceBayTemplate
|
|
|
- fields = ['id', 'name', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'description')
|
|
|
|
|
|
|
|
|
class InventoryItemTemplateFilterSet(ChangeLoggedModelFilterSet, DeviceTypeComponentFilterSet):
|
|
|
@@ -1068,10 +1093,22 @@ class DeviceFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = Device
|
|
|
- fields = [
|
|
|
+ fields = (
|
|
|
'id', 'asset_tag', 'face', 'position', 'latitude', 'longitude', 'airflow', 'vc_position', 'vc_priority',
|
|
|
'description',
|
|
|
- ]
|
|
|
+
|
|
|
+ # Counters
|
|
|
+ 'console_port_count',
|
|
|
+ 'console_server_port_count',
|
|
|
+ 'power_port_count',
|
|
|
+ 'power_outlet_count',
|
|
|
+ 'interface_count',
|
|
|
+ 'front_port_count',
|
|
|
+ 'rear_port_count',
|
|
|
+ 'device_bay_count',
|
|
|
+ 'module_bay_count',
|
|
|
+ 'inventory_item_count',
|
|
|
+ )
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -1151,7 +1188,7 @@ class VirtualDeviceContextFilterSet(NetBoxModelFilterSet, TenancyFilterSet, Prim
|
|
|
|
|
|
class Meta:
|
|
|
model = VirtualDeviceContext
|
|
|
- fields = ['id', 'device', 'name', 'description']
|
|
|
+ fields = ('id', 'device', 'name', 'identifier', 'description')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -1217,7 +1254,7 @@ class ModuleFilterSet(NetBoxModelFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = Module
|
|
|
- fields = ['id', 'status', 'asset_tag', 'description']
|
|
|
+ fields = ('id', 'status', 'asset_tag', 'description')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -1361,6 +1398,10 @@ class ModularDeviceComponentFilterSet(DeviceComponentFilterSet):
|
|
|
|
|
|
|
|
|
class CabledObjectFilterSet(django_filters.FilterSet):
|
|
|
+ cable_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ queryset=Cable.objects.all(),
|
|
|
+ label=_('Cable (ID)'),
|
|
|
+ )
|
|
|
cabled = django_filters.BooleanFilter(
|
|
|
field_name='cable',
|
|
|
lookup_expr='isnull',
|
|
|
@@ -1402,7 +1443,7 @@ class ConsolePortFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = ConsolePort
|
|
|
- fields = ['id', 'name', 'label', 'description', 'cable_end']
|
|
|
+ fields = ('id', 'name', 'label', 'speed', 'description', 'mark_connected', 'cable_end')
|
|
|
|
|
|
|
|
|
class ConsoleServerPortFilterSet(
|
|
|
@@ -1418,7 +1459,7 @@ class ConsoleServerPortFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = ConsoleServerPort
|
|
|
- fields = ['id', 'name', 'label', 'description', 'cable_end']
|
|
|
+ fields = ('id', 'name', 'label', 'speed', 'description', 'mark_connected', 'cable_end')
|
|
|
|
|
|
|
|
|
class PowerPortFilterSet(
|
|
|
@@ -1434,7 +1475,9 @@ class PowerPortFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerPort
|
|
|
- fields = ['id', 'name', 'label', 'maximum_draw', 'allocated_draw', 'description', 'cable_end']
|
|
|
+ fields = (
|
|
|
+ 'id', 'name', 'label', 'maximum_draw', 'allocated_draw', 'description', 'mark_connected', 'cable_end',
|
|
|
+ )
|
|
|
|
|
|
|
|
|
class PowerOutletFilterSet(
|
|
|
@@ -1451,10 +1494,16 @@ class PowerOutletFilterSet(
|
|
|
choices=PowerOutletFeedLegChoices,
|
|
|
null_value=None
|
|
|
)
|
|
|
+ power_port_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ queryset=PowerPort.objects.all(),
|
|
|
+ label=_('Power port (ID)'),
|
|
|
+ )
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerOutlet
|
|
|
- fields = ['id', 'name', 'label', 'feed_leg', 'description', 'cable_end']
|
|
|
+ fields = (
|
|
|
+ 'id', 'name', 'label', 'feed_leg', 'description', 'mark_connected', 'cable_end',
|
|
|
+ )
|
|
|
|
|
|
|
|
|
class CommonInterfaceFilterSet(django_filters.FilterSet):
|
|
|
@@ -1586,10 +1635,11 @@ class InterfaceFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = Interface
|
|
|
- fields = [
|
|
|
+ fields = (
|
|
|
'id', 'name', 'label', 'type', 'enabled', 'mtu', 'mgmt_only', 'poe_mode', 'poe_type', 'mode', 'rf_role',
|
|
|
- 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'cable_end',
|
|
|
- ]
|
|
|
+ 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected',
|
|
|
+ 'cable_id', 'cable_end', 'wireless_link_id',
|
|
|
+ )
|
|
|
|
|
|
def filter_virtual_chassis_member(self, queryset, name, value):
|
|
|
try:
|
|
|
@@ -1621,7 +1671,10 @@ class FrontPortFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = FrontPort
|
|
|
- fields = ['id', 'name', 'label', 'type', 'color', 'description', 'cable_end']
|
|
|
+ fields = (
|
|
|
+ 'id', 'name', 'label', 'type', 'color', 'rear_port_id', 'rear_port_position', 'description',
|
|
|
+ 'mark_connected', 'cable_end',
|
|
|
+ )
|
|
|
|
|
|
|
|
|
class RearPortFilterSet(
|
|
|
@@ -1636,21 +1689,33 @@ class RearPortFilterSet(
|
|
|
|
|
|
class Meta:
|
|
|
model = RearPort
|
|
|
- fields = ['id', 'name', 'label', 'type', 'color', 'positions', 'description', 'cable_end']
|
|
|
+ fields = (
|
|
|
+ 'id', 'name', 'label', 'type', 'color', 'positions', 'description', 'mark_connected', 'cable_end',
|
|
|
+ )
|
|
|
|
|
|
|
|
|
class ModuleBayFilterSet(DeviceComponentFilterSet, NetBoxModelFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = ModuleBay
|
|
|
- fields = ['id', 'name', 'label', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'position', 'description')
|
|
|
|
|
|
|
|
|
class DeviceBayFilterSet(DeviceComponentFilterSet, NetBoxModelFilterSet):
|
|
|
+ installed_device_id = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ queryset=Device.objects.all(),
|
|
|
+ label=_('Installed device (ID)'),
|
|
|
+ )
|
|
|
+ installed_device = django_filters.ModelMultipleChoiceFilter(
|
|
|
+ field_name='installed_device__name',
|
|
|
+ queryset=Device.objects.all(),
|
|
|
+ to_field_name='name',
|
|
|
+ label=_('Installed device (name)'),
|
|
|
+ )
|
|
|
|
|
|
class Meta:
|
|
|
model = DeviceBay
|
|
|
- fields = ['id', 'name', 'label', 'description']
|
|
|
+ fields = ('id', 'name', 'label', 'description')
|
|
|
|
|
|
|
|
|
class InventoryItemFilterSet(DeviceComponentFilterSet, NetBoxModelFilterSet):
|
|
|
@@ -1686,7 +1751,7 @@ class InventoryItemFilterSet(DeviceComponentFilterSet, NetBoxModelFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = InventoryItem
|
|
|
- fields = ['id', 'name', 'label', 'part_id', 'asset_tag', 'discovered']
|
|
|
+ fields = ('id', 'name', 'label', 'part_id', 'asset_tag', 'description', 'discovered')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -1770,7 +1835,7 @@ class VirtualChassisFilterSet(NetBoxModelFilterSet):
|
|
|
|
|
|
class Meta:
|
|
|
model = VirtualChassis
|
|
|
- fields = ['id', 'domain', 'name', 'description']
|
|
|
+ fields = ('id', 'domain', 'name', 'description', 'member_count')
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|
|
|
@@ -1953,12 +2018,12 @@ class CableFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
return self.filter_by_termination_object(queryset, CircuitTermination, value)
|
|
|
|
|
|
|
|
|
-class CableTerminationFilterSet(BaseFilterSet):
|
|
|
+class CableTerminationFilterSet(ChangeLoggedModelFilterSet):
|
|
|
termination_type = ContentTypeFilter()
|
|
|
|
|
|
class Meta:
|
|
|
model = CableTermination
|
|
|
- fields = ['id', 'cable', 'cable_end', 'termination_type', 'termination_id']
|
|
|
+ fields = ('id', 'cable', 'cable_end', 'termination_type', 'termination_id')
|
|
|
|
|
|
|
|
|
class PowerPanelFilterSet(NetBoxModelFilterSet, ContactModelFilterSet):
|
|
|
@@ -2073,10 +2138,10 @@ class PowerFeedFilterSet(NetBoxModelFilterSet, CabledObjectFilterSet, PathEndpoi
|
|
|
|
|
|
class Meta:
|
|
|
model = PowerFeed
|
|
|
- fields = [
|
|
|
- 'id', 'name', 'status', 'type', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization', 'cable_end',
|
|
|
- 'description',
|
|
|
- ]
|
|
|
+ fields = (
|
|
|
+ 'id', 'name', 'status', 'type', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization',
|
|
|
+ 'available_power', 'mark_connected', 'cable_end', 'description',
|
|
|
+ )
|
|
|
|
|
|
def search(self, queryset, name, value):
|
|
|
if not value.strip():
|