Merge pull request #7547 from netbox-community/3839-device-airflow

Closes #3839: Add airflow fields to Device and DeviceType
This commit is contained in:
Jeremy Stretch 2021-10-14 16:29:43 -04:00 committed by GitHub
commit 6015c47587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 142 additions and 27 deletions

View File

@ -12,3 +12,5 @@ Some devices house child devices which share physical resources, like space and
!!! note !!! note
This parent/child relationship is **not** suitable for modeling chassis-based devices, wherein child members share a common control plane. Instead, line cards and similarly non-autonomous hardware should be modeled as inventory items within a device, with any associated interfaces or other components assigned directly to the device. This parent/child relationship is **not** suitable for modeling chassis-based devices, wherein child members share a common control plane. Instead, line cards and similarly non-autonomous hardware should be modeled as inventory items within a device, with any associated interfaces or other components assigned directly to the device.
A device type may optionally specify an airflow direction, such as front-to-rear, rear-to-front, or passive. Airflow direction may also be set separately per device. If it is not defined for a device at the time of its creation, it will inherit the airflow setting of its device type.

View File

@ -6,6 +6,7 @@
### Enhancements ### Enhancements
* [#1337](https://github.com/netbox-community/netbox/issues/1337) - Add WWN field to interfaces * [#1337](https://github.com/netbox-community/netbox/issues/1337) - Add WWN field to interfaces
* [#3839](https://github.com/netbox-community/netbox/issues/3839) - Add `airflow` field for devices types and devices
* [#6711](https://github.com/netbox-community/netbox/issues/6711) - Add `longtext` custom field type with Markdown support * [#6711](https://github.com/netbox-community/netbox/issues/6711) - Add `longtext` custom field type with Markdown support
* [#6874](https://github.com/netbox-community/netbox/issues/6874) - Add tenant assignment for locations * [#6874](https://github.com/netbox-community/netbox/issues/6874) - Add tenant assignment for locations

View File

@ -288,13 +288,14 @@ class DeviceTypeSerializer(PrimaryModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:devicetype-detail') url = serializers.HyperlinkedIdentityField(view_name='dcim-api:devicetype-detail')
manufacturer = NestedManufacturerSerializer() manufacturer = NestedManufacturerSerializer()
subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False) subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False)
airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False)
device_count = serializers.IntegerField(read_only=True) device_count = serializers.IntegerField(read_only=True)
class Meta: class Meta:
model = DeviceType model = DeviceType
fields = [ fields = [
'id', 'url', 'display', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'id', 'url', 'display', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth',
'subdevice_role', 'front_image', 'rear_image', 'comments', 'tags', 'custom_fields', 'created', 'subdevice_role', 'airflow', 'front_image', 'rear_image', 'comments', 'tags', 'custom_fields', 'created',
'last_updated', 'device_count', 'last_updated', 'device_count',
] ]
@ -464,6 +465,7 @@ class DeviceSerializer(PrimaryModelSerializer):
rack = NestedRackSerializer(required=False, allow_null=True) rack = NestedRackSerializer(required=False, allow_null=True)
face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, required=False) face = ChoiceField(choices=DeviceFaceChoices, allow_blank=True, required=False)
status = ChoiceField(choices=DeviceStatusChoices, required=False) status = ChoiceField(choices=DeviceStatusChoices, required=False)
airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False)
primary_ip = NestedIPAddressSerializer(read_only=True) primary_ip = NestedIPAddressSerializer(read_only=True)
primary_ip4 = NestedIPAddressSerializer(required=False, allow_null=True) primary_ip4 = NestedIPAddressSerializer(required=False, allow_null=True)
primary_ip6 = NestedIPAddressSerializer(required=False, allow_null=True) primary_ip6 = NestedIPAddressSerializer(required=False, allow_null=True)
@ -475,9 +477,9 @@ class DeviceSerializer(PrimaryModelSerializer):
model = Device model = Device
fields = [ fields = [
'id', 'url', 'display', 'name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag', 'id', 'url', 'display', 'name', 'device_type', 'device_role', 'tenant', 'platform', 'serial', 'asset_tag',
'site', 'location', 'rack', 'position', 'face', 'parent_device', 'status', 'primary_ip', 'primary_ip4', 'site', 'location', 'rack', 'position', 'face', 'parent_device', 'status', 'airflow', 'primary_ip',
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'local_context_data', 'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments',
'tags', 'custom_fields', 'created', 'last_updated', 'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
] ]
validators = [] validators = []

