Skip to content

Commit

Permalink
Closes #9832: Add mounting_depth field to rack model
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Oct 27, 2022
1 parent dbe6659 commit 72898d2
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/models/dcim/rack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes/version-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ class Meta:
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',
]


Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Meta:
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):
Expand Down
11 changes: 9 additions & 2 deletions netbox/dcim/forms/bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
)


Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Meta:
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):
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Meta:
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",
Expand Down
18 changes: 18 additions & 0 deletions netbox/dcim/migrations/0164_rack_mounting_depth.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
10 changes: 9 additions & 1 deletion netbox/dcim/models/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions netbox/dcim/tables/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class Meta(NetBoxTable.Meta):
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',
Expand Down
14 changes: 12 additions & 2 deletions netbox/templates/dcim/rack.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h5 class="card-header">Dimensions</h5>
<th scope="row">Outer Width</th>
<td>
{% if object.outer_width %}
<span>{{ object.outer_width }} {{ object.get_outer_unit_display }}</span>
{{ object.outer_width }} {{ object.get_outer_unit_display }}
{% else %}
{{ ''|placeholder }}
{% endif %}
Expand All @@ -139,7 +139,17 @@ <h5 class="card-header">Dimensions</h5>
<th scope="row">Outer Depth</th>
<td>
{% if object.outer_depth %}
<span>{{ object.outer_depth }} {{ object.get_outer_unit_display }}</span>
{{ object.outer_depth }} {{ object.get_outer_unit_display }}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
</tr>
<tr>
<th scope="row">Mounting Depth</th>
<td>
{% if object.mounting_depth %}
{{ object.mounting_depth }} Millimeters
{% else %}
{{ ''|placeholder }}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/rack_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h5 class="offset-sm-3">Dimensions</h5>
<div class="form-text">Unit</div>
</div>
</div>
{% render_field form.mounting_depth %}
{% render_field form.desc_units %}
</div>
<div class="field-group my-5">
Expand Down

0 comments on commit 72898d2

Please sign in to comment.