From 02ffc2ddeed9483de6e765f7f5b4205ce10ea2b3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 30 Sep 2022 09:09:21 -0700 Subject: [PATCH 01/15] 10491 improve error message for ProtectedError on contact assignment --- netbox/tenancy/models/contacts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/tenancy/models/contacts.py b/netbox/tenancy/models/contacts.py index 41881f853..1dba814a6 100644 --- a/netbox/tenancy/models/contacts.py +++ b/netbox/tenancy/models/contacts.py @@ -163,8 +163,8 @@ class ContactAssignment(WebhooksMixin, ChangeLoggedModel): def __str__(self): if self.priority: - return f"{self.contact} ({self.get_priority_display()})" - return str(self.contact) + return f"{self.contact} ({self.get_priority_display()}) -> {self.object}" + return str(f"{self.contact} -> {self.object}") def get_absolute_url(self): return reverse('tenancy:contact', args=[self.contact.pk]) From 9ef24d3f43022f61044756741f40e095e9290bc1 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 10:39:03 -0400 Subject: [PATCH 02/15] Fixes #10513: Disable the reassignment of a module to a new device --- docs/release-notes/version-3.3.md | 1 + netbox/dcim/forms/models.py | 1 + netbox/dcim/models/devices.py | 8 ++++++++ netbox/dcim/tests/test_views.py | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index e91e825f5..2c2db9e47 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -16,6 +16,7 @@ * [#10461](https://github.com/netbox-community/netbox/issues/10461) - Enable filtering by read-only custom fields in the UI * [#10470](https://github.com/netbox-community/netbox/issues/10470) - Omit read-only custom fields from CSV import forms * [#10480](https://github.com/netbox-community/netbox/issues/10480) - Cable trace SVG links should not force a new window +* [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device --- diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py index b33023ece..1f1c869a5 100644 --- a/netbox/dcim/forms/models.py +++ b/netbox/dcim/forms/models.py @@ -679,6 +679,7 @@ class ModuleForm(NetBoxModelForm): super().__init__(*args, **kwargs) if self.instance.pk: + self.fields['device'].disabled = True self.fields['replicate_components'].initial = False self.fields['replicate_components'].disabled = True self.fields['adopt_components'].initial = False diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py index ccf4613bf..4c542341e 100644 --- a/netbox/dcim/models/devices.py +++ b/netbox/dcim/models/devices.py @@ -987,6 +987,14 @@ class Module(NetBoxModel, ConfigContextModel): def get_absolute_url(self): return reverse('dcim:module', args=[self.pk]) + def clean(self): + super().clean() + + if self.module_bay.device != self.device: + raise ValidationError( + f"Module must be installed within a module bay belonging to the assigned device ({self.device})." + ) + def save(self, *args, **kwargs): is_new = self.pk is None diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 50b36e36d..db3495521 100644 --- a/netbox/dcim/tests/test_views.py +++ b/netbox/dcim/tests/test_views.py @@ -1778,10 +1778,12 @@ class ModuleTestCase( ModuleBay(device=devices[0], name='Module Bay 2'), ModuleBay(device=devices[0], name='Module Bay 3'), ModuleBay(device=devices[0], name='Module Bay 4'), + ModuleBay(device=devices[0], name='Module Bay 5'), ModuleBay(device=devices[1], name='Module Bay 1'), ModuleBay(device=devices[1], name='Module Bay 2'), ModuleBay(device=devices[1], name='Module Bay 3'), ModuleBay(device=devices[1], name='Module Bay 4'), + ModuleBay(device=devices[1], name='Module Bay 5'), ) ModuleBay.objects.bulk_create(module_bays) @@ -1795,7 +1797,7 @@ class ModuleTestCase( tags = create_tags('Alpha', 'Bravo', 'Charlie') cls.form_data = { - 'device': devices[1].pk, + 'device': devices[0].pk, 'module_bay': module_bays[3].pk, 'module_type': module_types[0].pk, 'serial': 'A', @@ -1867,7 +1869,6 @@ class ModuleTestCase( self.assertIsNone(interface.module) # Create a module with adopted components - form_data['module_bay'] = ModuleBay.objects.filter(device=device).first() form_data['module_type'] = module_type form_data['replicate_components'] = False form_data['adopt_components'] = True From 0b6a3898fe0970b77928c9cf99588af8c7f2dc4a Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Mon, 3 Oct 2022 10:55:05 -0700 Subject: [PATCH 03/15] 8424 device location (#10544) * 8424 fix merge * 8424 fix merge * 8424 fix merge * 8424 fix merge --- netbox/dcim/views.py | 1 + netbox/templates/dcim/device.html | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 7a6aecc8e..5930d6b2d 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1616,6 +1616,7 @@ class DeviceView(generic.ObjectView): return { 'services': services, 'vc_members': vc_members, + 'svg_extra': f'highlight=id:{instance.pk}' } diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 253d905f2..d800658a5 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -7,7 +7,7 @@ {% block content %}
-
+
Device @@ -153,7 +153,7 @@ {% include 'inc/panels/comments.html' %} {% plugin_left_page object %}
-
+
Management
@@ -286,6 +286,22 @@
{% include 'inc/panels/contacts.html' %} {% include 'inc/panels/image_attachments.html' %} + {% if object.rack and object.position %} +
+
+
+