View File

@ -174,6 +174,25 @@ class DeviceStatusChoices(ChoiceSet):
} }
class DeviceAirflowChoices(ChoiceSet):
AIRFLOW_FRONT_TO_REAR = 'front-to-rear'
AIRFLOW_REAR_TO_FRONT = 'rear-to-front'
AIRFLOW_LEFT_TO_RIGHT = 'left-to-right'
AIRFLOW_RIGHT_TO_LEFT = 'right-to-left'
AIRFLOW_SIDE_TO_REAR = 'side-to-rear'
AIRFLOW_PASSIVE = 'passive'
CHOICES = (
(AIRFLOW_FRONT_TO_REAR, 'Front to rear'),
(AIRFLOW_REAR_TO_FRONT, 'Rear to front'),
(AIRFLOW_LEFT_TO_RIGHT, 'Left to right'),
(AIRFLOW_RIGHT_TO_LEFT, 'Right to left'),
(AIRFLOW_SIDE_TO_REAR, 'Side to rear'),
(AIRFLOW_PASSIVE, 'Passive'),
)
# #
# ConsolePorts # ConsolePorts
# #

View File

@ -441,7 +441,7 @@ class DeviceTypeFilterSet(PrimaryModelFilterSet):
class Meta: class Meta:
model = DeviceType model = DeviceType
fields = [ fields = [
'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
] ]
def search(self, queryset, name, value): def search(self, queryset, name, value):
@ -751,7 +751,7 @@ class DeviceFilterSet(PrimaryModelFilterSet, TenancyFilterSet, LocalConfigContex
class Meta: class Meta:
model = Device model = Device
fields = ['id', 'name', 'asset_tag', 'face', 'position', 'vc_position', 'vc_priority'] fields = ['id', 'name', 'asset_tag', 'face', 'position', 'airflow', 'vc_position', 'vc_priority']
def search(self, queryset, name, value): def search(self, queryset, name, value):
if not value.strip(): if not value.strip():

View File

@ -335,9 +335,14 @@ class DeviceTypeBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModel
widget=BulkEditNullBooleanSelect(), widget=BulkEditNullBooleanSelect(),
label='Is full depth' label='Is full depth'
) )
airflow = forms.ChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelect()
)
class Meta: class Meta:
nullable_fields = [] nullable_fields = ['airflow']
class DeviceRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm): class DeviceRoleBulkEditForm(BootstrapMixin, CustomFieldModelBulkEditForm):
@ -429,6 +434,11 @@ class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulk
required=False, required=False,
widget=StaticSelect() widget=StaticSelect()
) )
airflow = forms.ChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelect()
)
serial = forms.CharField( serial = forms.CharField(
max_length=50, max_length=50,
required=False, required=False,
@ -437,7 +447,7 @@ class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldModelBulk
class Meta: class Meta:
nullable_fields = [ nullable_fields = [
'tenant', 'platform', 'serial', 'tenant', 'platform', 'serial', 'airflow',
] ]

View File

@ -369,12 +369,17 @@ class DeviceCSVForm(BaseDeviceCSVForm):
required=False, required=False,
help_text='Mounted rack face' help_text='Mounted rack face'
) )
airflow = CSVChoiceField(
choices=DeviceAirflowChoices,
required=False,
help_text='Airflow direction'
)
class Meta(BaseDeviceCSVForm.Meta): class Meta(BaseDeviceCSVForm.Meta):
fields = [ fields = [
'name', 'device_role', 'tenant', 'manufacturer', 'device_type', 'platform', 'serial', 'asset_tag', 'status', 'name', 'device_role', 'tenant', 'manufacturer', 'device_type', 'platform', 'serial', 'asset_tag', 'status',
'site', 'location', 'rack', 'position', 'face', 'virtual_chassis', 'vc_position', 'vc_priority', 'cluster', 'site', 'location', 'rack', 'position', 'face', 'airflow', 'virtual_chassis', 'vc_position', 'vc_priority',
'comments', 'cluster', 'comments',
] ]
def __init__(self, data=None, *args, **kwargs): def __init__(self, data=None, *args, **kwargs):

