2
0
Jeremy Stretch 2 жил өмнө
parent
commit
1937c1fad6

+ 4 - 0
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.
 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
 ### 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.
 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.

+ 3 - 3
netbox/dcim/api/serializers.py

@@ -214,9 +214,9 @@ class RackSerializer(NetBoxModelSerializer):
         model = Rack
         model = Rack
         fields = [
         fields = [
             'id', 'url', 'display', 'name', 'facility_id', 'site', 'location', 'tenant', 'status', 'role', 'serial',
             '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',
         ]
         ]
 
 
 
 

+ 2 - 2
netbox/dcim/filtersets.py

@@ -323,8 +323,8 @@ class RackFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSe
     class Meta:
     class Meta:
         model = Rack
         model = Rack
         fields = [
         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):
     def search(self, queryset, name, value):

+ 3 - 3
netbox/dcim/tables/racks.py

@@ -114,9 +114,9 @@ class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
         model = Rack
         model = Rack
         fields = (
         fields = (
             'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial',
             '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 = (
         default_columns = (
             'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count',
             'pk', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count',

+ 6 - 0
netbox/dcim/tests/test_filtersets.py

@@ -459,6 +459,12 @@ class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
         params = {'u_height': [42, 43]}
         params = {'u_height': [42, 43]}
         self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
         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):
     def test_desc_units(self):
         params = {'desc_units': 'true'}
         params = {'desc_units': 'true'}
         self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
         self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)

+ 1 - 1
netbox/templates/dcim/rack_edit.html

@@ -39,6 +39,7 @@
         </div>
         </div>
         {% render_field form.type %}
         {% render_field form.type %}
         {% render_field form.width %}
         {% render_field form.width %}
+        {% render_field form.starting_unit %}
         {% render_field form.u_height %}
         {% render_field form.u_height %}
         <div class="row mb-3">
         <div class="row mb-3">
             <label class="col col-md-3 col-form-label text-lg-end">{% trans "Outer Dimensions" %}</label>
             <label class="col col-md-3 col-form-label text-lg-end">{% trans "Outer Dimensions" %}</label>
@@ -72,7 +73,6 @@
         </div>
         </div>
         {% render_field form.mounting_depth %}
         {% render_field form.mounting_depth %}
         {% render_field form.desc_units %}
         {% render_field form.desc_units %}
-        {% render_field form.starting_unit %}
     </div>
     </div>
 
 
     {% if form.custom_fields %}
     {% if form.custom_fields %}