diff --git a/docs/models/dcim/rack.md b/docs/models/dcim/rack.md index e88c36fad..505160d3e 100644 --- a/docs/models/dcim/rack.md +++ b/docs/models/dcim/rack.md @@ -65,6 +65,10 @@ The height of the rack, measured in units. The external width and depth of the rack can be tracked to aid in floorplan calculations. These measurements must be designated in either millimeters or inches. +### Mounting Depth + +The maximum depth of a mounted device that the rack can accommodate, in millimeters. For four-post frames or cabinets, this is the horizontal distance between the front and rear vertical rails. (Note that this measurement does _not_ include space between the rails and the cabinet doors.) + ### Weight The numeric weight of the rack, including a unit designation (e.g. 10 kilograms or 20 pounds). diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index eefb0ee21..5ca84c996 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -28,6 +28,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a * [#9478](https://github.com/netbox-community/netbox/issues/9478) - Add `link_peers` field to GraphQL types for cabled objects * [#9654](https://github.com/netbox-community/netbox/issues/9654) - Add `weight` field to racks, device types, and module types * [#9817](https://github.com/netbox-community/netbox/issues/9817) - Add `assigned_object` field to GraphQL type for IP addresses and L2VPN terminations +* [#9832](https://github.com/netbox-community/netbox/issues/9832) - Add `mounting_depth` field to rack model * [#9892](https://github.com/netbox-community/netbox/issues/9892) - Add optional `name` field for FHRP groups * [#10348](https://github.com/netbox-community/netbox/issues/10348) - Add decimal custom field type * [#10556](https://github.com/netbox-community/netbox/issues/10556) - Include a `display` field in all GraphQL object types @@ -81,6 +82,8 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a * Add `component` field * dcim.InventoryItemTemplate * Add `component` field +* dcim.Rack + * Add `mounting_depth` field * ipam.FHRPGroupAssignment * Add `interface` field * ipam.IPAddress diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 22d56565e..1cf9369ae 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -210,8 +210,8 @@ class RackSerializer(NetBoxModelSerializer): fields = [ 'id', 'url', 'display', 'name', 'facility_id', 'site', 'location', 'tenant', 'status', 'role', 'serial', 'asset_tag', 'type', 'width', 'u_height', 'weight', 'weight_unit', 'desc_units', 'outer_width', - 'outer_depth', 'outer_unit', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', - 'powerfeed_count', + 'outer_depth', 'outer_unit', 'mounting_depth', 'comments', 'tags', 'custom_fields', 'created', + 'last_updated', 'device_count', 'powerfeed_count', ] diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index a200b1ece..78afd816c 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -320,7 +320,7 @@ class RackFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSe model = Rack fields = [ 'id', 'name', 'facility_id', 'asset_tag', 'u_height', 'desc_units', 'outer_width', 'outer_depth', - 'outer_unit', 'weight', 'weight_unit' + 'outer_unit', 'mounting_depth', 'weight', 'weight_unit' ] def search(self, queryset, name, value): diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index d033d3a67..e3b69dc81 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -281,6 +281,10 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): required=False, widget=StaticSelect() ) + mounting_depth = forms.IntegerField( + required=False, + min_value=1 + ) comments = CommentField( widget=SmallTextarea, label='Comments' @@ -300,11 +304,14 @@ class RackBulkEditForm(NetBoxModelBulkEditForm): fieldsets = ( ('Rack', ('status', 'role', 'tenant', 'serial', 'asset_tag')), ('Location', ('region', 'site_group', 'site', 'location')), - ('Hardware', ('type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit')), + ('Hardware', ( + 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', + )), ('Weight', ('weight', 'weight_unit')), ) nullable_fields = ( - 'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'comments', 'weight', 'weight_unit' + 'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'comments', + 'weight', 'weight_unit' ) diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index f0fd9bf86..add66ee96 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -196,7 +196,7 @@ class RackCSVForm(NetBoxModelCSVForm): model = Rack fields = ( 'site', 'location', 'name', 'facility_id', 'tenant', 'status', 'role', 'type', 'serial', 'asset_tag', - 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'comments', + 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'comments', ) def __init__(self, data=None, *args, **kwargs): diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 1df9e143c..0da2f3430 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -278,7 +278,7 @@ class RackForm(TenancyForm, NetBoxModelForm): fields = [ 'region', 'site_group', 'site', 'location', 'name', 'facility_id', 'tenant_group', 'tenant', 'status', 'role', 'serial', 'asset_tag', 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', - 'outer_unit', 'weight', 'weight_unit', 'comments', 'tags', + 'outer_unit', 'mounting_depth', 'weight', 'weight_unit', 'comments', 'tags', ] help_texts = { 'site': "The site at which the rack exists", diff --git a/netbox/dcim/migrations/0164_rack_mounting_depth.py b/netbox/dcim/migrations/0164_rack_mounting_depth.py new file mode 100644 index 000000000..5bd087beb --- /dev/null +++ b/netbox/dcim/migrations/0164_rack_mounting_depth.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.1 on 2022-10-27 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0163_rack_devicetype_moduletype_weights'), + ] + + operations = [ + migrations.AddField( + model_name='rack', + name='mounting_depth', + field=models.PositiveSmallIntegerField(blank=True, null=True), + ), + ] diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index 6da48b65c..6fcd65a19 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -167,6 +167,14 @@ class Rack(NetBoxModel, WeightMixin): choices=RackDimensionUnitChoices, blank=True, ) + mounting_depth = models.PositiveSmallIntegerField( + blank=True, + null=True, + help_text=( + 'Maximum depth of a mounted device, in millimeters. For four-post racks, this is the ' + 'distance between the front and rear rails.' + ) + ) comments = models.TextField( blank=True ) @@ -187,7 +195,7 @@ class Rack(NetBoxModel, WeightMixin): clone_fields = ( 'site', 'location', 'tenant', 'status', 'role', 'type', 'width', 'u_height', 'desc_units', 'outer_width', - 'outer_depth', 'outer_unit', 'weight', 'weight_unit', + 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'weight_unit', ) class Meta: diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index 9c7b28983..1a355cc2a 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -89,8 +89,9 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable): model = Rack fields = ( 'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial', - 'asset_tag', 'type', 'width', 'outer_width', 'outer_depth', 'u_height', 'weight', 'comments', - 'device_count', 'get_utilization', 'get_power_utilization', 'contacts', 'tags', 'created', 'last_updated', + 'asset_tag', 'type', 'u_height', 'width', 'outer_width', 'outer_depth', 'mounting_depth', 'weight', + 'comments', 'device_count', 'get_utilization', 'get_power_utilization', 'contacts', 'tags', 'created', + 'last_updated', ) default_columns = ( 'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count', diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index e30ce7a62..7118f09ef 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -129,7 +129,7 @@ Outer Width {% if object.outer_width %} - {{ object.outer_width }} {{ object.get_outer_unit_display }} + {{ object.outer_width }} {{ object.get_outer_unit_display }} {% else %} {{ ''|placeholder }} {% endif %} @@ -139,7 +139,17 @@ Outer Depth {% if object.outer_depth %} - {{ object.outer_depth }} {{ object.get_outer_unit_display }} + {{ object.outer_depth }} {{ object.get_outer_unit_display }} + {% else %} + {{ ''|placeholder }} + {% endif %} + + + + Mounting Depth + + {% if object.mounting_depth %} + {{ object.mounting_depth }} Millimeters {% else %} {{ ''|placeholder }} {% endif %} diff --git a/netbox/templates/dcim/rack_edit.html b/netbox/templates/dcim/rack_edit.html index 4a340c147..a0af20c68 100644 --- a/netbox/templates/dcim/rack_edit.html +++ b/netbox/templates/dcim/rack_edit.html @@ -55,6 +55,7 @@
Unit
+ {% render_field form.mounting_depth %} {% render_field form.desc_units %}