View File

@ -385,7 +385,7 @@ class DeviceTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
model = DeviceType model = DeviceType
field_groups = [ field_groups = [
['q', 'tag'], ['q', 'tag'],
['manufacturer_id', 'subdevice_role'], ['manufacturer_id', 'subdevice_role', 'airflow'],
['console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports'], ['console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports'],
] ]
q = forms.CharField( q = forms.CharField(
@ -404,6 +404,11 @@ class DeviceTypeFilterForm(BootstrapMixin, CustomFieldModelFilterForm):
required=False, required=False,
widget=StaticSelectMultiple() widget=StaticSelectMultiple()
) )
airflow = forms.MultipleChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelectMultiple()
)
console_ports = forms.NullBooleanField( console_ports = forms.NullBooleanField(
required=False, required=False,
label='Has console ports', label='Has console ports',
@ -485,7 +490,7 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt
field_groups = [ field_groups = [
['q', 'tag'], ['q', 'tag'],
['region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id'], ['region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id'],
['status', 'role_id', 'serial', 'asset_tag', 'mac_address'], ['status', 'role_id', 'airflow', 'serial', 'asset_tag', 'mac_address'],
['manufacturer_id', 'device_type_id', 'platform_id'], ['manufacturer_id', 'device_type_id', 'platform_id'],
['tenant_group_id', 'tenant_id'], ['tenant_group_id', 'tenant_id'],
[ [
@ -574,6 +579,11 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt
required=False, required=False,
widget=StaticSelectMultiple() widget=StaticSelectMultiple()
) )
airflow = forms.MultipleChoiceField(
choices=add_blank_choice(DeviceAirflowChoices),
required=False,
widget=StaticSelectMultiple()
)
serial = forms.CharField( serial = forms.CharField(
required=False required=False
) )

View File

@ -367,12 +367,15 @@ class DeviceTypeForm(BootstrapMixin, CustomFieldModelForm):
class Meta: class Meta:
model = DeviceType model = DeviceType
fields = [ fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'front_image', 'rear_image', 'comments', 'tags', 'front_image', 'rear_image', 'comments', 'tags',
] ]
fieldsets = ( fieldsets = (
('Device Type', ( ('Device Type', (
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'tags', 'manufacturer', 'model', 'slug', 'part_number', 'tags',
)),
('Chassis', (
'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
)), )),
('Images', ('front_image', 'rear_image')), ('Images', ('front_image', 'rear_image')),
) )
@ -519,8 +522,8 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
model = Device model = Device
fields = [ fields = [
'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'region', 'site_group', 'site', 'rack', 'name', 'device_role', 'device_type', 'serial', 'asset_tag', 'region', 'site_group', 'site', 'rack',
'location', 'position', 'face', 'status', 'platform', 'primary_ip4', 'primary_ip6', 'cluster_group', 'location', 'position', 'face', 'status', 'airflow', 'platform', 'primary_ip4', 'primary_ip6',
'cluster', 'tenant_group', 'tenant', 'comments', 'tags', 'local_context_data' 'cluster_group', 'cluster', 'tenant_group', 'tenant', 'comments', 'tags', 'local_context_data'
] ]
help_texts = { help_texts = {
'device_role': "The function this device serves", 'device_role': "The function this device serves",
@ -531,6 +534,7 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
widgets = { widgets = {
'face': StaticSelect(), 'face': StaticSelect(),
'status': StaticSelect(), 'status': StaticSelect(),
'airflow': StaticSelect(),
'primary_ip4': StaticSelect(), 'primary_ip4': StaticSelect(),
'primary_ip6': StaticSelect(), 'primary_ip6': StaticSelect(),
} }

View File

@ -26,7 +26,7 @@ class DeviceTypeImportForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = DeviceType model = DeviceType
fields = [ fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'comments', 'comments',
] ]

View File

@ -144,6 +144,9 @@ class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, PrimaryObjectType):
def resolve_face(self, info): def resolve_face(self, info):
return self.face or None return self.face or None
def resolve_airflow(self, info):
return self.airflow or None
class DeviceBayType(ComponentObjectType): class DeviceBayType(ComponentObjectType):
@ -179,6 +182,9 @@ class DeviceTypeType(PrimaryObjectType):
def resolve_subdevice_role(self, info): def resolve_subdevice_role(self, info):
return self.subdevice_role or None return self.subdevice_role or None
def resolve_airflow(self, info):
return self.airflow or None
class FrontPortType(ComponentObjectType): class FrontPortType(ComponentObjectType):

View File

@ -0,0 +1,21 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0135_location_tenant'),
]
operations = [
migrations.AddField(
model_name='devicetype',
name='airflow',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='device',
name='airflow',
field=models.CharField(blank=True, max_length=50),
),
]

View File

@ -115,6 +115,11 @@ class DeviceType(PrimaryModel):
help_text='Parent devices house child devices in device bays. Leave blank ' help_text='Parent devices house child devices in device bays. Leave blank '
'if this device type is neither a parent nor a child.' 'if this device type is neither a parent nor a child.'
) )
airflow = models.CharField(
max_length=50,
choices=DeviceAirflowChoices,
blank=True
)
front_image = models.ImageField( front_image = models.ImageField(
upload_to='devicetype-images', upload_to='devicetype-images',
blank=True blank=True
@ -130,7 +135,7 @@ class DeviceType(PrimaryModel):
objects = RestrictedQuerySet.as_manager() objects = RestrictedQuerySet.as_manager()
clone_fields = [ clone_fields = [
'manufacturer', 'u_height', 'is_full_depth', 'subdevice_role', 'manufacturer', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
] ]
class Meta: class Meta:
@ -165,6 +170,7 @@ class DeviceType(PrimaryModel):
('u_height', self.u_height), ('u_height', self.u_height),
('is_full_depth', self.is_full_depth), ('is_full_depth', self.is_full_depth),
('subdevice_role', self.subdevice_role), ('subdevice_role', self.subdevice_role),
('airflow', self.airflow),
('comments', self.comments), ('comments', self.comments),
)) ))
@ -530,6 +536,11 @@ class Device(PrimaryModel, ConfigContextModel):
choices=DeviceStatusChoices, choices=DeviceStatusChoices,
default=DeviceStatusChoices.STATUS_ACTIVE default=DeviceStatusChoices.STATUS_ACTIVE
) )
airflow = models.CharField(
max_length=50,
choices=DeviceAirflowChoices,
blank=True
)
primary_ip4 = models.OneToOneField( primary_ip4 = models.OneToOneField(
to='ipam.IPAddress', to='ipam.IPAddress',
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
@ -580,7 +591,7 @@ class Device(PrimaryModel, ConfigContextModel):
objects = ConfigContextModelQuerySet.as_manager() objects = ConfigContextModelQuerySet.as_manager()
clone_fields = [ clone_fields = [
'device_type', 'device_role', 'tenant', 'platform', 'site', 'location', 'rack', 'status', 'cluster', 'device_type', 'device_role', 'tenant', 'platform', 'site', 'location', 'rack', 'status', 'airflow', 'cluster',
] ]
class Meta: class Meta:
@ -741,9 +752,12 @@ class Device(PrimaryModel, ConfigContextModel):
}) })
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
is_new = not bool(self.pk) is_new = not bool(self.pk)
# Inherit airflow attribute from DeviceType if not set
if is_new and not self.airflow:
self.airflow = self.device_type.airflow
super().save(*args, **kwargs) super().save(*args, **kwargs)
# If this is a new Device, instantiate all of the related components per the DeviceType definition # If this is a new Device, instantiate all of the related components per the DeviceType definition