Front

+ {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='front' extra_params=svg_extra %} +
+
+
+
+

Rear

+ {% include 'dcim/inc/rack_elevation.html' with object=object.rack face='rear' extra_params=svg_extra %} +
+
+
+ {% endif %} {% plugin_right_page object %}
From cf062b5b6aeb1f496f2a0670090c8349efa8fc73 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 13:56:46 -0400 Subject: [PATCH 04/15] Closes #10346: Document how to access plugin config parameters --- docs/plugins/development/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/plugins/development/index.md b/docs/plugins/development/index.md index 98db9e0bb..a2f3b8ce9 100644 --- a/docs/plugins/development/index.md +++ b/docs/plugins/development/index.md @@ -112,6 +112,14 @@ NetBox looks for the `config` variable within a plugin's `__init__.py` to load i All required settings must be configured by the user. If a configuration parameter is listed in both `required_settings` and `default_settings`, the default setting will be ignored. +!!! tip "Accessing Config Parameters" + Plugin configuration parameters can be accessed in `settings.PLUGINS_CONFIG`, mapped by plugin name. For example: + + ```python + from django.conf import settings + settings.PLUGINS_CONFIG['myplugin']['verbose_name'] + ``` + ## Create setup.py `setup.py` is the [setup script](https://docs.python.org/3.8/distutils/setupscript.html) used to package and install our plugin once it's finished. The primary function of this script is to call the setuptools library's `setup()` function to create a Python distribution package. We can pass a number of keyword arguments to control the package creation as well as to provide metadata about the plugin. An example `setup.py` is below: From aabee05a6ab02adcf008e51a3b71c52d5ce1685b Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 13:58:04 -0400 Subject: [PATCH 05/15] Changelog for #8424, #10491 --- docs/release-notes/version-3.3.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 2c2db9e47..897cd7f38 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -4,6 +4,7 @@ ### Enhancements +* [#8424](https://github.com/netbox-community/netbox/issues/8424) - Include rack elevation under device view * [#10465](https://github.com/netbox-community/netbox/issues/10465) - Improve formatting of device heights and rack positions ### Bug Fixes @@ -16,6 +17,7 @@ * [#10461](https://github.com/netbox-community/netbox/issues/10461) - Enable filtering by read-only custom fields in the UI * [#10470](https://github.com/netbox-community/netbox/issues/10470) - Omit read-only custom fields from CSV import forms * [#10480](https://github.com/netbox-community/netbox/issues/10480) - Cable trace SVG links should not force a new window +* [#10491](https://github.com/netbox-community/netbox/issues/10491) - Clarify representation of blocking contact assignments during contact deletion * [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device --- From d1efbf662005aeed91fa21fa26e34de3e307bb50 Mon Sep 17 00:00:00 2001 From: PieterL75 <74899468+PieterL75@users.noreply.github.com> Date: Mon, 3 Oct 2022 20:32:01 +0200 Subject: [PATCH 06/15] Issue10352 removegetvariables (#10475) * Add javascript to disable empty form fields * add js cleanGetUrl * use addEventListener submit * use addEventListener * update collectstatics * Use FormData to remove empty fields * optimeze ts-ignore * update ts-ignore comment * oneline of ts-ignore * one line of ts-ingnore * fix tsc errors by adding types (as per kkthxbye) Co-authored-by: Pieter Lambrecht --- netbox/project-static/dist/netbox.js | Bin 374422 -> 374623 bytes netbox/project-static/dist/netbox.js.map | Bin 344131 -> 344325 bytes netbox/project-static/src/netbox.ts | 14 ++++++++++++++ 3 files changed, 14 insertions(+) diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 6d0aa15358c6a96b7df28bd75793d2fd96670267..fe7a7e56901cbd2a09c93c5ff269ded0f07d8d84 100644 GIT binary patch delta 237 zcmW-au}T9$6h%?97Gm11*DaPA2&1JCrVtei3mdJ(V#vNt0yB5w+gU+GwAeooOzjt# zLhy6^0{sPjvAMqF`>lTPk^R0OHjzU+mQ;6+3qlc_B0&>OpfroM zN%3m2AU<|2DQ#_ec6wP>6}`M&F7M3ln|JP5~@n+?ler*G*7*9!_qOEOSX-LsT7HUGb*&xK1_YVass}N* z=j?RA&U&WonMoj*S`%Iwr#~(lW33PYaz&s9*lK%LjXp){AWjUP&r?aB5p705aPoXt G#p4HLC_O9y delta 28 jcmZo|5Ry*;zDq0{sd2iA!Ij=c#` diff --git a/netbox/project-static/src/netbox.ts b/netbox/project-static/src/netbox.ts index c178a2dbd..9bf23410d 100644 --- a/netbox/project-static/src/netbox.ts +++ b/netbox/project-static/src/netbox.ts @@ -37,6 +37,20 @@ function initDocument(): void { } function initWindow(): void { + + const documentForms = document.forms + for (var documentForm of documentForms) { + if (documentForm.method.toUpperCase() == 'GET') { + // @ts-ignore: Our version of typescript seems to be too old for FormDataEvent + documentForm.addEventListener('formdata', function(event: FormDataEvent) { + let formData: FormData = event.formData; + for (let [name, value] of Array.from(formData.entries())) { + if (value === '') formData.delete(name); + } + }); + } + } + const contentContainer = document.querySelector('.content-container'); if (contentContainer !== null) { // Focus the content container for accessible navigation. From 7feb86fe55db68827fcae8c81ce6668eb1bfd0dd Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 15:03:28 -0400 Subject: [PATCH 07/15] Changelog for #10352 --- docs/release-notes/version-3.3.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 897cd7f38..378eb993e 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -5,6 +5,7 @@ ### Enhancements * [#8424](https://github.com/netbox-community/netbox/issues/8424) - Include rack elevation under device view +* [#10352](https://github.com/netbox-community/netbox/issues/10352) - Omit extraneous URL query attributes during search * [#10465](https://github.com/netbox-community/netbox/issues/10465) - Improve formatting of device heights and rack positions ### Bug Fixes From 7712b81ab9f634c4281023588aba284041dda5a3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 15:35:45 -0400 Subject: [PATCH 08/15] Fixes #10517: Automatically inherit site assignment from cluster when creating a virtual machine --- docs/release-notes/version-3.3.md | 1 + netbox/virtualization/models.py | 4 +++- netbox/virtualization/tests/test_models.py | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 378eb993e..6d2bb3b5c 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -20,6 +20,7 @@ * [#10480](https://github.com/netbox-community/netbox/issues/10480) - Cable trace SVG links should not force a new window * [#10491](https://github.com/netbox-community/netbox/issues/10491) - Clarify representation of blocking contact assignments during contact deletion * [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device +* [#10517](https://github.com/netbox-community/netbox/issues/10517) - Automatically inherit site assignment from cluster when creating a virtual machine --- diff --git a/netbox/virtualization/models.py b/netbox/virtualization/models.py index abad57f88..69376d9c5 100644 --- a/netbox/virtualization/models.py +++ b/netbox/virtualization/models.py @@ -347,10 +347,12 @@ class VirtualMachine(NetBoxModel, ConfigContextModel): }) # Validate site for cluster & device - if self.cluster and self.cluster.site != self.site: + if self.cluster and self.site and self.cluster.site != self.site: raise ValidationError({ 'cluster': f'The selected cluster ({self.cluster} is not assigned to this site ({self.site}).' }) + elif self.cluster: + self.site = self.cluster.site if self.device and self.device.site != self.site: raise ValidationError({ 'device': f'The selected device ({self.device} is not assigned to this site ({self.site}).' diff --git a/netbox/virtualization/tests/test_models.py b/netbox/virtualization/tests/test_models.py index df5816efa..e916486b0 100644 --- a/netbox/virtualization/tests/test_models.py +++ b/netbox/virtualization/tests/test_models.py @@ -68,6 +68,7 @@ class VirtualMachineTestCase(TestCase): with self.assertRaises(ValidationError): VirtualMachine(name='vm1', site=sites[0], cluster=clusters[1]).full_clean() - # VM with cluster site but no direct site should fail - with self.assertRaises(ValidationError): - VirtualMachine(name='vm1', site=None, cluster=clusters[0]).full_clean() + # VM with cluster site but no direct site should have its site set automatically + vm = VirtualMachine(name='vm1', site=None, cluster=clusters[0]) + vm.full_clean() + self.assertEqual(vm.site, sites[0]) From eef5cefb5d8a8c5f60a015c09f0051a76b0d12ca Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 3 Oct 2022 16:11:24 -0400 Subject: [PATCH 09/15] Fixes #10460: Restore missing connection details for device components --- docs/release-notes/version-3.3.md | 1 + netbox/templates/dcim/consoleport.html | 104 ++++++------------ netbox/templates/dcim/consoleserverport.html | 104 ++++++------------ .../templates/dcim/inc/cabletermination.html | 14 --- .../dcim/inc/connection_endpoints.html | 36 ++++++ netbox/templates/dcim/interface.html | 86 +-------------- netbox/templates/dcim/powerfeed.html | 88 ++++----------- netbox/templates/dcim/poweroutlet.html | 82 ++++---------- netbox/templates/dcim/powerport.html | 102 ++++++----------- 9 files changed, 178 insertions(+), 439 deletions(-) delete mode 100644 netbox/templates/dcim/inc/cabletermination.html create mode 100644 netbox/templates/dcim/inc/connection_endpoints.html diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 6d2bb3b5c..4b7b76270 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -15,6 +15,7 @@ * [#10435](https://github.com/netbox-community/netbox/issues/10435) - Fix exception when filtering VLANs by virtual machine with no cluster assigned * [#10439](https://github.com/netbox-community/netbox/issues/10439) - Fix form widget styling for DeviceType airflow field * [#10445](https://github.com/netbox-community/netbox/issues/10445) - Avoid rounding virtual machine memory values +* [#10460](https://github.com/netbox-community/netbox/issues/10460) - Restore missing connection details for device components * [#10461](https://github.com/netbox-community/netbox/issues/10461) - Enable filtering by read-only custom fields in the UI * [#10470](https://github.com/netbox-community/netbox/issues/10470) - Omit read-only custom fields from CSV import forms * [#10480](https://github.com/netbox-community/netbox/issues/10480) - Cable trace SVG links should not force a new window diff --git a/netbox/templates/dcim/consoleport.html b/netbox/templates/dcim/consoleport.html index 39ffbf552..ad4f15c9d 100644 --- a/netbox/templates/dcim/consoleport.html +++ b/netbox/templates/dcim/consoleport.html @@ -54,80 +54,40 @@ {% plugin_left_page object %}
-
-
- Connection -
-
- {% if object.mark_connected %} - Marked as connected - {% elif object.cable %} - - - - - - {% if object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device{{ object.connected_endpoint.device|linkify }}
Name{{ object.connected_endpoint|linkify:"name" }}
Type{{ object.connected_endpoint.get_type_display|placeholder }}
Description{{ object.connected_endpoint.description|placeholder }}
Path Status - {% if object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
- {% else %} -
- Not Connected - {% if perms.dcim.add_cable %} - - {% endif %} -
- {% endif %} +
+
Connection
+
+ {% if object.mark_connected %} + Marked as connected + {% elif object.cable %} + {% include 'dcim/inc/connection_endpoints.html' %} + {% else %} +
+ Not Connected + {% if perms.dcim.add_cable %} + + {% endif %}
+ {% endif %}
- {% include 'dcim/inc/panels/inventory_items.html' %} - {% plugin_right_page object %} +
+ {% include 'dcim/inc/panels/inventory_items.html' %} + {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/consoleserverport.html b/netbox/templates/dcim/consoleserverport.html index 642e758a3..a543cd5ff 100644 --- a/netbox/templates/dcim/consoleserverport.html +++ b/netbox/templates/dcim/consoleserverport.html @@ -54,82 +54,40 @@ {% plugin_left_page object %}
-
-
- Connection -
-
- {% if object.mark_connected %} - Marked as connected - {% elif object.cable %} - - - - - - {% if object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device - {{ object.connected_endpoint.device|linkify }} -
Name{{ object.connected_endpoint|linkify:"name" }}
Type{{ object.connected_endpoint.get_type_display|placeholder }}
Description{{ object.connected_endpoint.description|placeholder }}
Path Status - {% if object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
- {% else %} -
- Not Connected - {% if perms.dcim.add_cable %} - - {% endif %} +
+
Connection
+
+ {% if object.mark_connected %} + Marked as connected + {% elif object.cable %} + {% include 'dcim/inc/connection_endpoints.html' %} + {% else %} +
+ Not Connected + {% if perms.dcim.add_cable %} + - {% endif %} + {% endif %}
+ {% endif %}
- {% include 'dcim/inc/panels/inventory_items.html' %} - {% plugin_right_page object %} +
+ {% include 'dcim/inc/panels/inventory_items.html' %} + {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/inc/cabletermination.html b/netbox/templates/dcim/inc/cabletermination.html deleted file mode 100644 index c7fa7918a..000000000 --- a/netbox/templates/dcim/inc/cabletermination.html +++ /dev/null @@ -1,14 +0,0 @@ - - {% if termination.parent_object.provider %} - - - {{ termination.parent_object.provider }} - {{ termination.parent_object }} - - {% else %} - {{ termination.parent_object|linkify }} - {% endif %} - - - {{ termination|linkify }} - diff --git a/netbox/templates/dcim/inc/connection_endpoints.html b/netbox/templates/dcim/inc/connection_endpoints.html new file mode 100644 index 000000000..fb994a492 --- /dev/null +++ b/netbox/templates/dcim/inc/connection_endpoints.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + +
Cable + {{ object.cable|linkify }} + + + +
Path Status + {% if object.path.is_complete and object.path.is_active %} + Reachable + {% else %} + Not Reachable + {% endif %} +
Path Endpoints + {% for endpoint in object.connected_endpoints %} + {% if endpoint.parent_object %} + {{ endpoint.parent_object|linkify }} + + {% endif %} + {{ endpoint|linkify }} + {% if not forloop.last %}
{% endif %} + {% empty %} + {{ ''|placeholder }} + {% endfor %} +
diff --git a/netbox/templates/dcim/interface.html b/netbox/templates/dcim/interface.html index 1216f3e88..887433d7b 100644 --- a/netbox/templates/dcim/interface.html +++ b/netbox/templates/dcim/interface.html @@ -144,89 +144,7 @@ Marked as Connected
{% elif object.cable %} - - {% if object.connected_endpoint.device %} - - - - {% endif %} - - - - - {% if object.connected_endpoint.device %} - {% with iface=object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% endwith %} - {% elif object.connected_endpoint.circuit %} - {% with ct=object.connected_endpoint %} - - - - - - - - - - - - - {% endwith %} - {% endif %} - - - - -
- {% if object.connected_endpoint.enabled %} - Enabled - {% else %} - Disabled - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device{{ iface.device|linkify }}
Name{{ iface|linkify:"name" }}
Type{{ iface.get_type_display }}
LAG{{ iface.lag|linkify|placeholder }}
Description{{ iface.description|placeholder }}
MTU{{ iface.mtu|placeholder }}
MAC Address{{ iface.mac_address|placeholder }}
802.1Q Mode{{ iface.get_mode_display }}
Provider{{ ct.circuit.provider|linkify }}
Circuit{{ ct.circuit|linkify }}
Side{{ ct.term_side }}
Path Status - {% if object.path.is_complete and object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
+ {% include 'dcim/inc/connection_endpoints.html' %} {% elif object.wireless_link %} @@ -238,7 +156,7 @@ - {% with peer_interface=object.connected_endpoint %} + {% with peer_interface=object.link_peers.0 %} diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index 584454df8..adb779ce3 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -100,73 +100,33 @@ {% plugin_left_page object %}
-
-
- Connection -
-
- {% if object.mark_connected %} -
- Marked as connected -
- {% elif object.cable %} -
Device {{ peer_interface.device|linkify }}
- - - - - {% if object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device{{ object.connected_endpoint.device|linkify }}
Name{{ object.connected_endpoint|linkify:"name" }}
Type{{ object.connected_endpoint.get_type_display|placeholder }}
Description{{ object.connected_endpoint.description|placeholder }}
Path Status - {% if object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
- {% else %} -
- Not connected -
- {% endif %} +
+
Connection
+
+ {% if object.mark_connected %} +
+ Marked as connected
- {% if not object.mark_connected and not object.cable %} - - {% include 'inc/panels/comments.html' %} - {% plugin_right_page object %} + {% if not object.mark_connected and not object.cable %} + + {% endif %} +
+ {% include 'inc/panels/comments.html' %} + {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/poweroutlet.html b/netbox/templates/dcim/poweroutlet.html index 26f4a07f8..fb6de8ddb 100644 --- a/netbox/templates/dcim/poweroutlet.html +++ b/netbox/templates/dcim/poweroutlet.html @@ -58,69 +58,29 @@ {% plugin_left_page object %}
-
-
- Connection -
-
- {% if object.mark_connected %} -
- Marked as Connected -
- {% elif object.cable %} - - - - - - {% if object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device{{ object.connected_endpoint.device|linkify }}
Name{{ object.connected_endpoint|linkify:"name" }}
Type{{ object.connected_endpoint.get_type_display|placeholder }}
Description{{ object.connected_endpoint.description|placeholder }}
Path Status - {% if object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
- {% else %} -
- Not Connected - {% if perms.dcim.add_cable %} - - Connect - - {% endif %} -
- {% endif %} +
+
Connection
+
+ {% if object.mark_connected %} +
+ Marked as Connected
+ {% elif object.cable %} + {% include 'dcim/inc/connection_endpoints.html' %} + {% else %} +
+ Not Connected + {% if perms.dcim.add_cable %} + + Connect + + {% endif %} +
+ {% endif %}
- {% include 'dcim/inc/panels/inventory_items.html' %} - {% plugin_right_page object %} +
+ {% include 'dcim/inc/panels/inventory_items.html' %} + {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/powerport.html b/netbox/templates/dcim/powerport.html index c5eccbf14..c552c2398 100644 --- a/netbox/templates/dcim/powerport.html +++ b/netbox/templates/dcim/powerport.html @@ -58,79 +58,39 @@ {% plugin_left_page object %}
-
-
- Connection -
-
- {% if object.mark_connected %} -
- Marked as Connected -
- {% elif object.cable %} - - - - - - {% if object.connected_endpoint %} - - - - - - - - - - - - - - - - - - - - - {% endif %} -
Cable - {{ object.cable|linkify }} - - - -
Device{{ object.connected_endpoint.device|linkify }}
Name{{ object.connected_endpoint|linkify:"name" }}
Type{{ object.connected_endpoint.get_type_display|placeholder }}
Description{{ object.connected_endpoint.description|placeholder }}
Path Status - {% if object.path.is_active %} - Reachable - {% else %} - Not Reachable - {% endif %} -
- {% else %} -
- Not Connected - {% if perms.dcim.add_cable %} - - - - - {% endif %} -
- {% endif %} +
+
Connection
+
+ {% if object.mark_connected %} +
+ Marked as Connected
+ {% elif object.cable %} + {% include 'dcim/inc/connection_endpoints.html' %} + {% else %} +
+ Not Connected + {% if perms.dcim.add_cable %} + + + + + {% endif %} +
+ {% endif %}
- {% include 'dcim/inc/panels/inventory_items.html' %} - {% plugin_right_page object %} +
+ {% include 'dcim/inc/panels/inventory_items.html' %} + {% plugin_right_page object %}
From 53f5f4603735980c18c1890217b6e9e442f8fe19 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 4 Oct 2022 14:36:14 -0400 Subject: [PATCH 10/15] #10460: Fix PowerFeed details --- netbox/templates/dcim/powerfeed.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index adb779ce3..54ac96bab 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -41,8 +41,8 @@ Connected Device - {% if object.connected_endpoint %} - {{ object.connected_endpoint.device|linkify }} ({{ object.connected_endpoint }}) + {% if object.connected_endpoints %} + {{ object.connected_endpoints.0.device|linkify }} ({{ object.connected_endpoints.0|linkify:"name" }}) {% else %} {{ ''|placeholder }} {% endif %} @@ -50,7 +50,7 @@ Utilization (Allocated) - {% with utilization=object.connected_endpoint.get_power_draw %} + {% with utilization=object.connected_endpoints.0.get_power_draw %} {% if utilization %} {{ utilization.allocated }}VA / {{ object.available_power }}VA From fec8d1bc2f1459018d248a277ee69853f1a2beb4 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 4 Oct 2022 15:26:52 -0400 Subject: [PATCH 11/15] Fixes #10423: Enforce object type validation when creating journal entries --- docs/release-notes/version-3.3.md | 1 + netbox/extras/models/models.py | 8 ++++++++ netbox/netbox/models/__init__.py | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 4b7b76270..92d93f5c8 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -12,6 +12,7 @@ * [#9497](https://github.com/netbox-community/netbox/issues/9497) - Adjust non-racked device filter on site and location detailed view * [#10408](https://github.com/netbox-community/netbox/issues/10408) - Fix validation when attempting to add redundant contact assignments +* [#10423](https://github.com/netbox-community/netbox/issues/10423) - Enforce object type validation when creating journal entries * [#10435](https://github.com/netbox-community/netbox/issues/10435) - Fix exception when filtering VLANs by virtual machine with no cluster assigned * [#10439](https://github.com/netbox-community/netbox/issues/10439) - Fix form widget styling for DeviceType airflow field * [#10445](https://github.com/netbox-community/netbox/issues/10445) - Avoid rounding virtual machine memory values diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index 0df34c146..1bcc91d62 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -463,6 +463,14 @@ class JournalEntry(CustomFieldsMixin, CustomLinksMixin, TagsMixin, WebhooksMixin def get_absolute_url(self): return reverse('extras:journalentry', args=[self.pk]) + def clean(self): + super().clean() + + # Prevent the creation of journal entries on unsupported models + permitted_types = ContentType.objects.filter(FeatureQuery('journaling').get_query()) + if self.assigned_object_type not in permitted_types: + raise ValidationError(f"Journaling is not supported for this object type ({self.assigned_object_type}).") + def get_kind_color(self): return JournalEntryKindChoices.colors.get(self.kind) diff --git a/netbox/netbox/models/__init__.py b/netbox/netbox/models/__init__.py index aefb733b4..1385dd585 100644 --- a/netbox/netbox/models/__init__.py +++ b/netbox/netbox/models/__init__.py @@ -20,7 +20,6 @@ class NetBoxFeatureSet( CustomLinksMixin, CustomValidationMixin, ExportTemplatesMixin, - JournalingMixin, TagsMixin, WebhooksMixin ): @@ -51,7 +50,7 @@ class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, models.Model) abstract = True -class NetBoxModel(CloningMixin, NetBoxFeatureSet, models.Model): +class NetBoxModel(CloningMixin, JournalingMixin, NetBoxFeatureSet, models.Model): """ Primary models represent real objects within the infrastructure being modeled. """ From 03946f2ca868dc21d8819f4db29107822b2a2c74 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 4 Oct 2022 15:46:55 -0400 Subject: [PATCH 12/15] Fixes #10559: Permit the pinning of a VM to a particular device within a cluster which has no site assignment --- docs/release-notes/version-3.3.md | 1 + netbox/templates/virtualization/cluster.html | 4 ++-- netbox/virtualization/models.py | 8 ++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 92d93f5c8..d4dcc83d6 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -23,6 +23,7 @@ * [#10491](https://github.com/netbox-community/netbox/issues/10491) - Clarify representation of blocking contact assignments during contact deletion * [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device * [#10517](https://github.com/netbox-community/netbox/issues/10517) - Automatically inherit site assignment from cluster when creating a virtual machine +* [#10559](https://github.com/netbox-community/netbox/issues/10559) - Permit the pinning of a VM to a particular device within a cluster which has no site assignment --- diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index 8acbb61f4..bf7c8a69a 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -21,7 +21,7 @@ Group - {{ object.group|linkify }} + {{ object.group|linkify|placeholder }} Tenant @@ -34,7 +34,7 @@ Site - {{ object.site|linkify }} + {{ object.site|linkify|placeholder }} Virtual Machines diff --git a/netbox/virtualization/models.py b/netbox/virtualization/models.py index 69376d9c5..b07e51790 100644 --- a/netbox/virtualization/models.py +++ b/netbox/virtualization/models.py @@ -349,14 +349,10 @@ class VirtualMachine(NetBoxModel, ConfigContextModel): # Validate site for cluster & device if self.cluster and self.site and self.cluster.site != self.site: raise ValidationError({ - 'cluster': f'The selected cluster ({self.cluster} is not assigned to this site ({self.site}).' + 'cluster': f'The selected cluster ({self.cluster}) is not assigned to this site ({self.site}).' }) elif self.cluster: self.site = self.cluster.site - if self.device and self.device.site != self.site: - raise ValidationError({ - 'device': f'The selected device ({self.device} is not assigned to this site ({self.site}).' - }) # Validate assigned cluster device if self.device and not self.cluster: @@ -365,7 +361,7 @@ class VirtualMachine(NetBoxModel, ConfigContextModel): }) if self.device and self.device not in self.cluster.devices.all(): raise ValidationError({ - 'device': f'The selected device ({self.device} is not assigned to this cluster ({self.cluster}).' + 'device': f'The selected device ({self.device}) is not assigned to this cluster ({self.cluster}).' }) # Validate primary IP addresses From bdefd8ea8c91d2d31fefd2133312451896e27042 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 5 Oct 2022 08:13:33 -0400 Subject: [PATCH 13/15] Fixes #10562: Correct URL for contacts table tags column --- docs/release-notes/version-3.3.md | 1 + netbox/tenancy/tables/tenants.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index d4dcc83d6..9314cc8eb 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -24,6 +24,7 @@ * [#10513](https://github.com/netbox-community/netbox/issues/10513) - Disable the reassignment of a module to a new device * [#10517](https://github.com/netbox-community/netbox/issues/10517) - Automatically inherit site assignment from cluster when creating a virtual machine * [#10559](https://github.com/netbox-community/netbox/issues/10559) - Permit the pinning of a VM to a particular device within a cluster which has no site assignment +* [#10562](https://github.com/netbox-community/netbox/issues/10562) - Correct URL for contacts table tags column --- diff --git a/netbox/tenancy/tables/tenants.py b/netbox/tenancy/tables/tenants.py index 8f18423be..f18f1db09 100644 --- a/netbox/tenancy/tables/tenants.py +++ b/netbox/tenancy/tables/tenants.py @@ -42,7 +42,7 @@ class TenantTable(NetBoxTable): linkify_item=True ) tags = columns.TagColumn( - url_name='tenancy:tenant_list' + url_name='tenancy:contact_list' ) class Meta(NetBoxTable.Meta): From 1c69bfaf2c8aa39f0764281d694accdc84e36883 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 5 Oct 2022 09:47:55 -0400 Subject: [PATCH 14/15] Release v3.3.5 --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yaml | 2 +- base_requirements.txt | 5 +++-- docs/release-notes/version-3.3.md | 2 +- netbox/netbox/settings.py | 2 +- requirements.txt | 18 +++++++++--------- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 11b7e9aff..907ad6cf7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.3.4 + placeholder: v3.3.5 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index bc00a3921..3cd9bc4ee 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.3.4 + placeholder: v3.3.5 validations: required: true - type: dropdown diff --git a/base_requirements.txt b/base_requirements.txt index 363f97b31..cc8695d6c 100644 --- a/base_requirements.txt +++ b/base_requirements.txt @@ -68,7 +68,7 @@ drf-yasg[validation] # Django wrapper for Graphene (GraphQL support) # https://github.com/graphql-python/graphene-django -graphene_django +graphene_django<3.0 # WSGI HTTP server # https://gunicorn.org/ @@ -80,7 +80,8 @@ Jinja2 # Simple markup language for rendering HTML # https://github.com/Python-Markdown/markdown -Markdown +# mkdocs currently requires Markdown v3.3 +Markdown<3.4 # File inclusion plugin for Python-Markdown # https://github.com/cmacmackin/markdown-include diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 9314cc8eb..daf542022 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -1,6 +1,6 @@ # NetBox v3.3 -## v3.3.5 (FUTURE) +## v3.3.5 (2022-10-05) ### Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index cfd4d231c..03e7eacc0 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ django.utils.encoding.force_text = force_str # Environment setup # -VERSION = '3.3.5-dev' +VERSION = '3.3.5' # Hostname HOSTNAME = platform.node() diff --git a/requirements.txt b/requirements.txt index f868c4f0d..ead32eeae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ bleach==5.0.1 -Django==4.0.7 +Django==4.0.8 django-cors-headers==3.13.0 -django-debug-toolbar==3.6.0 +django-debug-toolbar==3.7.0 django-filter==22.1 django-graphiql-debug-toolbar==0.2.0 -django-mptt==0.13.4 +django-mptt==0.14 django-pglocks==1.0.4 django-prometheus==2.2.0 django-redis==5.2.0 @@ -13,24 +13,24 @@ django-rq==2.5.1 django-tables2==2.4.1 django-taggit==3.0.0 django-timezone-field==5.0 -djangorestframework==3.13.1 -drf-yasg[validation]==1.21.3 +djangorestframework==3.14.0 +drf-yasg[validation]==1.21.4 graphene-django==2.15.0 gunicorn==20.1.0 Jinja2==3.1.2 -Markdown==3.4.1 -mkdocs-material==8.5.1 +Markdown==3.3.7 +mkdocs-material==8.5.6 mkdocstrings[python-legacy]==0.19.0 netaddr==0.8.0 Pillow==9.2.0 psycopg2-binary==2.9.3 PyYAML==6.0 -sentry-sdk==1.9.8 +sentry-sdk==1.9.10 social-auth-app-django==5.0.0 social-auth-core==4.3.0 svgwrite==1.4.3 tablib==3.2.1 -tzdata==2022.2 +tzdata==2022.4 # Workaround for #7401 jsonschema==3.2.0 From ae90ad1fb73817458bff7cf2e6504d4a132dd0c9 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 5 Oct 2022 10:13:02 -0400 Subject: [PATCH 15/15] PRVB --- docs/release-notes/version-3.3.md | 4 ++++ netbox/netbox/settings.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index daf542022..2e25a9589 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -1,5 +1,9 @@ # NetBox v3.3 +## v3.3.6 (FUTURE) + +--- + ## v3.3.5 (2022-10-05) ### Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 03e7eacc0..ebe3e7d5c 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ django.utils.encoding.force_text = force_str # Environment setup # -VERSION = '3.3.5' +VERSION = '3.3.6-dev' # Hostname HOSTNAME = platform.node()