Closes #9832: Add mounting_depth field to rack model

This commit is contained in:
jeremystretch 2022-10-27 10:17:20 -04:00 committed by Jeremy Stretch
parent dbe66596f9
commit d773f4e62a
12 changed files with 64 additions and 12 deletions

View File

@ -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).

View File

@ -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

View File

@ -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',
]

View File

@ -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):

View File

@ -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'
)

View File

@ -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):

View File

@ -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",

View File

@ -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),
),
]

View File

@ -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:

View File

@ -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',

View File

@ -129,7 +129,7 @@
<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 %}
@ -139,7 +139,17 @@
<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 %}

View File

@ -55,6 +55,7 @@
<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">