View File

@ -197,8 +197,8 @@ class DeviceTable(BaseTable):
model = Device model = Device
fields = ( fields = (
'pk', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial', 'pk', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'primary_ip4', 'primary_ip6', 'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'airflow', 'primary_ip', 'primary_ip4',
'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags', 'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'tags',
) )
default_columns = ( default_columns = (
'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type', 'pk', 'name', 'status', 'tenant', 'site', 'location', 'rack', 'device_role', 'manufacturer', 'device_type',

View File

@ -77,7 +77,7 @@ class DeviceTypeTable(BaseTable):
model = DeviceType model = DeviceType
fields = ( fields = (
'pk', 'model', 'manufacturer', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'pk', 'model', 'manufacturer', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
'comments', 'instance_count', 'tags', 'airflow', 'comments', 'instance_count', 'tags',
) )
default_columns = ( default_columns = (
'pk', 'model', 'manufacturer', 'part_number', 'u_height', 'is_full_depth', 'instance_count', 'pk', 'model', 'manufacturer', 'part_number', 'u_height', 'is_full_depth', 'instance_count',

View File

@ -638,8 +638,8 @@ class DeviceTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
device_types = ( device_types = (
DeviceType(manufacturer=manufacturers[0], model='Model 1', slug='model-1', part_number='Part Number 1', u_height=1, is_full_depth=True), DeviceType(manufacturer=manufacturers[0], model='Model 1', slug='model-1', part_number='Part Number 1', u_height=1, is_full_depth=True),
DeviceType(manufacturer=manufacturers[1], model='Model 2', slug='model-2', part_number='Part Number 2', u_height=2, is_full_depth=True, subdevice_role=SubdeviceRoleChoices.ROLE_PARENT), DeviceType(manufacturer=manufacturers[1], model='Model 2', slug='model-2', part_number='Part Number 2', u_height=2, is_full_depth=True, subdevice_role=SubdeviceRoleChoices.ROLE_PARENT, airflow=DeviceAirflowChoices.AIRFLOW_FRONT_TO_REAR),
DeviceType(manufacturer=manufacturers[2], model='Model 3', slug='model-3', part_number='Part Number 3', u_height=3, is_full_depth=False, subdevice_role=SubdeviceRoleChoices.ROLE_CHILD), DeviceType(manufacturer=manufacturers[2], model='Model 3', slug='model-3', part_number='Part Number 3', u_height=3, is_full_depth=False, subdevice_role=SubdeviceRoleChoices.ROLE_CHILD, airflow=DeviceAirflowChoices.AIRFLOW_REAR_TO_FRONT),
) )
DeviceType.objects.bulk_create(device_types) DeviceType.objects.bulk_create(device_types)
@ -704,6 +704,10 @@ class DeviceTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
params = {'subdevice_role': SubdeviceRoleChoices.ROLE_PARENT} params = {'subdevice_role': SubdeviceRoleChoices.ROLE_PARENT}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_airflow(self):
params = {'airflow': DeviceAirflowChoices.AIRFLOW_FRONT_TO_REAR}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_manufacturer(self): def test_manufacturer(self):
manufacturers = Manufacturer.objects.all()[:2] manufacturers = Manufacturer.objects.all()[:2]
params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]} params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]}
@ -1235,8 +1239,8 @@ class DeviceTestCase(TestCase, ChangeLoggedFilterSetTests):
devices = ( devices = (
Device(name='Device 1', device_type=device_types[0], device_role=device_roles[0], platform=platforms[0], tenant=tenants[0], serial='ABC', asset_tag='1001', site=sites[0], location=locations[0], rack=racks[0], position=1, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_ACTIVE, cluster=clusters[0], local_context_data={"foo": 123}), Device(name='Device 1', device_type=device_types[0], device_role=device_roles[0], platform=platforms[0], tenant=tenants[0], serial='ABC', asset_tag='1001', site=sites[0], location=locations[0], rack=racks[0], position=1, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_ACTIVE, cluster=clusters[0], local_context_data={"foo": 123}),
Device(name='Device 2', device_type=device_types[1], device_role=device_roles[1], platform=platforms[1], tenant=tenants[1], serial='DEF', asset_tag='1002', site=sites[1], location=locations[1], rack=racks[1], position=2, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_STAGED, cluster=clusters[1]), Device(name='Device 2', device_type=device_types[1], device_role=device_roles[1], platform=platforms[1], tenant=tenants[1], serial='DEF', asset_tag='1002', site=sites[1], location=locations[1], rack=racks[1], position=2, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_STAGED, airflow=DeviceAirflowChoices.AIRFLOW_FRONT_TO_REAR, cluster=clusters[1]),
Device(name='Device 3', device_type=device_types[2], device_role=device_roles[2], platform=platforms[2], tenant=tenants[2], serial='GHI', asset_tag='1003', site=sites[2], location=locations[2], rack=racks[2], position=3, face=DeviceFaceChoices.FACE_REAR, status=DeviceStatusChoices.STATUS_FAILED, cluster=clusters[2]), Device(name='Device 3', device_type=device_types[2], device_role=device_roles[2], platform=platforms[2], tenant=tenants[2], serial='GHI', asset_tag='1003', site=sites[2], location=locations[2], rack=racks[2], position=3, face=DeviceFaceChoices.FACE_REAR, status=DeviceStatusChoices.STATUS_FAILED, airflow=DeviceAirflowChoices.AIRFLOW_REAR_TO_FRONT, cluster=clusters[2]),
) )
Device.objects.bulk_create(devices) Device.objects.bulk_create(devices)
@ -1390,6 +1394,10 @@ class DeviceTestCase(TestCase, ChangeLoggedFilterSetTests):
params = {'is_full_depth': 'false'} params = {'is_full_depth': 'false'}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_airflow(self):
params = {'airflow': DeviceAirflowChoices.AIRFLOW_FRONT_TO_REAR}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_mac_address(self): def test_mac_address(self):
params = {'mac_address': ['00-00-00-00-00-01', '00-00-00-00-00-02']} params = {'mac_address': ['00-00-00-00-00-01', '00-00-00-00-00-02']}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)

