diff --git a/docs/models/dcim/moduletype.md b/docs/models/dcim/moduletype.md index 3122d2e00..7077e16c2 100644 --- a/docs/models/dcim/moduletype.md +++ b/docs/models/dcim/moduletype.md @@ -39,3 +39,7 @@ An alternative part number to uniquely identify the module type. ### Weight The numeric weight of the module, including a unit designation (e.g. 3 kilograms or 1 pound). + +### Airflow + +The direction in which air circulates through the device chassis for cooling. diff --git a/docs/models/dcim/racktype.md b/docs/models/dcim/racktype.md index d44e17b17..82c41bdf6 100644 --- a/docs/models/dcim/racktype.md +++ b/docs/models/dcim/racktype.md @@ -54,4 +54,7 @@ The maximum total weight capacity for all installed devices, inclusive of the ra If selected, the rack's elevation will display unit 1 at the top of the rack. (Most racks use ascending numbering, with unit 1 assigned to the bottommost position.) +### Airflow + +The direction in which air circulates through the device chassis for cooling. diff --git a/netbox/dcim/api/serializers_/devices.py b/netbox/dcim/api/serializers_/devices.py index f4e72f082..842c7e02b 100644 --- a/netbox/dcim/api/serializers_/devices.py +++ b/netbox/dcim/api/serializers_/devices.py @@ -149,7 +149,7 @@ class ModuleSerializer(NetBoxModelSerializer): class Meta: model = Module fields = [ - 'id', 'url', 'display_url', 'display', 'device', 'module_bay', 'module_type', 'status', 'serial', - 'asset_tag', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', + 'id', 'url', 'display_url', 'display', 'device', 'module_bay', 'module_type', 'status', + 'serial', 'asset_tag', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', ] brief_fields = ('id', 'url', 'display', 'device', 'module_bay', 'module_type', 'description') diff --git a/netbox/dcim/api/serializers_/devicetypes.py b/netbox/dcim/api/serializers_/devicetypes.py index a755247db..e04668e82 100644 --- a/netbox/dcim/api/serializers_/devicetypes.py +++ b/netbox/dcim/api/serializers_/devicetypes.py @@ -64,11 +64,13 @@ class DeviceTypeSerializer(NetBoxModelSerializer): class ModuleTypeSerializer(NetBoxModelSerializer): manufacturer = ManufacturerSerializer(nested=True) weight_unit = ChoiceField(choices=WeightUnitChoices, allow_blank=True, required=False, allow_null=True) + airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False, allow_null=True) class Meta: model = ModuleType fields = [ - 'id', 'url', 'display_url', 'display', 'manufacturer', 'model', 'part_number', 'weight', 'weight_unit', - 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', + 'id', 'url', 'display_url', 'display', 'manufacturer', 'model', 'part_number', 'airflow', + 'weight', 'weight_unit', 'description', 'comments', 'tags', 'custom_fields', + 'created', 'last_updated', ] brief_fields = ('id', 'url', 'display', 'manufacturer', 'model', 'description') diff --git a/netbox/dcim/api/serializers_/racks.py b/netbox/dcim/api/serializers_/racks.py index 4fb96e08c..e05ae6f80 100644 --- a/netbox/dcim/api/serializers_/racks.py +++ b/netbox/dcim/api/serializers_/racks.py @@ -64,13 +64,18 @@ class RackTypeSerializer(RackBaseSerializer): manufacturer = ManufacturerSerializer( nested=True ) + airflow = ChoiceField( + choices=DeviceAirflowChoices, + allow_blank=True, + required=False + ) class Meta: model = RackType fields = [ 'id', 'url', 'display_url', 'display', 'manufacturer', 'name', 'slug', 'description', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'weight', - 'max_weight', 'weight_unit', 'mounting_depth', 'description', 'comments', 'tags', 'custom_fields', + 'max_weight', 'weight_unit', 'mounting_depth', 'airflow', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', ] brief_fields = ('id', 'url', 'display', 'manufacturer', 'name', 'slug', 'description') @@ -95,6 +100,11 @@ class RackSerializer(RackBaseSerializer): choices=RackStatusChoices, required=False ) + airflow = ChoiceField( + choices=DeviceAirflowChoices, + allow_blank=True, + required=False + ) role = RackRoleSerializer( nested=True, required=False, @@ -124,7 +134,7 @@ class RackSerializer(RackBaseSerializer): 'id', 'url', 'display_url', 'display', 'name', 'facility_id', 'site', 'location', 'tenant', 'status', 'role', 'serial', 'asset_tag', 'rack_type', 'form_factor', 'width', 'u_height', 'starting_unit', 'weight', 'max_weight', 'weight_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', - 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', + 'airflow', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'powerfeed_count', ] brief_fields = ('id', 'url', 'display', 'name', 'description', 'device_count') diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 4a017dd46..5af5a3878 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -268,6 +268,11 @@ class RackTypeBulkEditForm(NetBoxModelBulkEditForm): required=False, min_value=1 ) + airflow = forms.ChoiceField( + label=_('Airflow'), + choices=add_blank_choice(DeviceAirflowChoices), + required=False + ) weight = forms.DecimalField( label=_('Weight'), min_value=0, @@ -298,7 +303,7 @@ class RackTypeBulkEditForm(NetBoxModelBulkEditForm): 'width', 'u_height', InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')), - InlineFields('weight', 'max_weight', 'weight_unit', label=_('Weight')), + InlineFields('airflow', 'weight', 'max_weight', 'weight_unit', label=_('Chassis')), 'mounting_depth', name=_('Dimensions') ), @@ -409,6 +414,11 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): required=False, min_value=1 ) + airflow = forms.ChoiceField( + label=_('Airflow'), + choices=add_blank_choice(DeviceAirflowChoices), + required=False + ) weight = forms.DecimalField( label=_('Weight'), min_value=0, @@ -440,7 +450,7 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): 'form_factor', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', name=_('Hardware') ), - FieldSet('weight', 'max_weight', 'weight_unit', name=_('Weight')), + FieldSet('airflow', 'weight', 'max_weight', 'weight_unit', name=_('Chassis')), ) nullable_fields = ( 'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'weight', @@ -563,6 +573,11 @@ class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm): label=_('Part number'), required=False ) + airflow = forms.ChoiceField( + label=_('Airflow'), + choices=add_blank_choice(DeviceAirflowChoices), + required=False + ) weight = forms.DecimalField( label=_('Weight'), min_value=0, @@ -584,7 +599,7 @@ class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm): model = ModuleType fieldsets = ( FieldSet('manufacturer', 'part_number', 'description', name=_('Module Type')), - FieldSet('weight', 'weight_unit', name=_('Weight')), + FieldSet('airflow', 'weight', 'weight_unit', name=_('Chassis')), ) nullable_fields = ('part_number', 'weight', 'weight_unit', 'description', 'comments') diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index 7f7efecf6..d86caf55c 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -206,6 +206,12 @@ class RackTypeImportForm(NetBoxModelImportForm): required=False, help_text=_('Unit for outer dimensions') ) + airflow = CSVChoiceField( + label=_('Airflow'), + choices=DeviceAirflowChoices, + required=False, + help_text=_('Airflow direction') + ) weight_unit = CSVChoiceField( label=_('Weight unit'), choices=WeightUnitChoices, @@ -217,8 +223,8 @@ class RackTypeImportForm(NetBoxModelImportForm): model = RackType fields = ( 'manufacturer', 'name', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units', - 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', - 'description', 'comments', 'tags', + 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'airflow', 'weight', 'max_weight', + 'weight_unit', 'description', 'comments', 'tags', ) def __init__(self, data=None, *args, **kwargs): @@ -273,6 +279,12 @@ class RackImportForm(NetBoxModelImportForm): required=False, help_text=_('Unit for outer dimensions') ) + airflow = CSVChoiceField( + label=_('Airflow'), + choices=DeviceAirflowChoices, + required=False, + help_text=_('Airflow direction') + ) weight_unit = CSVChoiceField( label=_('Weight unit'), choices=WeightUnitChoices, @@ -284,8 +296,8 @@ class RackImportForm(NetBoxModelImportForm): model = Rack fields = ( 'site', 'location', 'name', 'facility_id', 'tenant', 'status', 'role', 'form_factor', 'serial', 'asset_tag', - 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', - 'max_weight', 'weight_unit', 'description', 'comments', 'tags', + 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'airflow', + 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags', ) def __init__(self, data=None, *args, **kwargs): @@ -400,6 +412,12 @@ class ModuleTypeImportForm(NetBoxModelImportForm): queryset=Manufacturer.objects.all(), to_field_name='name' ) + airflow = CSVChoiceField( + label=_('Airflow'), + choices=DeviceAirflowChoices, + required=False, + help_text=_('Airflow direction') + ) weight = forms.DecimalField( label=_('Weight'), required=False, @@ -414,7 +432,7 @@ class ModuleTypeImportForm(NetBoxModelImportForm): class Meta: model = ModuleType - fields = ['manufacturer', 'model', 'part_number', 'description', 'weight', 'weight_unit', 'comments', 'tags'] + fields = ['manufacturer', 'model', 'part_number', 'description', 'airflow', 'weight', 'weight_unit', 'comments', 'tags'] class DeviceRoleImportForm(NetBoxModelImportForm): diff --git a/netbox/dcim/forms/filtersets.py b/netbox/dcim/forms/filtersets.py index 5d16a7b39..61dd27d32 100644 --- a/netbox/dcim/forms/filtersets.py +++ b/netbox/dcim/forms/filtersets.py @@ -267,6 +267,11 @@ class RackBaseFilterForm(NetBoxModelFilterSetForm): choices=BOOLEAN_WITH_BLANK_CHOICES ) ) + airflow = forms.MultipleChoiceField( + label=_('Airflow'), + choices=add_blank_choice(DeviceAirflowChoices), + required=False + ) weight = forms.DecimalField( label=_('Weight'), required=False, @@ -288,7 +293,7 @@ class RackTypeFilterForm(RackBaseFilterForm): model = RackType fieldsets = ( FieldSet('q', 'filter_id', 'tag'), - FieldSet('form_factor', 'width', 'u_height', name=_('Rack Type')), + FieldSet('form_factor', 'width', 'u_height', 'airflow', name=_('Rack Type')), FieldSet('starting_unit', 'desc_units', name=_('Numbering')), FieldSet('weight', 'max_weight', 'weight_unit', name=_('Weight')), ) @@ -308,7 +313,7 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, RackBaseFilterFo FieldSet('region_id', 'site_group_id', 'site_id', 'location_id', name=_('Location')), FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')), FieldSet('status', 'role_id', 'serial', 'asset_tag', name=_('Rack')), - FieldSet('form_factor', 'width', 'u_height', name=_('Rack Type')), + FieldSet('form_factor', 'width', 'u_height', 'airflow', name=_('Rack Type')), FieldSet('starting_unit', 'desc_units', name=_('Numbering')), FieldSet('weight', 'max_weight', 'weight_unit', name=_('Weight')), FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts')), @@ -578,7 +583,7 @@ class ModuleTypeFilterForm(NetBoxModelFilterSetForm): model = ModuleType fieldsets = ( FieldSet('q', 'filter_id', 'tag'), - FieldSet('manufacturer_id', 'part_number', name=_('Hardware')), + FieldSet('manufacturer_id', 'part_number', 'airflow', name=_('Hardware')), FieldSet( 'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', 'pass_through_ports', name=_('Components') @@ -638,6 +643,11 @@ class ModuleTypeFilterForm(NetBoxModelFilterSetForm): ) ) tag = TagFilterField(model) + airflow = forms.MultipleChoiceField( + label=_('Airflow'), + choices=add_blank_choice(DeviceAirflowChoices), + required=False + ) weight = forms.DecimalField( label=_('Weight'), required=False diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index bff0d8c46..d43caaee8 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -213,7 +213,7 @@ class RackTypeForm(NetBoxModelForm): fieldsets = ( FieldSet('manufacturer', 'name', 'slug', 'description', 'form_factor', 'tags', name=_('Rack Type')), FieldSet( - 'width', 'u_height', + 'airflow', 'width', 'u_height', InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')), InlineFields('weight', 'max_weight', 'weight_unit', label=_('Weight')), 'mounting_depth', name=_('Dimensions') @@ -226,7 +226,7 @@ class RackTypeForm(NetBoxModelForm): fields = [ 'manufacturer', 'name', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', - 'description', 'comments', 'tags', + 'airflow', 'description', 'comments', 'tags', ] @@ -268,8 +268,8 @@ class RackForm(TenancyForm, NetBoxModelForm): fields = [ 'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial', 'asset_tag', 'rack_type', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', - 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', - 'comments', 'tags', + 'outer_depth', 'outer_unit', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'weight_unit', + 'description', 'comments', 'tags', ] def __init__(self, *args, **kwargs): @@ -292,7 +292,7 @@ class RackForm(TenancyForm, NetBoxModelForm): FieldSet( 'form_factor', 'width', 'starting_unit', 'u_height', InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')), - InlineFields('weight', 'max_weight', 'weight_unit', label=_('Weight')), + InlineFields('airflow', 'weight', 'max_weight', 'weight_unit', label=_('Chassis')), 'mounting_depth', 'desc_units', name=_('Dimensions') ), ) @@ -398,13 +398,14 @@ class ModuleTypeForm(NetBoxModelForm): fieldsets = ( FieldSet('manufacturer', 'model', 'part_number', 'description', 'tags', name=_('Module Type')), - FieldSet('weight', 'weight_unit', name=_('Weight')) + FieldSet('airflow', 'weight', 'weight_unit', name=_('Chassis')) ) class Meta: model = ModuleType fields = [ - 'manufacturer', 'model', 'part_number', 'weight', 'weight_unit', 'description', 'comments', 'tags', + 'manufacturer', 'model', 'part_number', 'airflow', 'weight', 'weight_unit', 'description', + 'comments', 'tags', ] diff --git a/netbox/dcim/migrations/0189_module_airflow_rack_airflow_racktype_airflow.py b/netbox/dcim/migrations/0189_moduletype_airflow_rack_airflow_racktype_airflow.py similarity index 88% rename from netbox/dcim/migrations/0189_module_airflow_rack_airflow_racktype_airflow.py rename to netbox/dcim/migrations/0189_moduletype_airflow_rack_airflow_racktype_airflow.py index 4523ec49c..853daea9c 100644 --- a/netbox/dcim/migrations/0189_module_airflow_rack_airflow_racktype_airflow.py +++ b/netbox/dcim/migrations/0189_moduletype_airflow_rack_airflow_racktype_airflow.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.7 on 2024-07-24 08:45 +# Generated by Django 5.0.7 on 2024-07-24 09:06 from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( - model_name='module', + model_name='moduletype', name='airflow', field=models.CharField(blank=True, max_length=50), ), diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py index 14f17f4ce..1d8fbb163 100644 --- a/netbox/dcim/models/devices.py +++ b/netbox/dcim/models/devices.py @@ -360,7 +360,7 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin, AirflowMixin) return self.subdevice_role == SubdeviceRoleChoices.ROLE_CHILD -class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin): +class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin, AirflowMixin): """ A ModuleType represents a hardware element that can be installed within a device and which houses additional components; for example, a line card within a chassis-based switch such as the Cisco Catalyst 6500. Like a @@ -1120,7 +1120,7 @@ class Device( return round(total_weight / 1000, 2) -class Module(PrimaryModel, ConfigContextModel, AirflowMixin): +class Module(PrimaryModel, ConfigContextModel): """ A Module represents a field-installable component within a Device which may itself hold multiple device components (for example, a line card within a chassis switch). Modules are instantiated from ModuleTypes. diff --git a/netbox/dcim/tables/modules.py b/netbox/dcim/tables/modules.py index 0cd9e438e..5b06e08b2 100644 --- a/netbox/dcim/tables/modules.py +++ b/netbox/dcim/tables/modules.py @@ -40,7 +40,7 @@ class ModuleTypeTable(NetBoxTable): class Meta(NetBoxTable.Meta): model = ModuleType fields = ( - 'pk', 'id', 'model', 'manufacturer', 'part_number', 'weight', 'description', 'comments', 'tags', + 'pk', 'id', 'model', 'manufacturer', 'part_number', 'airflow', 'weight', 'description', 'comments', 'tags', ) default_columns = ( 'pk', 'model', 'manufacturer', 'part_number', diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index d269681c5..064a5a43d 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -92,8 +92,8 @@ class RackTypeTable(NetBoxTable): model = RackType fields = ( 'pk', 'id', 'name', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', - 'outer_depth', 'mounting_depth', 'weight', 'max_weight', 'description', 'comments', 'tags', 'created', - 'last_updated', + 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments', 'tags', + 'created', 'last_updated', ) default_columns = ( 'pk', 'name', 'manufacturer', 'type', 'u_height', 'description', @@ -171,7 +171,7 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable): fields = ( 'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial', 'asset_tag', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width', 'outer_depth', - 'mounting_depth', 'weight', 'max_weight', 'comments', 'device_count', 'get_utilization', + 'mounting_depth', 'airflow', 'weight', 'max_weight', 'comments', 'device_count', 'get_utilization', 'get_power_utilization', 'description', 'contacts', 'tags', 'created', 'last_updated', ) default_columns = ( diff --git a/netbox/templates/dcim/moduletype.html b/netbox/templates/dcim/moduletype.html index 77feece97..3ddeea89e 100644 --- a/netbox/templates/dcim/moduletype.html +++ b/netbox/templates/dcim/moduletype.html @@ -26,6 +26,12 @@