From 18332bdbf10d8d79d2110a6a18cc80efbb8dc67d Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 26 Oct 2022 10:23:50 -0400 Subject: [PATCH 01/34] 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 ffb831e9d41..8b8bd006018 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.7 (FUTURE) + +--- + ## v3.3.6 (2022-10-26) ### Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index cb26652b9fb..02e80b6cd9c 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ # Environment setup # -VERSION = '3.3.6' +VERSION = '3.3.7-dev' # Hostname HOSTNAME = platform.node() From edb522022848b7a00a08dbe4206e16526a1e585a Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 26 Oct 2022 15:11:44 -0400 Subject: [PATCH 02/34] Changelog for #10666 (missed in v3.3.6) --- 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 8b8bd006018..6af0586b459 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -23,6 +23,7 @@ * [#10643](https://github.com/netbox-community/netbox/issues/10643) - Ensure consistent display of custom fields for all model forms * [#10646](https://github.com/netbox-community/netbox/issues/10646) - Fix filtering of power feed by power panel when connecting a cable * [#10655](https://github.com/netbox-community/netbox/issues/10655) - Correct display of assigned contacts in object tables +* [#10666](https://github.com/netbox-community/netbox/issues/10666) - Re-evaluate disabled LDAP user when processing API requests * [#10682](https://github.com/netbox-community/netbox/issues/10682) - Correct home view links to connection lists * [#10712](https://github.com/netbox-community/netbox/issues/10712) - Fix ModuleNotFoundError exception when generating API schema under Python 3.9+ * [#10716](https://github.com/netbox-community/netbox/issues/10716) - Add left/right page plugin content embeds for tag view From 8f4fa065f90b94f1a840331289677384fe4d6b3a Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 31 Oct 2022 09:18:50 -0700 Subject: [PATCH 03/34] 10770 fix social auth --- netbox/netbox/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 02e80b6cd9c..84c1944afea 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -501,7 +501,7 @@ def _setting(name, default=None): # Force usage of PostgreSQL's JSONB field for extra data SOCIAL_AUTH_JSONFIELD_ENABLED = True -SOCIAL_AUTH_CLEAN_USERNAME_FUNCTION = 'netbox.users.utils.clean_username' +SOCIAL_AUTH_CLEAN_USERNAME_FUNCTION = 'users.utils.clean_username' # # Django Prometheus From 867af61875538c8d305b26b622a7555be354c50a Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 28 Oct 2022 14:22:31 -0700 Subject: [PATCH 04/34] 10282 fix race condition in API IP creation --- netbox/ipam/api/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/netbox/ipam/api/views.py b/netbox/ipam/api/views.py index 9db3d7953b1..9ea38758d59 100644 --- a/netbox/ipam/api/views.py +++ b/netbox/ipam/api/views.py @@ -112,6 +112,18 @@ class IPAddressViewSet(NetBoxModelViewSet): serializer_class = serializers.IPAddressSerializer filterset_class = filtersets.IPAddressFilterSet + @advisory_lock(ADVISORY_LOCK_KEYS['available-ips']) + def create(self, request, *args, **kwargs): + return super().create(request, *args, **kwargs) + + @advisory_lock(ADVISORY_LOCK_KEYS['available-ips']) + def update(self, request, *args, **kwargs): + return super().update(request, *args, **kwargs) + + @advisory_lock(ADVISORY_LOCK_KEYS['available-ips']) + def destroy(self, request, *args, **kwargs): + return super().destroy(request, *args, **kwargs) + class FHRPGroupViewSet(NetBoxModelViewSet): queryset = FHRPGroup.objects.prefetch_related('ip_addresses', 'tags') From a25ee66150884f122c3c5e58ff97b355ca1119c2 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 31 Oct 2022 15:15:45 -0400 Subject: [PATCH 05/34] Changelog for #10282, #10770 --- docs/release-notes/version-3.3.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 6af0586b459..28fd9367d1f 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -2,6 +2,11 @@ ## v3.3.7 (FUTURE) +### Bug Fixes + +* [#10282](https://github.com/netbox-community/netbox/issues/10282) - Enforce advisory locks when allocating available IP addresses to prevent race conditions +* [#10770](https://github.com/netbox-community/netbox/issues/10282) - Fix social authentication for new users + --- ## v3.3.6 (2022-10-26) From 7990cfb078db1800d557bd06785239cfc84d8db0 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 1 Nov 2022 15:27:35 -0400 Subject: [PATCH 06/34] Fixes #10803: Fix exception when ordering contacts by number of assignments --- docs/release-notes/version-3.3.md | 1 + netbox/tenancy/views.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 28fd9367d1f..3a75166c33a 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -6,6 +6,7 @@ * [#10282](https://github.com/netbox-community/netbox/issues/10282) - Enforce advisory locks when allocating available IP addresses to prevent race conditions * [#10770](https://github.com/netbox-community/netbox/issues/10282) - Fix social authentication for new users +* [#10803](https://github.com/netbox-community/netbox/issues/10803) - Fix exception when ordering contacts by number of assignments --- diff --git a/netbox/tenancy/views.py b/netbox/tenancy/views.py index e582c15d112..d8b810ad9ca 100644 --- a/netbox/tenancy/views.py +++ b/netbox/tenancy/views.py @@ -188,6 +188,8 @@ def get_extra_context(self, request, instance): contacts = Contact.objects.restrict(request.user, 'view').filter( group=instance + ).annotate( + assignment_count=count_related(ContactAssignment, 'contact') ) contacts_table = tables.ContactTable(contacts, user=request.user, exclude=('group',)) contacts_table.configure(request) @@ -338,14 +340,18 @@ class ContactBulkImportView(generic.BulkImportView): class ContactBulkEditView(generic.BulkEditView): - queryset = Contact.objects.all() + queryset = Contact.objects.annotate( + assignment_count=count_related(ContactAssignment, 'contact') + ) filterset = filtersets.ContactFilterSet table = tables.ContactTable form = forms.ContactBulkEditForm class ContactBulkDeleteView(generic.BulkDeleteView): - queryset = Contact.objects.all() + queryset = Contact.objects.annotate( + assignment_count=count_related(ContactAssignment, 'contact') + ) filterset = filtersets.ContactFilterSet table = tables.ContactTable From aaf1ea52b769571991292211bb2ca477d557006c Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 1 Nov 2022 15:38:10 -0400 Subject: [PATCH 07/34] Fixes #10791: Permit nullifying VLAN group scope_type via REST API --- docs/release-notes/version-3.3.md | 1 + netbox/ipam/api/serializers.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 3a75166c33a..23c797dbf3f 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -6,6 +6,7 @@ * [#10282](https://github.com/netbox-community/netbox/issues/10282) - Enforce advisory locks when allocating available IP addresses to prevent race conditions * [#10770](https://github.com/netbox-community/netbox/issues/10282) - Fix social authentication for new users +* [#10791](https://github.com/netbox-community/netbox/issues/10791) - Permit nullifying VLAN group `scope_type` via REST API * [#10803](https://github.com/netbox-community/netbox/issues/10803) - Fix exception when ordering contacts by number of assignments --- diff --git a/netbox/ipam/api/serializers.py b/netbox/ipam/api/serializers.py index fa8b563e95d..eff39a41843 100644 --- a/netbox/ipam/api/serializers.py +++ b/netbox/ipam/api/serializers.py @@ -175,6 +175,7 @@ class VLANGroupSerializer(NetBoxModelSerializer): queryset=ContentType.objects.filter( model__in=VLANGROUP_SCOPE_TYPES ), + allow_null=True, required=False, default=None ) From aa7f04bf1b8200ef9c5b261cd642862229444d8f Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 1 Nov 2022 16:45:32 -0400 Subject: [PATCH 08/34] Fixes #10809: Permit nullifying site time_zone via REST API --- docs/release-notes/version-3.3.md | 1 + netbox/dcim/api/serializers.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 23c797dbf3f..754efcddf28 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -8,6 +8,7 @@ * [#10770](https://github.com/netbox-community/netbox/issues/10282) - Fix social authentication for new users * [#10791](https://github.com/netbox-community/netbox/issues/10791) - Permit nullifying VLAN group `scope_type` via REST API * [#10803](https://github.com/netbox-community/netbox/issues/10803) - Fix exception when ordering contacts by number of assignments +* [#10809](https://github.com/netbox-community/netbox/issues/10809) - Permit nullifying site `time_zone` via REST API --- diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 897ee4ca356..cb1edfe1fdc 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -130,7 +130,7 @@ class SiteSerializer(NetBoxModelSerializer): region = NestedRegionSerializer(required=False, allow_null=True) group = NestedSiteGroupSerializer(required=False, allow_null=True) tenant = NestedTenantSerializer(required=False, allow_null=True) - time_zone = TimeZoneSerializerField(required=False) + time_zone = TimeZoneSerializerField(required=False, allow_null=True) asns = SerializedPKRelatedField( queryset=ASN.objects.all(), serializer=NestedASNSerializer, From 4f5caa5ed27692fac07eda11f0d7bb6295fed08a Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 1 Nov 2022 16:48:40 -0400 Subject: [PATCH 09/34] Release v3.3.7 --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yaml | 2 +- docs/release-notes/version-3.3.md | 2 +- netbox/netbox/settings.py | 2 +- requirements.txt | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 56c14e96659..4de82d4e336 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.6 + placeholder: v3.3.7 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index bef1ce58714..5f0a17aa7c3 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.6 + placeholder: v3.3.7 validations: required: true - type: dropdown diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 754efcddf28..fe02827d6a1 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.7 (FUTURE) +## v3.3.7 (2022-11-01) ### Bug Fixes diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 84c1944afea..5241737223a 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ # Environment setup # -VERSION = '3.3.7-dev' +VERSION = '3.3.7' # Hostname HOSTNAME = platform.node() diff --git a/requirements.txt b/requirements.txt index bce015110b5..73abfa25937 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ Markdown==3.3.7 mkdocs-material==8.5.7 mkdocstrings[python-legacy]==0.19.0 netaddr==0.8.0 -Pillow==9.2.0 +Pillow==9.3.0 psycopg2-binary==2.9.5 PyYAML==6.0 sentry-sdk==1.10.1 @@ -30,7 +30,7 @@ social-auth-app-django==5.0.0 social-auth-core[openidconnect]==4.3.0 svgwrite==1.4.3 tablib==3.2.1 -tzdata==2022.5 +tzdata==2022.6 # Workaround for #7401 jsonschema==3.2.0 From 2af8891f70a02cc8991028348a4764c32cdfc2a2 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 1 Nov 2022 17:11:55 -0400 Subject: [PATCH 10/34] 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 fe02827d6a1..a693ec1e005 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.8 (FUTURE) + +--- + ## v3.3.7 (2022-11-01) ### Bug Fixes diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 5241737223a..e5a8b7dbd70 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ # Environment setup # -VERSION = '3.3.7' +VERSION = '3.3.8-dev' # Hostname HOSTNAME = platform.node() From 4ebcdd2b8f740acb74d6de28793986928f216cdf Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 3 Nov 2022 06:29:45 -0700 Subject: [PATCH 11/34] 8072 move js code from template to static file (#10824) --- netbox/netbox/settings.py | 1 + netbox/project-static/js/setmode.js | 72 +++++++++++++++++++++++++++ netbox/templates/base/base.html | 77 +++-------------------------- 3 files changed, 80 insertions(+), 70 deletions(-) create mode 100644 netbox/project-static/js/setmode.js diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index e5a8b7dbd70..c941f067270 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -407,6 +407,7 @@ def _setting(name, default=None): STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'project-static', 'dist'), os.path.join(BASE_DIR, 'project-static', 'img'), + os.path.join(BASE_DIR, 'project-static', 'js'), ('docs', os.path.join(BASE_DIR, 'project-static', 'docs')), # Prefix with /docs ) diff --git a/netbox/project-static/js/setmode.js b/netbox/project-static/js/setmode.js new file mode 100644 index 00000000000..8441a542f68 --- /dev/null +++ b/netbox/project-static/js/setmode.js @@ -0,0 +1,72 @@ +/** + * Set the color mode on the `` element and in local storage. + * + * @param mode {"dark" | "light"} NetBox Color Mode. + * @param inferred {boolean} Value is inferred from browser/system preference. + */ +function setMode(mode, inferred) { + document.documentElement.setAttribute("data-netbox-color-mode", mode); + localStorage.setItem("netbox-color-mode", mode); + localStorage.setItem("netbox-color-mode-inferred", inferred); +} +/** + * Determine the best initial color mode to use prior to rendering. + */ +function initMode() { + try { + // Browser prefers dark color scheme. + var preferDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + // Browser prefers light color scheme. + var preferLight = window.matchMedia("(prefers-color-scheme: light)").matches; + // Client NetBox color-mode override. + var clientMode = localStorage.getItem("netbox-color-mode"); + // NetBox server-rendered value. + var serverMode = document.documentElement.getAttribute("data-netbox-color-mode"); + // Color mode is inferred from browser/system preference and not deterministically set by + // the client or server. + var inferred = JSON.parse(localStorage.getItem("netbox-color-mode-inferred")); + + if (inferred === true && (serverMode === "light" || serverMode === "dark")) { + // The color mode was previously inferred from browser/system preference, but + // the server now has a value, so we should use the server's value. + return setMode(serverMode, false); + } + if (clientMode === null && (serverMode === "light" || serverMode === "dark")) { + // If the client mode is not set but the server mode is, use the server mode. + return setMode(serverMode, false); + } + if (clientMode !== null && serverMode === "unset") { + // The color mode has been set, deterministically or otherwise, and the server + // has no preference or has not been set. Use the client mode, but allow it to + /// be overridden by the server if/when a server value exists. + return setMode(clientMode, true); + } + if ( + clientMode !== null && + (serverMode === "light" || serverMode === "dark") && + clientMode !== serverMode + ) { + // If the client mode is set and is different than the server mode (which is also set), + // use the client mode over the server mode, as it should be more recent. + return setMode(clientMode, false); + } + if (clientMode === serverMode) { + // If the client and server modes match, use that value. + return setMode(clientMode, false); + } + if (preferDark && serverMode === "unset") { + // If the server mode is not set but the browser prefers dark mode, use dark mode, but + // allow it to be overridden by an explicit preference. + return setMode("dark", true); + } + if (preferLight && serverMode === "unset") { + // If the server mode is not set but the browser prefers light mode, use light mode, + // but allow it to be overridden by an explicit preference. + return setMode("light", true); + } + } catch (error) { + // In the event of an error, log it to the console and set the mode to light mode. + console.error(error); + } + return setMode("light", true); +}; diff --git a/netbox/templates/base/base.html b/netbox/templates/base/base.html index 8ba47dde36f..138a92b6d56 100644 --- a/netbox/templates/base/base.html +++ b/netbox/templates/base/base.html @@ -26,78 +26,15 @@ {# Page title #} {% block title %}Home{% endblock %} | NetBox + + From 271d524687728f803f8a55c918f77f87a93fed8f Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Nov 2022 16:52:46 -0700 Subject: [PATCH 12/34] 10709 add AzureAD Tenant Oauth2 --- netbox/netbox/authentication.py | 1 + 1 file changed, 1 insertion(+) diff --git a/netbox/netbox/authentication.py b/netbox/netbox/authentication.py index a7e56e2799e..89d71b8152a 100644 --- a/netbox/netbox/authentication.py +++ b/netbox/netbox/authentication.py @@ -24,6 +24,7 @@ 'azuread-oauth2': ('Microsoft Azure AD', 'microsoft'), 'azuread-b2c-oauth2': ('Microsoft Azure AD', 'microsoft'), 'azuread-tenant-oauth2': ('Microsoft Azure AD', 'microsoft'), + 'azuread-v2-tenant-oauth2': ('Microsoft Azure AD', 'microsoft'), 'bitbucket': ('BitBucket', 'bitbucket'), 'bitbucket-oauth2': ('BitBucket', 'bitbucket'), 'digitalocean': ('DigitalOcean', 'digital-ocean'), From 43da786016f5bfb1f58026d620106fc24aa38ecb Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 4 Nov 2022 11:00:35 -0700 Subject: [PATCH 13/34] 10829 fix top edit selected button --- netbox/templates/generic/object_list.html | 95 ++++++++++++----------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/netbox/templates/generic/object_list.html b/netbox/templates/generic/object_list.html index 60eba6097e8..272c1598eaa 100644 --- a/netbox/templates/generic/object_list.html +++ b/netbox/templates/generic/object_list.html @@ -67,64 +67,65 @@ {% applied_filters filter_form request.GET %} {% endif %} - {# "Select all" form #} - {% if table.paginator.num_pages > 1 %} -
-
- {% csrf_token %} -
-
- {% if 'bulk_edit' in actions %} - {% bulk_edit_button model query_params=request.GET %} - {% endif %} - {% if 'bulk_delete' in actions %} - {% bulk_delete_button model query_params=request.GET %} - {% endif %} -
-
- - + + {% csrf_token %} + {# "Select all" form #} + {% if table.paginator.num_pages > 1 %} +
+
+
+
+ {% if 'bulk_edit' in actions %} + {% bulk_edit_button model query_params=request.GET %} + {% endif %} + {% if 'bulk_delete' in actions %} + {% bulk_delete_button model query_params=request.GET %} + {% endif %} +
+
+ + +
- -
- {% endif %} +
+ {% endif %} - {# Object table controls #} - {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %} + {# Object table controls #} + {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %} -
- {% csrf_token %} - +
+ {% csrf_token %} + - {# Object table #} + {# Object table #} - {% if prerequisite_model %} - {% include 'inc/missing_prerequisites.html' %} - {% endif %} + {% if prerequisite_model %} + {% include 'inc/missing_prerequisites.html' %} + {% endif %} -
-
- {% include 'htmx/table.html' %} +
+
+ {% include 'htmx/table.html' %} +
-
- {# Form buttons #} -
-
- {% block bulk_buttons %} - {% if 'bulk_edit' in actions %} - {% bulk_edit_button model query_params=request.GET %} - {% endif %} - {% if 'bulk_delete' in actions %} - {% bulk_delete_button model query_params=request.GET %} - {% endif %} - {% endblock %} + {# Form buttons #} +
+
+ {% block bulk_buttons %} + {% if 'bulk_edit' in actions %} + {% bulk_edit_button model query_params=request.GET %} + {% endif %} + {% if 'bulk_delete' in actions %} + {% bulk_delete_button model query_params=request.GET %} + {% endif %} + {% endblock %} +
-
From 93e241e8f3e1b3002eaf14615863eda16500dca1 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 4 Nov 2022 16:56:52 -0400 Subject: [PATCH 14/34] Changelog for #10709, #10829 --- docs/release-notes/version-3.3.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index a693ec1e005..4b058c6ca4b 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -2,6 +2,11 @@ ## v3.3.8 (FUTURE) +### Bug Fixes + +* [#10709](https://github.com/netbox-community/netbox/issues/10709) - Correct UI display for `azuread-v2-tenant-oauth2` SSO backend +* [#10829](https://github.com/netbox-community/netbox/issues/10829) - Fix bulk edit/delete buttons ad top of object lists + --- ## v3.3.7 (2022-11-01) From 33d8f8e5e782d789aa35b329229115b94d818611 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 10 Nov 2022 13:19:43 -0800 Subject: [PATCH 15/34] 10874 remove link to contact roles (#10879) --- netbox/templates/tenancy/contactrole.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/templates/tenancy/contactrole.html b/netbox/templates/tenancy/contactrole.html index 37ef5e936ad..85b78578a0e 100644 --- a/netbox/templates/tenancy/contactrole.html +++ b/netbox/templates/tenancy/contactrole.html @@ -25,7 +25,7 @@
Contact Role
Assignments - {{ assignment_count }} + {{ assignment_count }} From c854c290160e0a02181d0e36f7bbc941ddbb8ded Mon Sep 17 00:00:00 2001 From: Brian Candler Date: Thu, 10 Nov 2022 21:23:05 +0000 Subject: [PATCH 16/34] Fix broken cookie paths when BASE_PATH is set (introduced in #10706) (#10856) Fixes #10837 --- netbox/netbox/settings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index c941f067270..4ff440c469e 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -81,11 +81,11 @@ BASE_PATH = getattr(configuration, 'BASE_PATH', '') if BASE_PATH: BASE_PATH = BASE_PATH.strip('/') + '/' # Enforce trailing slash only +CSRF_COOKIE_PATH = LANGUAGE_COOKIE_PATH = SESSION_COOKIE_PATH = f'/{BASE_PATH.rstrip("/")}' CORS_ORIGIN_ALLOW_ALL = getattr(configuration, 'CORS_ORIGIN_ALLOW_ALL', False) CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIST', []) CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', []) CSRF_COOKIE_NAME = getattr(configuration, 'CSRF_COOKIE_NAME', 'csrftoken') -CSRF_COOKIE_PATH = BASE_PATH or '/' CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', []) DATE_FORMAT = getattr(configuration, 'DATE_FORMAT', 'N j, Y') DATETIME_FORMAT = getattr(configuration, 'DATETIME_FORMAT', 'N j, Y g:i a') @@ -130,8 +130,6 @@ SENTRY_TAGS = getattr(configuration, 'SENTRY_TAGS', {}) SESSION_FILE_PATH = getattr(configuration, 'SESSION_FILE_PATH', None) SESSION_COOKIE_NAME = getattr(configuration, 'SESSION_COOKIE_NAME', 'sessionid') -SESSION_COOKIE_PATH = BASE_PATH or '/' -LANGUAGE_COOKIE_PATH = BASE_PATH or '/' SHORT_DATE_FORMAT = getattr(configuration, 'SHORT_DATE_FORMAT', 'Y-m-d') SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H:i') SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s') From 3d1501e8fdd8e051a4574fe890c504122aa0e6f1 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 10 Nov 2022 16:33:34 -0500 Subject: [PATCH 17/34] Changelog for #10837, #10874 --- 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 4b058c6ca4b..2df69c32ce1 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -6,6 +6,8 @@ * [#10709](https://github.com/netbox-community/netbox/issues/10709) - Correct UI display for `azuread-v2-tenant-oauth2` SSO backend * [#10829](https://github.com/netbox-community/netbox/issues/10829) - Fix bulk edit/delete buttons ad top of object lists +* [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set +* [#10874](https://github.com/netbox-community/netbox/issues/10874) - Remove erroneous link for contact assignment count --- From d59d23e3083b0c8c8e10b20553042f450798c639 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 10 Nov 2022 16:47:17 -0500 Subject: [PATCH 18/34] Fixes #10881: Fix dark mode coloring for data on device status page --- docs/release-notes/version-3.3.md | 1 + netbox/templates/dcim/device/status.html | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 2df69c32ce1..f23b03a25c9 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -8,6 +8,7 @@ * [#10829](https://github.com/netbox-community/netbox/issues/10829) - Fix bulk edit/delete buttons ad top of object lists * [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set * [#10874](https://github.com/netbox-community/netbox/issues/10874) - Remove erroneous link for contact assignment count +* [#10881](https://github.com/netbox-community/netbox/issues/10881) - Fix dark mode coloring for data on device status page --- diff --git a/netbox/templates/dcim/device/status.html b/netbox/templates/dcim/device/status.html index a668ebf1e8e..51dd7d27e2a 100644 --- a/netbox/templates/dcim/device/status.html +++ b/netbox/templates/dcim/device/status.html @@ -64,19 +64,19 @@
Device Facts
Environment
- + - + - + - + - + From 5729a06348afb5640146f2e7a7c1452ca3f1fede Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 14 Nov 2022 09:20:02 -0500 Subject: [PATCH 19/34] Fixes #10910: Fix cable creation links on power port view --- docs/release-notes/version-3.3.md | 1 + netbox/templates/dcim/powerport.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index f23b03a25c9..89e6909ff05 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -9,6 +9,7 @@ * [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set * [#10874](https://github.com/netbox-community/netbox/issues/10874) - Remove erroneous link for contact assignment count * [#10881](https://github.com/netbox-community/netbox/issues/10881) - Fix dark mode coloring for data on device status page +* [#10910](https://github.com/netbox-community/netbox/issues/10910) - Fix cable creation links on power port view --- diff --git a/netbox/templates/dcim/powerport.html b/netbox/templates/dcim/powerport.html index 18814a4286e..476ee44d39d 100644 --- a/netbox/templates/dcim/powerport.html +++ b/netbox/templates/dcim/powerport.html @@ -77,10 +77,10 @@
Connection
From d97113119812962ea89192d9acd33b0eb7c4b988 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 14 Nov 2022 09:24:12 -0500 Subject: [PATCH 20/34] Fixes #10897: Fix form widget styling on FHRP group form --- docs/release-notes/version-3.3.md | 1 + netbox/ipam/forms/models.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 89e6909ff05..aa396f475b9 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -9,6 +9,7 @@ * [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set * [#10874](https://github.com/netbox-community/netbox/issues/10874) - Remove erroneous link for contact assignment count * [#10881](https://github.com/netbox-community/netbox/issues/10881) - Fix dark mode coloring for data on device status page +* [#10897](https://github.com/netbox-community/netbox/issues/10897) - Fix form widget styling on FHRP group form * [#10910](https://github.com/netbox-community/netbox/issues/10910) - Fix cable creation links on power port view --- diff --git a/netbox/ipam/forms/models.py b/netbox/ipam/forms/models.py index 1986b159086..95723f80d93 100644 --- a/netbox/ipam/forms/models.py +++ b/netbox/ipam/forms/models.py @@ -549,6 +549,11 @@ class Meta: fields = ( 'protocol', 'group_id', 'auth_type', 'auth_key', 'description', 'ip_vrf', 'ip_address', 'ip_status', 'tags', ) + widgets = { + 'protocol': StaticSelect(), + 'auth_type': StaticSelect(), + 'ip_status': StaticSelect(), + } def save(self, *args, **kwargs): instance = super().save(*args, **kwargs) From 84005093581f51da59344e86b79c0b72d3b437af Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 14 Nov 2022 09:28:03 -0500 Subject: [PATCH 21/34] Fixes #10891: Populate tag selection list for service filter form --- docs/release-notes/version-3.3.md | 1 + netbox/ipam/forms/filtersets.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index aa396f475b9..df84c8de469 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -9,6 +9,7 @@ * [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set * [#10874](https://github.com/netbox-community/netbox/issues/10874) - Remove erroneous link for contact assignment count * [#10881](https://github.com/netbox-community/netbox/issues/10881) - Fix dark mode coloring for data on device status page +* [#10891](https://github.com/netbox-community/netbox/issues/10891) - Populate tag selection list for service filter form * [#10897](https://github.com/netbox-community/netbox/issues/10897) - Fix form widget styling on FHRP group form * [#10910](https://github.com/netbox-community/netbox/issues/10910) - Fix cable creation links on power port view diff --git a/netbox/ipam/forms/filtersets.py b/netbox/ipam/forms/filtersets.py index ecf63b49f36..9566e69a9a5 100644 --- a/netbox/ipam/forms/filtersets.py +++ b/netbox/ipam/forms/filtersets.py @@ -478,6 +478,7 @@ class ServiceTemplateFilterForm(NetBoxModelFilterSetForm): class ServiceFilterForm(ServiceTemplateFilterForm): model = Service + tag = TagFilterField(model) class L2VPNFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm): From cd8943144bec52ff608ddad3db5d0155832a4a23 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 2 Nov 2022 17:40:43 -0400 Subject: [PATCH 22/34] Use context vars instead of thread-local storage for change logging --- netbox/extras/context_managers.py | 15 +++++++-------- netbox/extras/signals.py | 29 ++++++++++++++--------------- netbox/netbox/__init__.py | 3 --- netbox/netbox/context.py | 10 ++++++++++ netbox/netbox/request_context.py | 9 --------- 5 files changed, 31 insertions(+), 35 deletions(-) create mode 100644 netbox/netbox/context.py delete mode 100644 netbox/netbox/request_context.py diff --git a/netbox/extras/context_managers.py b/netbox/extras/context_managers.py index 9f73fe9c39e..d4aeb83642b 100644 --- a/netbox/extras/context_managers.py +++ b/netbox/extras/context_managers.py @@ -3,8 +3,7 @@ from django.db.models.signals import m2m_changed, pre_delete, post_save from extras.signals import clear_webhooks, clear_webhook_queue, handle_changed_object, handle_deleted_object -from netbox import thread_locals -from netbox.request_context import set_request +from netbox.context import current_request, webhooks_queue from .webhooks import flush_webhooks @@ -16,8 +15,8 @@ def change_logging(request): :param request: WSGIRequest object with a unique `id` set """ - set_request(request) - thread_locals.webhook_queue = [] + current_request.set(request) + webhooks_queue.set([]) # Connect our receivers to the post_save and post_delete signals. post_save.connect(handle_changed_object, dispatch_uid='handle_changed_object') @@ -35,8 +34,8 @@ def change_logging(request): clear_webhooks.disconnect(clear_webhook_queue, dispatch_uid='clear_webhook_queue') # Flush queued webhooks to RQ - flush_webhooks(thread_locals.webhook_queue) - del thread_locals.webhook_queue + flush_webhooks(webhooks_queue.get()) - # Clear the request from thread-local storage - set_request(None) + # Clear context vars + current_request.set(None) + webhooks_queue.set([]) diff --git a/netbox/extras/signals.py b/netbox/extras/signals.py index aff350cc4f3..8854d631408 100644 --- a/netbox/extras/signals.py +++ b/netbox/extras/signals.py @@ -7,9 +7,8 @@ from django_prometheus.models import model_deletes, model_inserts, model_updates from extras.validators import CustomValidator -from netbox import thread_locals from netbox.config import get_config -from netbox.request_context import get_request +from netbox.context import current_request, webhooks_queue from netbox.signals import post_clean from .choices import ObjectChangeActionChoices from .models import ConfigRevision, CustomField, ObjectChange @@ -30,7 +29,7 @@ def handle_changed_object(sender, instance, **kwargs): if not hasattr(instance, 'to_objectchange'): return - request = get_request() + request = current_request.get() m2m_changed = False def is_same_object(instance, webhook_data): @@ -69,13 +68,14 @@ def is_same_object(instance, webhook_data): objectchange.save() # If this is an M2M change, update the previously queued webhook (from post_save) - webhook_queue = thread_locals.webhook_queue - if m2m_changed and webhook_queue and is_same_object(instance, webhook_queue[-1]): + queue = webhooks_queue.get() + if m2m_changed and queue and is_same_object(instance, queue[-1]): instance.refresh_from_db() # Ensure that we're working with fresh M2M assignments - webhook_queue[-1]['data'] = serialize_for_webhook(instance) - webhook_queue[-1]['snapshots']['postchange'] = get_snapshots(instance, action)['postchange'] + queue[-1]['data'] = serialize_for_webhook(instance) + queue[-1]['snapshots']['postchange'] = get_snapshots(instance, action)['postchange'] else: - enqueue_object(webhook_queue, instance, request.user, request.id, action) + enqueue_object(queue, instance, request.user, request.id, action) + webhooks_queue.set(queue) # Increment metric counters if action == ObjectChangeActionChoices.ACTION_CREATE: @@ -91,7 +91,7 @@ def handle_deleted_object(sender, instance, **kwargs): if not hasattr(instance, 'to_objectchange'): return - request = get_request() + request = current_request.get() # Record an ObjectChange if applicable if hasattr(instance, 'to_objectchange'): @@ -101,8 +101,9 @@ def handle_deleted_object(sender, instance, **kwargs): objectchange.save() # Enqueue webhooks - webhook_queue = thread_locals.webhook_queue - enqueue_object(webhook_queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE) + queue = webhooks_queue.get() + enqueue_object(queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE) + webhooks_queue.set(queue) # Increment metric counters model_deletes.labels(instance._meta.model_name).inc() @@ -113,10 +114,8 @@ def clear_webhook_queue(sender, **kwargs): Delete any queued webhooks (e.g. because of an aborted bulk transaction) """ logger = logging.getLogger('webhooks') - webhook_queue = thread_locals.webhook_queue - - logger.info(f"Clearing {len(webhook_queue)} queued webhooks ({sender})") - webhook_queue.clear() + logger.info(f"Clearing {len(webhooks_queue.get())} queued webhooks ({sender})") + webhooks_queue.set([]) # diff --git a/netbox/netbox/__init__.py b/netbox/netbox/__init__.py index 5cf43102523..e69de29bb2d 100644 --- a/netbox/netbox/__init__.py +++ b/netbox/netbox/__init__.py @@ -1,3 +0,0 @@ -import threading - -thread_locals = threading.local() diff --git a/netbox/netbox/context.py b/netbox/netbox/context.py new file mode 100644 index 00000000000..02c6fccaea8 --- /dev/null +++ b/netbox/netbox/context.py @@ -0,0 +1,10 @@ +from contextvars import ContextVar + +__all__ = ( + 'current_request', + 'webhooks_queue', +) + + +current_request = ContextVar('current_request') +webhooks_queue = ContextVar('webhooks_queue') diff --git a/netbox/netbox/request_context.py b/netbox/netbox/request_context.py deleted file mode 100644 index 41e8283e8c5..00000000000 --- a/netbox/netbox/request_context.py +++ /dev/null @@ -1,9 +0,0 @@ -from netbox import thread_locals - - -def set_request(request): - thread_locals.request = request - - -def get_request(): - return getattr(thread_locals, 'request', None) From 4a95cfd1c4435e6eda01745fe06d902c25d2493e Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 3 Nov 2022 08:48:13 -0400 Subject: [PATCH 23/34] Permanently connect change logging & webhook receivers --- netbox/extras/context_managers.py | 16 --------------- netbox/extras/signals.py | 34 +++++++++++++++++++++++-------- netbox/netbox/context.py | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/netbox/extras/context_managers.py b/netbox/extras/context_managers.py index d4aeb83642b..32323999efe 100644 --- a/netbox/extras/context_managers.py +++ b/netbox/extras/context_managers.py @@ -1,8 +1,5 @@ from contextlib import contextmanager -from django.db.models.signals import m2m_changed, pre_delete, post_save - -from extras.signals import clear_webhooks, clear_webhook_queue, handle_changed_object, handle_deleted_object from netbox.context import current_request, webhooks_queue from .webhooks import flush_webhooks @@ -18,21 +15,8 @@ def change_logging(request): current_request.set(request) webhooks_queue.set([]) - # Connect our receivers to the post_save and post_delete signals. - post_save.connect(handle_changed_object, dispatch_uid='handle_changed_object') - m2m_changed.connect(handle_changed_object, dispatch_uid='handle_changed_object') - pre_delete.connect(handle_deleted_object, dispatch_uid='handle_deleted_object') - clear_webhooks.connect(clear_webhook_queue, dispatch_uid='clear_webhook_queue') - yield - # Disconnect change logging signals. This is necessary to avoid recording any errant - # changes during test cleanup. - post_save.disconnect(handle_changed_object, dispatch_uid='handle_changed_object') - m2m_changed.disconnect(handle_changed_object, dispatch_uid='handle_changed_object') - pre_delete.disconnect(handle_deleted_object, dispatch_uid='handle_deleted_object') - clear_webhooks.disconnect(clear_webhook_queue, dispatch_uid='clear_webhook_queue') - # Flush queued webhooks to RQ flush_webhooks(webhooks_queue.get()) diff --git a/netbox/extras/signals.py b/netbox/extras/signals.py index 8854d631408..31e0c126cf7 100644 --- a/netbox/extras/signals.py +++ b/netbox/extras/signals.py @@ -14,6 +14,7 @@ from .models import ConfigRevision, CustomField, ObjectChange from .webhooks import enqueue_object, get_snapshots, serialize_for_webhook + # # Change logging/webhooks # @@ -22,22 +23,32 @@ clear_webhooks = Signal() +def is_same_object(instance, webhook_data, request_id): + """ + Compare the given instance to the most recent queued webhook object, returning True + if they match. This check is used to avoid creating duplicate webhook entries. + """ + return ( + ContentType.objects.get_for_model(instance) == webhook_data['content_type'] and + instance.pk == webhook_data['object_id'] and + request_id == webhook_data['request_id'] + ) + + +@receiver((post_save, m2m_changed)) def handle_changed_object(sender, instance, **kwargs): """ Fires when an object is created or updated. """ + m2m_changed = False + if not hasattr(instance, 'to_objectchange'): return + # Get the current request, or bail if not set request = current_request.get() - m2m_changed = False - - def is_same_object(instance, webhook_data): - return ( - ContentType.objects.get_for_model(instance) == webhook_data['content_type'] and - instance.pk == webhook_data['object_id'] and - request.id == webhook_data['request_id'] - ) + if request is None: + return # Determine the type of change being made if kwargs.get('created'): @@ -69,7 +80,7 @@ def is_same_object(instance, webhook_data): # If this is an M2M change, update the previously queued webhook (from post_save) queue = webhooks_queue.get() - if m2m_changed and queue and is_same_object(instance, queue[-1]): + if m2m_changed and queue and is_same_object(instance, queue[-1], request.id): instance.refresh_from_db() # Ensure that we're working with fresh M2M assignments queue[-1]['data'] = serialize_for_webhook(instance) queue[-1]['snapshots']['postchange'] = get_snapshots(instance, action)['postchange'] @@ -84,6 +95,7 @@ def is_same_object(instance, webhook_data): model_updates.labels(instance._meta.model_name).inc() +@receiver(pre_delete) def handle_deleted_object(sender, instance, **kwargs): """ Fires when an object is deleted. @@ -91,7 +103,10 @@ def handle_deleted_object(sender, instance, **kwargs): if not hasattr(instance, 'to_objectchange'): return + # Get the current request, or bail if not set request = current_request.get() + if request is None: + return # Record an ObjectChange if applicable if hasattr(instance, 'to_objectchange'): @@ -109,6 +124,7 @@ def handle_deleted_object(sender, instance, **kwargs): model_deletes.labels(instance._meta.model_name).inc() +@receiver(clear_webhooks) def clear_webhook_queue(sender, **kwargs): """ Delete any queued webhooks (e.g. because of an aborted bulk transaction) diff --git a/netbox/netbox/context.py b/netbox/netbox/context.py index 02c6fccaea8..b5e4dc28ed4 100644 --- a/netbox/netbox/context.py +++ b/netbox/netbox/context.py @@ -6,5 +6,5 @@ ) -current_request = ContextVar('current_request') +current_request = ContextVar('current_request', default=None) webhooks_queue = ContextVar('webhooks_queue') From 7401fd70501d9431f7f8624455dde59db8f5802e Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 14 Nov 2022 10:40:48 -0800 Subject: [PATCH 24/34] 10909 add l2vpn to tenant stats --- netbox/templates/tenancy/tenant.html | 6 ++++++ netbox/tenancy/views.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox/templates/tenancy/tenant.html b/netbox/templates/tenancy/tenant.html index e8dc4b23a46..7d2ff014964 100644 --- a/netbox/templates/tenancy/tenant.html +++ b/netbox/templates/tenancy/tenant.html @@ -93,6 +93,12 @@

{{ stats.vlan_count }}

VLANs

+ + +

{{ stats.circuit_count }}

Circuits

diff --git a/netbox/tenancy/views.py b/netbox/tenancy/views.py index d8b810ad9ca..03b454321e7 100644 --- a/netbox/tenancy/views.py +++ b/netbox/tenancy/views.py @@ -4,7 +4,7 @@ from circuits.models import Circuit from dcim.models import Cable, Device, Location, Rack, RackReservation, Site -from ipam.models import Aggregate, IPAddress, IPRange, Prefix, VLAN, VRF, ASN +from ipam.models import Aggregate, IPAddress, IPRange, L2VPN, Prefix, VLAN, VRF, ASN from netbox.views import generic from utilities.utils import count_related from virtualization.models import VirtualMachine, Cluster @@ -111,6 +111,7 @@ def get_extra_context(self, request, instance): 'iprange_count': IPRange.objects.restrict(request.user, 'view').filter(tenant=instance).count(), 'ipaddress_count': IPAddress.objects.restrict(request.user, 'view').filter(tenant=instance).count(), 'vlan_count': VLAN.objects.restrict(request.user, 'view').filter(tenant=instance).count(), + 'l2vpn_count': L2VPN.objects.restrict(request.user, 'view').filter(tenant=instance).count(), 'circuit_count': Circuit.objects.restrict(request.user, 'view').filter(tenant=instance).count(), 'virtualmachine_count': VirtualMachine.objects.restrict(request.user, 'view').filter(tenant=instance).count(), 'cluster_count': Cluster.objects.restrict(request.user, 'view').filter(tenant=instance).count(), From 564884a7749a94f79b9fa954b5aa65da27845368 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 14 Nov 2022 10:20:38 -0800 Subject: [PATCH 25/34] 10903 add module type on manufacturer page --- netbox/templates/dcim/manufacturer.html | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/netbox/templates/dcim/manufacturer.html b/netbox/templates/dcim/manufacturer.html index 43d16afcb81..ad975f2eaba 100644 --- a/netbox/templates/dcim/manufacturer.html +++ b/netbox/templates/dcim/manufacturer.html @@ -4,10 +4,24 @@ {% load render_table from django_tables2 %} {% block extra_controls %} - {% if perms.dcim.add_devicetype %} - - Add Device Type - + {% if perms.dcim.add_devicetype or perms.dcim.add_moduletype %} + {% endif %} {% endblock extra_controls %} From c6930e3ea85155086eef7e045bd0fa8c87632984 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 15 Nov 2022 08:10:13 -0800 Subject: [PATCH 26/34] 10919 add location to cable termination panels --- netbox/templates/dcim/inc/cable_termination.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netbox/templates/dcim/inc/cable_termination.html b/netbox/templates/dcim/inc/cable_termination.html index ced9bda5028..0ee4c1ccf24 100644 --- a/netbox/templates/dcim/inc/cable_termination.html +++ b/netbox/templates/dcim/inc/cable_termination.html @@ -7,6 +7,10 @@
+ + + + From 928d880f0e830aa317ece2670ab16f2c77046e06 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Wed, 16 Nov 2022 06:27:49 -0800 Subject: [PATCH 27/34] 10902 add location to power feed form (#10913) * 10902 add location to power feed form * Bind location field to selected site Co-authored-by: jeremystretch --- netbox/dcim/forms/models.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py index 8f1626361eb..da50b8f2ae0 100644 --- a/netbox/dcim/forms/models.py +++ b/netbox/dcim/forms/models.py @@ -877,10 +877,21 @@ class PowerFeedForm(NetBoxModelForm): 'site_id': '$site' } ) + location = DynamicModelChoiceField( + queryset=Location.objects.all(), + required=False, + query_params={ + 'site_id': '$site' + }, + initial_params={ + 'racks': '$rack' + } + ) rack = DynamicModelChoiceField( queryset=Rack.objects.all(), required=False, query_params={ + 'location_id': '$location', 'site_id': '$site' } ) @@ -888,14 +899,14 @@ class PowerFeedForm(NetBoxModelForm): fieldsets = ( ('Power Panel', ('region', 'site', 'power_panel')), - ('Power Feed', ('rack', 'name', 'status', 'type', 'mark_connected', 'tags')), + ('Power Feed', ('location', 'rack', 'name', 'status', 'type', 'mark_connected', 'tags')), ('Characteristics', ('supply', 'voltage', 'amperage', 'phase', 'max_utilization')), ) class Meta: model = PowerFeed fields = [ - 'region', 'site_group', 'site', 'power_panel', 'rack', 'name', 'status', 'type', 'mark_connected', 'supply', + 'region', 'site_group', 'site', 'power_panel', 'location', 'rack', 'name', 'status', 'type', 'mark_connected', 'supply', 'phase', 'voltage', 'amperage', 'max_utilization', 'comments', 'tags', ] widgets = { From 316c3808f7fcfca282600dbd85a5f63f9a28c92e Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 16 Nov 2022 09:43:11 -0500 Subject: [PATCH 28/34] Changelog for #9439, #10902, #10914, #10915, #10919 --- docs/release-notes/version-3.3.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index df84c8de469..c7a2db6d727 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -2,8 +2,16 @@ ## v3.3.8 (FUTURE) +### Enhancements + +* [#10902](https://github.com/netbox-community/netbox/issues/10902) - Add location selector to power feed form +* [#10914](https://github.com/netbox-community/netbox/issues/10914) - Include "add module type" button on manufacturer view +* [#10915](https://github.com/netbox-community/netbox/issues/10915) - Add count of L2VPNs to tenant view +* [#10919](https://github.com/netbox-community/netbox/issues/10919) - Include device location under cable view + ### Bug Fixes +* [#9439](https://github.com/netbox-community/netbox/issues/9439) - Ensure thread safety of change logging functions * [#10709](https://github.com/netbox-community/netbox/issues/10709) - Correct UI display for `azuread-v2-tenant-oauth2` SSO backend * [#10829](https://github.com/netbox-community/netbox/issues/10829) - Fix bulk edit/delete buttons ad top of object lists * [#10837](https://github.com/netbox-community/netbox/issues/10837) - Correct cookie paths when `BASE_PATH` is set From a2007a4728faafeee5c296afabc116707db42344 Mon Sep 17 00:00:00 2001 From: Derick Vigne Date: Wed, 16 Nov 2022 09:57:49 -0500 Subject: [PATCH 29/34] Closes #10904: Added Colors to SVG for Front and Rear Ports (#10905) * Added Colors to SVG for Front and Reaer Ports Fix for feature request 10904 thanks to @TheZackCodec * Simplify termination color resolution Co-authored-by: jeremystretch --- netbox/dcim/svg/cables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/svg/cables.py b/netbox/dcim/svg/cables.py index 9a847acc9b5..33adef798a0 100644 --- a/netbox/dcim/svg/cables.py +++ b/netbox/dcim/svg/cables.py @@ -166,7 +166,7 @@ def _get_color(cls, instance): """ if hasattr(instance, 'parent_object'): # Termination - return 'f0f0f0' + return getattr(instance, 'color', 'f0f0f0') or 'f0f0f0' if hasattr(instance, 'device_role'): # Device return instance.device_role.color From 3a62fd49e6f0b7d6ef5080321a54df9479e4de76 Mon Sep 17 00:00:00 2001 From: Patrick Hurrelmann Date: Wed, 16 Nov 2022 16:26:46 +0100 Subject: [PATCH 30/34] Fixes: #10356 backplane connections (#10554) * Fixes: #10356 Add interface type and cable for backplane connections * Allow Backplone for front and readports , too. * Correct tyo in port definition * pep8 fix (blank lines) * Remove port type and changed name/description of backplane cable * Omit backplane cable type Co-authored-by: Patrick Hurrelmann Co-authored-by: jeremystretch --- netbox/dcim/choices.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index 7d35a40f9c6..14ddc9930e9 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -783,6 +783,17 @@ class InterfaceTypeChoices(ChoiceSet): TYPE_400GE_QSFP_DD = '400gbase-x-qsfpdd' TYPE_400GE_OSFP = '400gbase-x-osfp' + # Ethernet Backplane + TYPE_1GE_KX = '1000base-kx' + TYPE_10GE_KR = '10gbase-kr' + TYPE_10GE_KX4 = '10gbase-kx4' + TYPE_25GE_KR = '25gbase-kr' + TYPE_40GE_KR4 = '40gbase-kr4' + TYPE_50GE_KR = '50gbase-kr' + TYPE_100GE_KP4 = '100gbase-kp4' + TYPE_100GE_KR2 = '100gbase-kr2' + TYPE_100GE_KR4 = '100gbase-kr4' + # Wireless TYPE_80211A = 'ieee802.11a' TYPE_80211G = 'ieee802.11g' @@ -911,6 +922,20 @@ class InterfaceTypeChoices(ChoiceSet): (TYPE_400GE_OSFP, 'OSFP (400GE)'), ) ), + ( + 'Ethernet (backplane)', + ( + (TYPE_1GE_KX, '1000BASE-KX (1GE)'), + (TYPE_10GE_KR, '10GBASE-KR (10GE)'), + (TYPE_10GE_KX4, '10GBASE-KX4 (10GE)'), + (TYPE_25GE_KR, '25GBASE-KR (25GE)'), + (TYPE_40GE_KR4, '40GBASE-KR4 (40GE)'), + (TYPE_50GE_KR, '50GBASE-KR (50GE)'), + (TYPE_100GE_KP4, '100GBASE-KP4 (100GE)'), + (TYPE_100GE_KR2, '100GBASE-KR2 (100GE)'), + (TYPE_100GE_KR4, '100GBASE-KR4 (100GE)'), + ) + ), ( 'Wireless', ( From 44c248e6c280fa2421f8b17adc1424131398b144 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 16 Nov 2022 10:36:30 -0500 Subject: [PATCH 31/34] Closes #10934: Update release package URL --- docs/installation/3-netbox.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation/3-netbox.md b/docs/installation/3-netbox.md index f42e28debfc..72c054e5b7b 100644 --- a/docs/installation/3-netbox.md +++ b/docs/installation/3-netbox.md @@ -36,7 +36,7 @@ This documentation provides two options for installing NetBox: from a downloadab Download the [latest stable release](https://github.com/netbox-community/netbox/releases) from GitHub as a tarball or ZIP archive and extract it to your desired path. In this example, we'll use `/opt/netbox` as the NetBox root. ```no-highlight -sudo wget https://github.com/netbox-community/netbox/archive/vX.Y.Z.tar.gz +sudo wget https://github.com/netbox-community/netbox/archive/refs/tags/vX.Y.Z.tar.gz sudo tar -xzf vX.Y.Z.tar.gz -C /opt sudo ln -s /opt/netbox-X.Y.Z/ /opt/netbox ``` From 540bba4544d9f31c126571cc1a45a6783b3b6a89 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 16 Nov 2022 10:37:06 -0500 Subject: [PATCH 32/34] Closes #10920: Include request cookies when queuing a custom script --- netbox/utilities/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/netbox/utilities/utils.py b/netbox/utilities/utils.py index 69ab615fcbb..ba3388c7575 100644 --- a/netbox/utilities/utils.py +++ b/netbox/utilities/utils.py @@ -410,6 +410,7 @@ def copy_safe_request(request): } return NetBoxFakeRequest({ 'META': meta, + 'COOKIES': request.COOKIES, 'POST': request.POST, 'GET': request.GET, 'FILES': request.FILES, From ceec1055e0ea5d09d2606c9742f8ac240aa49d33 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 16 Nov 2022 10:40:18 -0500 Subject: [PATCH 33/34] Changelog for #10356, #10904, #10920 --- docs/release-notes/version-3.3.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index c7a2db6d727..3872b4c34e4 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -4,10 +4,13 @@ ### Enhancements +* [#10356](https://github.com/netbox-community/netbox/issues/10356) - Add backplane Ethernet interface types * [#10902](https://github.com/netbox-community/netbox/issues/10902) - Add location selector to power feed form +* [#10904](https://github.com/netbox-community/netbox/issues/10904) - Use front/rear port colors in cable trace SVG * [#10914](https://github.com/netbox-community/netbox/issues/10914) - Include "add module type" button on manufacturer view * [#10915](https://github.com/netbox-community/netbox/issues/10915) - Add count of L2VPNs to tenant view * [#10919](https://github.com/netbox-community/netbox/issues/10919) - Include device location under cable view +* [#10920](https://github.com/netbox-community/netbox/issues/10920) - Include request cookies when queuing a custom script ### Bug Fixes From 62a80c46a87cb924d49931fc5dc1628bd7f1089a Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 16 Nov 2022 10:45:29 -0500 Subject: [PATCH 34/34] Release v3.3.8 --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yaml | 2 +- docs/release-notes/version-3.3.md | 2 +- netbox/netbox/settings.py | 2 +- requirements.txt | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 4de82d4e336..3beec4cf7a9 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.7 + placeholder: v3.3.8 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 5f0a17aa7c3..6688de9fef0 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.7 + placeholder: v3.3.8 validations: required: true - type: dropdown diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 3872b4c34e4..4894690defb 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.8 (FUTURE) +## v3.3.8 (2022-11-16) ### Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 4ff440c469e..46663f08c4f 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -29,7 +29,7 @@ # Environment setup # -VERSION = '3.3.8-dev' +VERSION = '3.3.8' # Hostname HOSTNAME = platform.node() diff --git a/requirements.txt b/requirements.txt index 73abfa25937..8e89b47c5af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ django-pglocks==1.0.4 django-prometheus==2.2.0 django-redis==5.2.0 django-rich==1.4.0 -django-rq==2.5.1 +django-rq==2.6.0 django-tables2==2.4.1 django-taggit==3.0.0 django-timezone-field==5.0 @@ -19,13 +19,13 @@ graphene-django==2.15.0 gunicorn==20.1.0 Jinja2==3.1.2 Markdown==3.3.7 -mkdocs-material==8.5.7 +mkdocs-material==8.5.10 mkdocstrings[python-legacy]==0.19.0 netaddr==0.8.0 Pillow==9.3.0 psycopg2-binary==2.9.5 PyYAML==6.0 -sentry-sdk==1.10.1 +sentry-sdk==1.11.0 social-auth-app-django==5.0.0 social-auth-core[openidconnect]==4.3.0 svgwrite==1.4.3
CPU
Memory
Temperature
Fans
Power
Location{{ terminations.0.device.location|linkify|placeholder }}
Rack {{ terminations.0.device.rack|linkify|placeholder }}