View File

@ -93,6 +93,12 @@
<span><a href="{{ object.device_type.get_absolute_url }}">{{ object.device_type }}</a> ({{ object.device_type.u_height }}U)</span> <span><a href="{{ object.device_type.get_absolute_url }}">{{ object.device_type }}</a> ({{ object.device_type.u_height }}U)</span>
</td> </td>
</tr> </tr>
<tr>
<td>Airflow</td>
<td>
{{ object.get_airflow_display|placeholder }}
</td>
</tr>
<tr> <tr>
<th scope="row">Serial Number</th> <th scope="row">Serial Number</th>
<td class="font-monospace">{{ object.serial|placeholder }}</td> <td class="font-monospace">{{ object.serial|placeholder }}</td>

View File

@ -19,6 +19,7 @@
</div> </div>
{% render_field form.manufacturer %} {% render_field form.manufacturer %}
{% render_field form.device_type %} {% render_field form.device_type %}
{% render_field form.airflow %}
{% render_field form.serial %} {% render_field form.serial %}
{% render_field form.asset_tag %} {% render_field form.asset_tag %}
</div> </div>

View File

@ -90,6 +90,12 @@
{{ object.get_subdevice_role_display|placeholder }} {{ object.get_subdevice_role_display|placeholder }}
</td> </td>
</tr> </tr>
<tr>
<td>Airflow</td>
<td>
{{ object.get_airflow_display|placeholder }}
</td>
</tr>
<tr> <tr>
<td>Front Image</td> <td>Front Image</td>
<td> <td>