- - {{ device.site }}
- {% if device.rack %}
- - Racks
- - {{ device.rack }}
- {% endif %}
+ - Devices
+ - {{ device.site }}
{% if device.parent_bay %}
- {{ device.parent_bay.device }}
- {{ device.parent_bay }}
@@ -101,7 +98,7 @@
-
- Inventory {{ device.inventoryitems.unrestricted.count }}
+ Inventory {{ device.inventoryitems.count }}
{% if perms.dcim.napalm_read_device %}
@@ -151,8 +148,10 @@
{% if device.rack %}
{% if device.rack.group %}
- {{ device.rack.group }}
-
+ {% for group in device.rack.group.get_ancestors %}
+ {{ group }}
+ {% endfor %}
+ {{ device.rack.group }}
{% endif %}
{{ device.rack }}
{% else %}
diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html
index 5ead0ac4f..4cf3b9018 100644
--- a/netbox/templates/dcim/rack.html
+++ b/netbox/templates/dcim/rack.html
@@ -11,6 +11,12 @@
- Racks
- {{ rack.site }}
+ {% if rack.group %}
+ {% for group in rack.group.get_ancestors %}
+ - {{ group }}
+ {% endfor %}
+ - {{ rack.group }}
+ {% endif %}
- {{ rack }}
@@ -87,7 +93,10 @@
| Group |
{% if rack.group %}
- {{ rack.group }}
+ {% for group in rack.group.get_ancestors %}
+ {{ group }}
+ {% endfor %}
+ {{ rack.group }}
{% else %}
None
{% endif %}
diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html
index d6c21bf92..f5823f721 100644
--- a/netbox/templates/dcim/site.html
+++ b/netbox/templates/dcim/site.html
@@ -12,7 +12,7 @@
- Sites
{% if site.region %}
- {% for region in site.region.get_ancestors.unrestricted %}
+ {% for region in site.region.get_ancestors %}
- {{ region }}
{% endfor %}
- {{ site.region }}
@@ -86,7 +86,7 @@
Region |
{% if site.region %}
- {% for region in site.region.get_ancestors.unrestricted %}
+ {% for region in site.region.get_ancestors %}
{{ region }}
{% endfor %}
From e983f44fd327961dbacbe183eacdcdf45a73521a Mon Sep 17 00:00:00 2001
From: Jeremy Stretch
Date: Wed, 16 Sep 2020 12:53:11 -0400
Subject: [PATCH 59/73] Closes #5128: Increase maximum rear port positions from
64 to 1024
---
docs/models/dcim/rearporttemplate.md | 2 +-
docs/release-notes/version-2.9.md | 1 +
netbox/dcim/constants.py | 2 +-
.../migrations/0116_rearport_max_positions.py | 34 +++++++++++++++++++
.../dcim/models/device_component_templates.py | 10 ++++--
netbox/dcim/models/device_components.py | 10 ++++--
6 files changed, 53 insertions(+), 6 deletions(-)
create mode 100644 netbox/dcim/migrations/0116_rearport_max_positions.py
diff --git a/docs/models/dcim/rearporttemplate.md b/docs/models/dcim/rearporttemplate.md
index 71d9a200b..01ba02ac0 100644
--- a/docs/models/dcim/rearporttemplate.md
+++ b/docs/models/dcim/rearporttemplate.md
@@ -1,3 +1,3 @@
## Rear Port Templates
-A template for a rear-facing pass-through port that will be created on all instantiations of the parent device type. Each rear port may have a physical type and one or more front port templates assigned to it. The number of positions associated with a rear port determines how many front ports can be assigned to it (the maximum is 64).
+A template for a rear-facing pass-through port that will be created on all instantiations of the parent device type. Each rear port may have a physical type and one or more front port templates assigned to it. The number of positions associated with a rear port determines how many front ports can be assigned to it (the maximum is 1024).
diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md
index fd7a99ff0..5472188ba 100644
--- a/docs/release-notes/version-2.9.md
+++ b/docs/release-notes/version-2.9.md
@@ -5,6 +5,7 @@
### Enhancements
* [#1755](https://github.com/netbox-community/netbox/issues/1755) - Toggle order in which rack elevations are displayed
+* [#5128](https://github.com/netbox-community/netbox/issues/5128) - Increase maximum rear port positions from 64 to 1024
* [#5134](https://github.com/netbox-community/netbox/issues/5134) - Display full hierarchy in breadcrumbs for sites/racks
### Bug Fixes
diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py
index 66768515c..961c458e0 100644
--- a/netbox/dcim/constants.py
+++ b/netbox/dcim/constants.py
@@ -18,7 +18,7 @@ RACK_ELEVATION_LEGEND_WIDTH_DEFAULT = 30
#
REARPORT_POSITIONS_MIN = 1
-REARPORT_POSITIONS_MAX = 64
+REARPORT_POSITIONS_MAX = 1024
#
diff --git a/netbox/dcim/migrations/0116_rearport_max_positions.py b/netbox/dcim/migrations/0116_rearport_max_positions.py
new file mode 100644
index 000000000..a03f4e3d5
--- /dev/null
+++ b/netbox/dcim/migrations/0116_rearport_max_positions.py
@@ -0,0 +1,34 @@
+# Generated by Django 3.1 on 2020-09-16 16:51
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('dcim', '0115_rackreservation_order'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='frontport',
+ name='rear_port_position',
+ field=models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1024)]),
+ ),
+ migrations.AlterField(
+ model_name='frontporttemplate',
+ name='rear_port_position',
+ field=models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1024)]),
+ ),
+ migrations.AlterField(
+ model_name='rearport',
+ name='positions',
+ field=models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1024)]),
+ ),
+ migrations.AlterField(
+ model_name='rearporttemplate',
+ name='positions',
+ field=models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1024)]),
+ ),
+ ]
diff --git a/netbox/dcim/models/device_component_templates.py b/netbox/dcim/models/device_component_templates.py
index 492fe3762..7a94b3e1b 100644
--- a/netbox/dcim/models/device_component_templates.py
+++ b/netbox/dcim/models/device_component_templates.py
@@ -264,7 +264,10 @@ class FrontPortTemplate(ComponentTemplateModel):
)
rear_port_position = models.PositiveSmallIntegerField(
default=1,
- validators=[MinValueValidator(1), MaxValueValidator(64)]
+ validators=[
+ MinValueValidator(REARPORT_POSITIONS_MIN),
+ MaxValueValidator(REARPORT_POSITIONS_MAX)
+ ]
)
class Meta:
@@ -315,7 +318,10 @@ class RearPortTemplate(ComponentTemplateModel):
)
positions = models.PositiveSmallIntegerField(
default=1,
- validators=[MinValueValidator(1), MaxValueValidator(64)]
+ validators=[
+ MinValueValidator(REARPORT_POSITIONS_MIN),
+ MaxValueValidator(REARPORT_POSITIONS_MAX)
+ ]
)
class Meta:
diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py
index d7e077a16..18ca5cf3e 100644
--- a/netbox/dcim/models/device_components.py
+++ b/netbox/dcim/models/device_components.py
@@ -809,7 +809,10 @@ class FrontPort(CableTermination, ComponentModel):
)
rear_port_position = models.PositiveSmallIntegerField(
default=1,
- validators=[MinValueValidator(1), MaxValueValidator(64)]
+ validators=[
+ MinValueValidator(REARPORT_POSITIONS_MIN),
+ MaxValueValidator(REARPORT_POSITIONS_MAX)
+ ]
)
tags = TaggableManager(through=TaggedItem)
@@ -864,7 +867,10 @@ class RearPort(CableTermination, ComponentModel):
)
positions = models.PositiveSmallIntegerField(
default=1,
- validators=[MinValueValidator(1), MaxValueValidator(64)]
+ validators=[
+ MinValueValidator(REARPORT_POSITIONS_MIN),
+ MaxValueValidator(REARPORT_POSITIONS_MAX)
+ ]
)
tags = TaggableManager(through=TaggedItem)
From 43f1fbf5b33035bf972cce5e011b1ac1ecc3ba72 Mon Sep 17 00:00:00 2001
From: Jeremy Stretch
Date: Wed, 16 Sep 2020 13:07:55 -0400
Subject: [PATCH 60/73] Fixes #5136: Fix exception when bulk editing interface
802.1Q mode
---
docs/release-notes/version-2.9.md | 1 +
netbox/utilities/views.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md
index 5472188ba..6e3919542 100644
--- a/docs/release-notes/version-2.9.md
+++ b/docs/release-notes/version-2.9.md
@@ -17,6 +17,7 @@
* [#5111](https://github.com/netbox-community/netbox/issues/5111) - Allow use of tuples when specifying ObjectVar `query_params`
* [#5118](https://github.com/netbox-community/netbox/issues/5118) - Specifying an empty list of tags should clear assigned tags (REST API)
* [#5133](https://github.com/netbox-community/netbox/issues/5133) - Fix disassociation of an IP address from a VM interface
+* [#5136](https://github.com/netbox-community/netbox/issues/5136) - Fix exception when bulk editing interface 802.1Q mode
---
diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py
index 079068648..5ae839eff 100644
--- a/netbox/utilities/views.py
+++ b/netbox/utilities/views.py
@@ -945,7 +945,7 @@ class BulkEditView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
# ManyToManyFields
elif isinstance(model_field, ManyToManyField):
- if form.cleaned_data[name].count() > 0:
+ if form.cleaned_data[name]:
getattr(obj, name).set(form.cleaned_data[name])
# Normal fields
elif form.cleaned_data[name] not in (None, ''):
From 2bc524a2ee82355395d2768e1ba3def55d7d13b0 Mon Sep 17 00:00:00 2001
From: Jeremy Stretch
Date: Wed, 16 Sep 2020 14:25:07 -0400
Subject: [PATCH 61/73] Standardize usage of BooleanColumn
---
netbox/ipam/tables.py | 2 +-
netbox/utilities/tables.py | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py
index d7a64f7db..afdeb5515 100644
--- a/netbox/ipam/tables.py
+++ b/netbox/ipam/tables.py
@@ -415,7 +415,7 @@ class IPAddressDetailTable(IPAddressTable):
tenant = tables.TemplateColumn(
template_code=COL_TENANT
)
- assigned = tables.BooleanColumn(
+ assigned = BooleanColumn(
accessor='assigned_object_id',
verbose_name='Assigned'
)
diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py
index 6df6b2e26..d1f17ff1e 100644
--- a/netbox/utilities/tables.py
+++ b/netbox/utilities/tables.py
@@ -114,12 +114,12 @@ class BooleanColumn(tables.Column):
character.
"""
def render(self, value):
- if value is True:
+ if value:
rendered = ''
- elif value is False:
- rendered = ''
- else:
+ elif value is None:
rendered = '—'
+ else:
+ rendered = ''
return mark_safe(rendered)
From 12402f4c309c8385256fd0c148d074a2ef3c27a6 Mon Sep 17 00:00:00 2001
From: Jeremy Stretch
Date: Mon, 21 Sep 2020 15:14:44 -0400
Subject: [PATCH 62/73] Fixes #5156: Add missing "add" button to rack
reservations list
---
docs/release-notes/version-2.9.md | 1 +
netbox/dcim/views.py | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md
index 6e3919542..e6f1e6d5f 100644
--- a/docs/release-notes/version-2.9.md
+++ b/docs/release-notes/version-2.9.md
@@ -18,6 +18,7 @@
* [#5118](https://github.com/netbox-community/netbox/issues/5118) - Specifying an empty list of tags should clear assigned tags (REST API)
* [#5133](https://github.com/netbox-community/netbox/issues/5133) - Fix disassociation of an IP address from a VM interface
* [#5136](https://github.com/netbox-community/netbox/issues/5136) - Fix exception when bulk editing interface 802.1Q mode
+* [#5156](https://github.com/netbox-community/netbox/issues/5156) - Add missing "add" button to rack reservations list
---
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index ab84ba64b..77ca0b534 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -414,7 +414,6 @@ class RackReservationListView(ObjectListView):
filterset = filters.RackReservationFilterSet
filterset_form = forms.RackReservationFilterForm
table = tables.RackReservationTable
- action_buttons = ('export',)
class RackReservationView(ObjectView):
From d540728f50e583f3bbf52a21efcbcea94be9b8dd Mon Sep 17 00:00:00 2001
From: Jeremy Stretch
Date: Mon, 21 Sep 2020 15:26:32 -0400
Subject: [PATCH 63/73] Closes #5149: Add rack group field to device edit form
---
docs/release-notes/version-2.9.md | 1 +
netbox/dcim/forms.py | 11 ++++++++++-
netbox/templates/dcim/device_edit.html | 1 +
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/docs/release-notes/version-2.9.md b/docs/release-notes/version-2.9.md
index e6f1e6d5f..7defe5317 100644
--- a/docs/release-notes/version-2.9.md
+++ b/docs/release-notes/version-2.9.md
@@ -7,6 +7,7 @@
* [#1755](https://github.com/netbox-community/netbox/issues/1755) - Toggle order in which rack elevations are displayed
* [#5128](https://github.com/netbox-community/netbox/issues/5128) - Increase maximum rear port positions from 64 to 1024
* [#5134](https://github.com/netbox-community/netbox/issues/5134) - Display full hierarchy in breadcrumbs for sites/racks
+* [#5149](https://github.com/netbox-community/netbox/issues/5149) - Add rack group field to device edit form
### Bug Fixes
diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py
index 43f77de51..d3c385121 100644
--- a/netbox/dcim/forms.py
+++ b/netbox/dcim/forms.py
@@ -1680,12 +1680,21 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
'region_id': '$region'
}
)
+ rack_group = DynamicModelChoiceField(
+ queryset=RackGroup.objects.all(),
+ required=False,
+ display_field='display_name',
+ query_params={
+ 'site_id': '$site'
+ }
+ )
rack = DynamicModelChoiceField(
queryset=Rack.objects.all(),
required=False,
display_field='display_name',
query_params={
- 'site_id': '$site'
+ 'site_id': '$site',
+ 'group_id': '$rack_group',
}
)
position = forms.TypedChoiceField(
diff --git a/netbox/templates/dcim/device_edit.html b/netbox/templates/dcim/device_edit.html
index 0f1ac2886..f1b68d063 100644
--- a/netbox/templates/dcim/device_edit.html
+++ b/netbox/templates/dcim/device_edit.html
@@ -23,6 +23,7 @@
{% render_field form.region %}
{% render_field form.site %}
+ {% render_field form.rack_group %}
{% render_field form.rack %}
{% if obj.device_type.is_child_device and obj.parent_bay %}
| |