diff --git a/docs/models/dcim/rack.md b/docs/models/dcim/rack.md index b603e7a0b..3989e2b04 100644 --- a/docs/models/dcim/rack.md +++ b/docs/models/dcim/rack.md @@ -61,6 +61,10 @@ The canonical distance between the two vertical rails on a face. (This is typica The height of the rack, measured in units. +### Starting Unit + +The number of the numerically lowest unit in the rack. This value defaults to one, but may be higher in certain situations. For example, you may want to model only a select range of units within a shared physical rack (e.g. U13 through U24). + ### Outer Dimensions 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. diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index da4482f43..341a1064a 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -214,9 +214,9 @@ class RackSerializer(NetBoxModelSerializer): model = Rack fields = [ 'id', 'url', 'display', 'name', 'facility_id', 'site', 'location', 'tenant', 'status', 'role', 'serial', - 'asset_tag', 'type', 'width', 'u_height', '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', 'powerfeed_count', + 'asset_tag', 'type', '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', 'powerfeed_count', ] diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index f7c53b23d..f7ae8591f 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -323,8 +323,8 @@ class RackFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSe class Meta: model = Rack fields = [ - 'id', 'name', 'facility_id', 'asset_tag', 'u_height', 'desc_units', 'outer_width', 'outer_depth', - 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit' + 'id', 'name', 'facility_id', 'asset_tag', 'u_height', 'starting_unit', 'desc_units', 'outer_width', + 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit' ] def search(self, queryset, name, value): diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index 8610c54c4..22ca3da90 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -114,9 +114,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', 'u_height', 'width', 'outer_width', 'outer_depth', 'mounting_depth', 'weight', - 'max_weight', 'comments', 'device_count', 'get_utilization', 'get_power_utilization', 'description', - 'contacts', 'tags', 'created', 'last_updated', + 'asset_tag', 'type', 'u_height', 'starting_unit', 'width', 'outer_width', 'outer_depth', 'mounting_depth', + 'weight', 'max_weight', 'comments', 'device_count', 'get_utilization', 'get_power_utilization', + 'description', 'contacts', 'tags', 'created', 'last_updated', ) default_columns = ( 'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count', diff --git a/netbox/dcim/tests/test_filtersets.py b/netbox/dcim/tests/test_filtersets.py index 0597bbf99..48600bf41 100644 --- a/netbox/dcim/tests/test_filtersets.py +++ b/netbox/dcim/tests/test_filtersets.py @@ -459,6 +459,12 @@ class RackTestCase(TestCase, ChangeLoggedFilterSetTests): params = {'u_height': [42, 43]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) + def test_starting_unit(self): + params = {'starting_unit': [1]} + self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3) + params = {'starting_unit': [2]} + self.assertEqual(self.filterset(params, self.queryset).qs.count(), 0) + def test_desc_units(self): params = {'desc_units': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) diff --git a/netbox/templates/dcim/rack_edit.html b/netbox/templates/dcim/rack_edit.html index 875c3d6ab..193cfa02e 100644 --- a/netbox/templates/dcim/rack_edit.html +++ b/netbox/templates/dcim/rack_edit.html @@ -39,6 +39,7 @@ {% render_field form.type %} {% render_field form.width %} + {% render_field form.starting_unit %} {% render_field form.u_height %}