From 332487efcd9143b19ae6aaf03377ae60b8d904dd Mon Sep 17 00:00:00 2001 From: dansheps Date: Mon, 11 Mar 2019 15:09:36 -0500 Subject: [PATCH 01/25] API Filtering Documentation Changes * Fixed typo * Clarified documentation regarding filtering multiple times (some filters can, some cannot) --- CHANGELOG.md | 7 +++++++ docs/api/overview.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8996bda..86af60918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +v2.5.9 (FUTURE) + +## Bug Fixes + +* [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering +* [#2991](https://github.com/digitalocean/netbox/issues/2991) - Correct documentation for API Filtering + v2.5.8 (2019-03-11) ## Enhancements diff --git a/docs/api/overview.md b/docs/api/overview.md index 1115759d8..00ff9c27e 100644 --- a/docs/api/overview.md +++ b/docs/api/overview.md @@ -261,7 +261,7 @@ A list of objects retrieved via the API can be filtered by passing one or more q GET /api/ipam/prefixes/?status=1 ``` -The same filter can be incldued multiple times. These will effect a logical OR and return objects matching any of the given values. For example, the following will return all active and reserved prefixes: +Certain filters can be included multiple times within a single request. These will effect a logical OR and return objects matching any of the given values. For example, the following will return all active and reserved prefixes: ``` GET /api/ipam/prefixes/?status=1&status=2 From 61efe6102e4eed5aa4f3f5a51be90eae9feeb7c2 Mon Sep 17 00:00:00 2001 From: dansheps Date: Tue, 12 Mar 2019 15:52:44 -0500 Subject: [PATCH 02/25] Fixes #2207 * Added 'id' field sort to InterfaceManager --- netbox/dcim/managers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/dcim/managers.py b/netbox/dcim/managers.py index feaa09d74..3afc3234c 100644 --- a/netbox/dcim/managers.py +++ b/netbox/dcim/managers.py @@ -64,11 +64,15 @@ class InterfaceManager(Manager): The original `name` field is considered in its entirety to serve as a fallback in the event interfaces do not match any of the prescribed fields. + + The `id` field is included to enforce deterministic ordering of interfaces in similar vein of other device + components. """ sql_col = '{}.name'.format(self.model._meta.db_table) ordering = [ - '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', + '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'id' + ] fields = { From 929253432476058088a75db419ee39aa7d894268 Mon Sep 17 00:00:00 2001 From: dansheps Date: Tue, 12 Mar 2019 15:54:38 -0500 Subject: [PATCH 03/25] Changelog Updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86af60918..3f95bdb63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v2.5.9 (FUTURE) ## Bug Fixes +* [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes Deterministic Ordering of Interfaces * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2991](https://github.com/digitalocean/netbox/issues/2991) - Correct documentation for API Filtering From 520af82f051110c7862d9915af2ccfe5d4a55b58 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 13 Mar 2019 10:00:40 -0400 Subject: [PATCH 04/25] Closes #2924: Add interface type for QSFP28 50GE --- CHANGELOG.md | 2 +- netbox/dcim/constants.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86af60918..4964b591c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ v2.5.9 (FUTURE) ## Bug Fixes * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering -* [#2991](https://github.com/digitalocean/netbox/issues/2991) - Correct documentation for API Filtering +* [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE v2.5.8 (2019-03-11) diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index 0b81e68bf..af2547bc4 100644 --- a/netbox/dcim/constants.py +++ b/netbox/dcim/constants.py @@ -83,6 +83,7 @@ IFACE_FF_10GE_XENPAK = 1310 IFACE_FF_10GE_X2 = 1320 IFACE_FF_25GE_SFP28 = 1350 IFACE_FF_40GE_QSFP_PLUS = 1400 +IFACE_FF_50GE_QSFP28 = 1420 IFACE_FF_100GE_CFP = 1500 IFACE_FF_100GE_CFP2 = 1510 IFACE_FF_100GE_CFP4 = 1520 @@ -164,6 +165,7 @@ IFACE_FF_CHOICES = [ [IFACE_FF_10GE_X2, 'X2 (10GE)'], [IFACE_FF_25GE_SFP28, 'SFP28 (25GE)'], [IFACE_FF_40GE_QSFP_PLUS, 'QSFP+ (40GE)'], + [IFACE_FF_50GE_QSFP28, 'QSFP28 (50GE)'], [IFACE_FF_100GE_CFP, 'CFP (100GE)'], [IFACE_FF_100GE_CFP2, 'CFP2 (100GE)'], [IFACE_FF_200GE_CFP2, 'CFP2 (200GE)'], From aab84ba6f3777c305df2186568b6031c2ebb766d Mon Sep 17 00:00:00 2001 From: dansheps Date: Wed, 13 Mar 2019 14:02:23 -0500 Subject: [PATCH 05/25] Change ID to PK --- netbox/dcim/managers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/managers.py b/netbox/dcim/managers.py index 3afc3234c..9e4e5fca2 100644 --- a/netbox/dcim/managers.py +++ b/netbox/dcim/managers.py @@ -71,7 +71,7 @@ class InterfaceManager(Manager): sql_col = '{}.name'.format(self.model._meta.db_table) ordering = [ - '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'id' + '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'pk' ] From 7edad4eba9b5f58deb9ea1af53faee824a6edc38 Mon Sep 17 00:00:00 2001 From: Alexander Kinneer Date: Fri, 15 Mar 2019 10:35:03 -0500 Subject: [PATCH 06/25] Add support for configuring use of an SSL connection to Redis. Requires a build or release of django-rq containing https://github.com/rq/django-rq/pull/326/commits/44f3fdd7cbd94a4e0331befbb4a57c81e079cdbf --- netbox/extras/apps.py | 1 + netbox/netbox/configuration.example.py | 1 + netbox/netbox/settings.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/netbox/extras/apps.py b/netbox/extras/apps.py index 2d4517c26..6e6083691 100644 --- a/netbox/extras/apps.py +++ b/netbox/extras/apps.py @@ -22,6 +22,7 @@ class ExtrasConfig(AppConfig): port=settings.REDIS_PORT, db=settings.REDIS_DATABASE, password=settings.REDIS_PASSWORD or None, + ssl=settings.REDIS_SSL, ) rs.ping() except redis.exceptions.ConnectionError: diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index d7a9cf2ed..145ebf0e6 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -132,6 +132,7 @@ REDIS = { 'PASSWORD': '', 'DATABASE': 0, 'DEFAULT_TIMEOUT': 300, + 'SSL': False, } # The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 6b36e2f93..389fead42 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -131,6 +131,7 @@ REDIS_PORT = REDIS.get('PORT', 6379) REDIS_PASSWORD = REDIS.get('PASSWORD', '') REDIS_DATABASE = REDIS.get('DATABASE', 0) REDIS_DEFAULT_TIMEOUT = REDIS.get('DEFAULT_TIMEOUT', 300) +REDIS_SSL = REDIS.get('SSL', False) # Email EMAIL_HOST = EMAIL.get('SERVER') @@ -291,6 +292,7 @@ RQ_QUEUES = { 'DB': REDIS_DATABASE, 'PASSWORD': REDIS_PASSWORD, 'DEFAULT_TIMEOUT': REDIS_DEFAULT_TIMEOUT, + 'SSL': REDIS_SSL, } } From 1bf04f2e30abda3b30c4d12a4ee39a53c403efcc Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 17 Mar 2019 01:24:54 -0400 Subject: [PATCH 07/25] fixes #2936 - device role selection showing duplicate first entry --- CHANGELOG.md | 1 + netbox/dcim/forms.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b350c95..33a77c42f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ v2.5.9 (FUTURE) * [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes Deterministic Ordering of Interfaces * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE +* [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry v2.5.8 (2019-03-11) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index ad209c516..06cc7ffe2 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -1700,7 +1700,6 @@ class DeviceFilterForm(BootstrapMixin, CustomFieldFilterForm): widget=APISelectMultiple( api_url="/api/dcim/device-roles/", value_field="slug", - null_option=True, ) ) tenant = FilterChoiceField( From 5f40be4bd56676a0f3eb640c624ebd8179f46deb Mon Sep 17 00:00:00 2001 From: dansheps Date: Mon, 18 Mar 2019 09:20:57 -0500 Subject: [PATCH 08/25] Changes vm_role from "true" to "True" in virtualization form --- CHANGELOG.md | 1 + netbox/virtualization/forms.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a77c42f..f627cec21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v2.5.9 (FUTURE) ## Bug Fixes +* [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering * [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes Deterministic Ordering of Interfaces * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE diff --git a/netbox/virtualization/forms.py b/netbox/virtualization/forms.py index 70bbf0910..1e5f42160 100644 --- a/netbox/virtualization/forms.py +++ b/netbox/virtualization/forms.py @@ -348,7 +348,7 @@ class VirtualMachineForm(BootstrapMixin, TenancyForm, CustomFieldForm): "role": APISelect( api_url="/api/dcim/device-roles/", additional_query_params={ - "vm_role": "true" + "vm_role": "True" } ), 'primary_ip4': StaticSelect2(), @@ -480,7 +480,7 @@ class VirtualMachineBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldB widget=APISelect( api_url="/api/dcim/device-roles/", additional_query_params={ - "vm_role": "true" + "vm_role": "True" } ) ) @@ -582,7 +582,7 @@ class VirtualMachineFilterForm(BootstrapMixin, CustomFieldFilterForm): value_field="slug", null_option=True, additional_query_params={ - 'vm_role': 'true' + 'vm_role': "True" } ) ) From f88099eb3b6632090db3214cdceacd09dc4e3249 Mon Sep 17 00:00:00 2001 From: Alexander Kinneer Date: Mon, 18 Mar 2019 11:15:40 -0500 Subject: [PATCH 09/25] Add documentation for new Redis SSL configuration parameter. --- docs/configuration/optional-settings.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/configuration/optional-settings.md b/docs/configuration/optional-settings.md index 65ac588b6..f8bd70e88 100644 --- a/docs/configuration/optional-settings.md +++ b/docs/configuration/optional-settings.md @@ -283,6 +283,7 @@ REDIS = { 'PASSWORD': '', 'DATABASE': 0, 'DEFAULT_TIMEOUT': 300, + 'SSL': False, } ``` @@ -315,3 +316,9 @@ The TCP port to use when connecting to the Redis server. Default: None The password to use when authenticating to the Redis server (optional). + +### SSL + +Default: False + +Use secure sockets layer to encrypt the connections to the Redis server. From e5447052567427b0f87ef3b1f9926dcd221a85f1 Mon Sep 17 00:00:00 2001 From: Alexander Kinneer Date: Fri, 15 Mar 2019 10:35:03 -0500 Subject: [PATCH 10/25] Add support for configuring use of an SSL connection to Redis. Requires a build or release of django-rq containing https://github.com/rq/django-rq/pull/326/commits/44f3fdd7cbd94a4e0331befbb4a57c81e079cdbf --- docs/configuration/optional-settings.md | 7 +++++++ netbox/extras/apps.py | 1 + netbox/netbox/configuration.example.py | 1 + netbox/netbox/settings.py | 2 ++ 4 files changed, 11 insertions(+) diff --git a/docs/configuration/optional-settings.md b/docs/configuration/optional-settings.md index 65ac588b6..f8bd70e88 100644 --- a/docs/configuration/optional-settings.md +++ b/docs/configuration/optional-settings.md @@ -283,6 +283,7 @@ REDIS = { 'PASSWORD': '', 'DATABASE': 0, 'DEFAULT_TIMEOUT': 300, + 'SSL': False, } ``` @@ -315,3 +316,9 @@ The TCP port to use when connecting to the Redis server. Default: None The password to use when authenticating to the Redis server (optional). + +### SSL + +Default: False + +Use secure sockets layer to encrypt the connections to the Redis server. diff --git a/netbox/extras/apps.py b/netbox/extras/apps.py index 2d4517c26..6e6083691 100644 --- a/netbox/extras/apps.py +++ b/netbox/extras/apps.py @@ -22,6 +22,7 @@ class ExtrasConfig(AppConfig): port=settings.REDIS_PORT, db=settings.REDIS_DATABASE, password=settings.REDIS_PASSWORD or None, + ssl=settings.REDIS_SSL, ) rs.ping() except redis.exceptions.ConnectionError: diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index d7a9cf2ed..145ebf0e6 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -132,6 +132,7 @@ REDIS = { 'PASSWORD': '', 'DATABASE': 0, 'DEFAULT_TIMEOUT': 300, + 'SSL': False, } # The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 6b36e2f93..389fead42 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -131,6 +131,7 @@ REDIS_PORT = REDIS.get('PORT', 6379) REDIS_PASSWORD = REDIS.get('PASSWORD', '') REDIS_DATABASE = REDIS.get('DATABASE', 0) REDIS_DEFAULT_TIMEOUT = REDIS.get('DEFAULT_TIMEOUT', 300) +REDIS_SSL = REDIS.get('SSL', False) # Email EMAIL_HOST = EMAIL.get('SERVER') @@ -291,6 +292,7 @@ RQ_QUEUES = { 'DB': REDIS_DATABASE, 'PASSWORD': REDIS_PASSWORD, 'DEFAULT_TIMEOUT': REDIS_DEFAULT_TIMEOUT, + 'SSL': REDIS_SSL, } } From 044f7395bb23583d467cdd66abda319ce95cd714 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 19 Mar 2019 09:48:16 -0400 Subject: [PATCH 11/25] Closes #2995: Added powerbox to community SDK list --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39ab1afc4..8b9df7f2c 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,13 @@ and run `upgrade.sh`. ## Supported SDK -- [pynetbox](https://github.com/digitalocean/pynetbox) Python API client library for Netbox. +- [pynetbox](https://github.com/digitalocean/pynetbox) - A Python API client library for Netbox ## Community SDK -- [netbox-client-ruby](https://github.com/ninech/netbox-client-ruby) A ruby client library for Netbox v2. +- [netbox-client-ruby](https://github.com/ninech/netbox-client-ruby) - A Ruby client library for Netbox +- [powerbox](https://github.com/BatmanAMA/powerbox) - A PowerShell library for Netbox ## Ansible Inventory -- [netbox-as-ansible-inventory](https://github.com/AAbouZaid/netbox-as-ansible-inventory) Ansible dynamic inventory script for Netbox. - +- [netbox-as-ansible-inventory](https://github.com/AAbouZaid/netbox-as-ansible-inventory) - Ansible dynamic inventory script for Netbox From f6345b9a5d503ed72e9f78a7bb0dc6fbd0347b35 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 19 Mar 2019 10:22:52 -0400 Subject: [PATCH 12/25] Fixes #2998: Limit device query to non-racked devices if no rack selected when creating a cable --- CHANGELOG.md | 1 + netbox/project-static/js/forms.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a77c42f..3f171c02a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ v2.5.9 (FUTURE) * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE * [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry +* [#2998](https://github.com/digitalocean/netbox/issues/2998) - Limit device query to non-racked devices if no rack selected when creating a cable v2.5.8 (2019-03-11) diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 2a6bf92ff..81ddb9ffd 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -155,10 +155,13 @@ $(document).ready(function() { filter_for_elements.each(function(index, filter_for_element) { var param_name = $(filter_for_element).attr(attr_name); + var is_nullable = $(filter_for_element).attr("nullable"); var value = $(filter_for_element).val(); if (param_name && value) { parameters[param_name] = value; + } else if (param_name && is_nullable) { + parameters[param_name] = "null"; } }); From 7d1ee2e94e7d58adcb31bb026cbc588c0a5e7310 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 19 Mar 2019 10:34:07 -0400 Subject: [PATCH 13/25] Changelog for #3011 --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daff30a1d..b79bc697c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,17 @@ v2.5.9 (FUTURE) +## Enhancements + +* [#3011](https://github.com/digitalocean/netbox/issues/3011) - Add SSL support for django-rq (requires django-rq v1.3.1+) + ## Bug Fixes -* [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering * [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes Deterministic Ordering of Interfaces * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE * [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry * [#2998](https://github.com/digitalocean/netbox/issues/2998) - Limit device query to non-racked devices if no rack selected when creating a cable +* [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering v2.5.8 (2019-03-11) From fc76c8eb0fa6ea81a28919a273a27fe5aeae393e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Mar 2019 16:24:53 -0400 Subject: [PATCH 14/25] FieldChoicesViewSet should infer field choices from serializer, not model --- netbox/dcim/api/serializers.py | 9 +++++++-- netbox/dcim/api/views.py | 2 +- netbox/extras/api/serializers.py | 5 ++++- netbox/extras/api/views.py | 1 - netbox/ipam/api/serializers.py | 2 ++ netbox/utilities/api.py | 18 ++++++++++++------ 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 4c65a3a19..d8bf68e12 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -1,3 +1,4 @@ +from django.contrib.contenttypes.models import ContentType from rest_framework import serializers from rest_framework.validators import UniqueTogetherValidator from taggit_serializer.serializers import TaggitSerializer, TagListSerializerField @@ -502,8 +503,12 @@ class InventoryItemSerializer(TaggitSerializer, ValidatedModelSerializer): # class CableSerializer(ValidatedModelSerializer): - termination_a_type = ContentTypeField() - termination_b_type = ContentTypeField() + termination_a_type = ContentTypeField( + queryset=ContentType.objects.filter(model__in=CABLE_TERMINATION_TYPES) + ) + termination_b_type = ContentTypeField( + queryset=ContentType.objects.filter(model__in=CABLE_TERMINATION_TYPES) + ) termination_a = serializers.SerializerMethodField(read_only=True) termination_b = serializers.SerializerMethodField(read_only=True) status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, required=False) diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 8fddc7129..2fd398f08 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -1,7 +1,7 @@ from collections import OrderedDict from django.conf import settings -from django.db.models import F, Q +from django.db.models import F from django.http import HttpResponseForbidden from django.shortcuts import get_object_or_404 from drf_yasg import openapi diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index 7643562bb..88de52929 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -1,3 +1,4 @@ +from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from rest_framework import serializers from taggit.models import Tag @@ -88,7 +89,9 @@ class TagSerializer(ValidatedModelSerializer): # class ImageAttachmentSerializer(ValidatedModelSerializer): - content_type = ContentTypeField() + content_type = ContentTypeField( + queryset=ContentType.objects.all() + ) parent = serializers.SerializerMethodField(read_only=True) class Meta: diff --git a/netbox/extras/api/views.py b/netbox/extras/api/views.py index 0453b1f1c..3fcb14920 100644 --- a/netbox/extras/api/views.py +++ b/netbox/extras/api/views.py @@ -23,7 +23,6 @@ from . import serializers class ExtrasFieldChoicesViewSet(FieldChoicesViewSet): fields = ( - (CustomField, ['type']), (Graph, ['type']), ) diff --git a/netbox/ipam/api/serializers.py b/netbox/ipam/api/serializers.py index 030266188..9b2c45371 100644 --- a/netbox/ipam/api/serializers.py +++ b/netbox/ipam/api/serializers.py @@ -128,6 +128,7 @@ class VLANSerializer(TaggitSerializer, CustomFieldModelSerializer): # class PrefixSerializer(TaggitSerializer, CustomFieldModelSerializer): + family = ChoiceField(choices=AF_CHOICES, read_only=True) site = NestedSiteSerializer(required=False, allow_null=True) vrf = NestedVRFSerializer(required=False, allow_null=True) tenant = NestedTenantSerializer(required=False, allow_null=True) @@ -189,6 +190,7 @@ class IPAddressInterfaceSerializer(WritableNestedSerializer): class IPAddressSerializer(TaggitSerializer, CustomFieldModelSerializer): + family = ChoiceField(choices=AF_CHOICES, read_only=True) vrf = NestedVRFSerializer(required=False, allow_null=True) tenant = NestedTenantSerializer(required=False, allow_null=True) status = ChoiceField(choices=IPADDRESS_STATUS_CHOICES, required=False) diff --git a/netbox/utilities/api.py b/netbox/utilities/api.py index b65a7841b..e0e7f3c71 100644 --- a/netbox/utilities/api.py +++ b/netbox/utilities/api.py @@ -32,7 +32,9 @@ def get_serializer_for_model(model, prefix=''): try: return dynamic_import(serializer_name) except AttributeError: - return None + raise Exception( + "Could not determine serializer for {}.{} with prefix '{}'".format(app_name, model_name, prefix) + ) # @@ -100,6 +102,10 @@ class ChoiceField(Field): return data + @property + def choices(self): + return self._choices + class ContentTypeField(RelatedField): """ @@ -110,10 +116,6 @@ class ContentTypeField(RelatedField): "invalid": "Invalid value. Specify a content type as '.'.", } - # Can't set this as an attribute because it raises an exception when the field is read-only - def get_queryset(self): - return ContentType.objects.all() - def to_internal_value(self, data): try: app_label, model = data.split('.') @@ -256,10 +258,14 @@ class FieldChoicesViewSet(ViewSet): self._fields = OrderedDict() for cls, field_list in self.fields: for field_name in field_list: + model_name = cls._meta.verbose_name.lower().replace(' ', '-') key = ':'.join([model_name, field_name]) + + serializer = get_serializer_for_model(cls)() choices = [] - for k, v in cls._meta.get_field(field_name).choices: + + for k, v in serializer.get_fields()[field_name].choices.items(): if type(v) in [list, tuple]: for k2, v2 in v: choices.append({ From 3acc8ca3ab0307487aa5d61a8c8b091900b594b2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Mar 2019 16:26:56 -0400 Subject: [PATCH 15/25] Fixes #3022: Add missing cable termination types to DCIM _choices endpoint --- CHANGELOG.md | 1 + netbox/dcim/api/views.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b79bc697c..7e86f4a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ v2.5.9 (FUTURE) * [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry * [#2998](https://github.com/digitalocean/netbox/issues/2998) - Limit device query to non-racked devices if no rack selected when creating a cable * [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering +* [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint v2.5.8 (2019-03-11) diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 2fd398f08..db8cb87a9 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -35,7 +35,7 @@ from .exceptions import MissingFilterException class DCIMFieldChoicesViewSet(FieldChoicesViewSet): fields = ( - (Cable, ['length_unit', 'status', 'type']), + (Cable, ['length_unit', 'status', 'termination_a_type', 'termination_b_type', 'type']), (ConsolePort, ['connection_status']), (Device, ['face', 'status']), (DeviceType, ['subdevice_role']), From 2170eedf0898e6e6478993ba5f7b9c0da2c89fe9 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 24 Mar 2019 15:31:12 -0400 Subject: [PATCH 16/25] implements #2933 - username in webhooks --- CHANGELOG.md | 1 + netbox/extras/middleware.py | 4 ++-- netbox/extras/webhooks.py | 5 +++-- netbox/extras/webhooks_worker.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e86f4a49..b3d26e7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v2.5.9 (FUTURE) ## Enhancements +* [#2933](https://github.com/digitalocean/netbox/issues/2933) - Add username to outbound webhook requests * [#3011](https://github.com/digitalocean/netbox/issues/3011) - Add SSL support for django-rq (requires django-rq v1.3.1+) ## Bug Fixes diff --git a/netbox/extras/middleware.py b/netbox/extras/middleware.py index 38dde6275..de0b0ef68 100644 --- a/netbox/extras/middleware.py +++ b/netbox/extras/middleware.py @@ -37,7 +37,7 @@ def _record_object_deleted(request, instance, **kwargs): if hasattr(instance, 'log_change'): instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE) - enqueue_webhooks(instance, OBJECTCHANGE_ACTION_DELETE) + enqueue_webhooks(instance, request.user, OBJECTCHANGE_ACTION_DELETE) class ObjectChangeMiddleware(object): @@ -83,7 +83,7 @@ class ObjectChangeMiddleware(object): obj.log_change(request.user, request.id, action) # Enqueue webhooks - enqueue_webhooks(obj, action) + enqueue_webhooks(obj, request.user, action) # Housekeeping: 1% chance of clearing out expired ObjectChanges if _thread_locals.changed_objects and settings.CHANGELOG_RETENTION and random.randint(1, 100) == 1: diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py index 12dc7558b..07233892c 100644 --- a/netbox/extras/webhooks.py +++ b/netbox/extras/webhooks.py @@ -9,7 +9,7 @@ from utilities.api import get_serializer_for_model from .constants import WEBHOOK_MODELS -def enqueue_webhooks(instance, action): +def enqueue_webhooks(instance, user, action): """ Find Webhook(s) assigned to this instance + action and enqueue them to be processed @@ -47,5 +47,6 @@ def enqueue_webhooks(instance, action): serializer.data, instance._meta.model_name, action, - str(datetime.datetime.now()) + str(datetime.datetime.now()), + user.username ) diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py index 5a680f5d1..13805c77d 100644 --- a/netbox/extras/webhooks_worker.py +++ b/netbox/extras/webhooks_worker.py @@ -10,7 +10,7 @@ from extras.constants import WEBHOOK_CT_JSON, WEBHOOK_CT_X_WWW_FORM_ENCODED, OBJ @job('default') -def process_webhook(webhook, data, model_name, event, timestamp): +def process_webhook(webhook, data, model_name, event, timestamp, username): """ Make a POST request to the defined Webhook """ @@ -18,6 +18,7 @@ def process_webhook(webhook, data, model_name, event, timestamp): 'event': dict(OBJECTCHANGE_ACTION_CHOICES)[event].lower(), 'timestamp': timestamp, 'model': model_name, + 'username': username, 'data': data } headers = { From 2e1887eb0e21d0ae924f69ede02d4103d4ba14bf Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 24 Mar 2019 15:35:42 -0400 Subject: [PATCH 17/25] implements #3025 - Add request ID to outbound webhook requests --- CHANGELOG.md | 1 + netbox/extras/middleware.py | 4 ++-- netbox/extras/webhooks.py | 5 +++-- netbox/extras/webhooks_worker.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d26e7bb..94969799b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ v2.5.9 (FUTURE) * [#2933](https://github.com/digitalocean/netbox/issues/2933) - Add username to outbound webhook requests * [#3011](https://github.com/digitalocean/netbox/issues/3011) - Add SSL support for django-rq (requires django-rq v1.3.1+) +* [#3025](https://github.com/digitalocean/netbox/issues/3025) - Add request ID to outbound webhook requests (for correlating all changes part of a single request) ## Bug Fixes diff --git a/netbox/extras/middleware.py b/netbox/extras/middleware.py index de0b0ef68..be878918b 100644 --- a/netbox/extras/middleware.py +++ b/netbox/extras/middleware.py @@ -37,7 +37,7 @@ def _record_object_deleted(request, instance, **kwargs): if hasattr(instance, 'log_change'): instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE) - enqueue_webhooks(instance, request.user, OBJECTCHANGE_ACTION_DELETE) + enqueue_webhooks(instance, request.user, request.id, OBJECTCHANGE_ACTION_DELETE) class ObjectChangeMiddleware(object): @@ -83,7 +83,7 @@ class ObjectChangeMiddleware(object): obj.log_change(request.user, request.id, action) # Enqueue webhooks - enqueue_webhooks(obj, request.user, action) + enqueue_webhooks(obj, request.user, request.id, action) # Housekeeping: 1% chance of clearing out expired ObjectChanges if _thread_locals.changed_objects and settings.CHANGELOG_RETENTION and random.randint(1, 100) == 1: diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py index 07233892c..1ad050866 100644 --- a/netbox/extras/webhooks.py +++ b/netbox/extras/webhooks.py @@ -9,7 +9,7 @@ from utilities.api import get_serializer_for_model from .constants import WEBHOOK_MODELS -def enqueue_webhooks(instance, user, action): +def enqueue_webhooks(instance, user, request_id, action): """ Find Webhook(s) assigned to this instance + action and enqueue them to be processed @@ -48,5 +48,6 @@ def enqueue_webhooks(instance, user, action): instance._meta.model_name, action, str(datetime.datetime.now()), - user.username + user.username, + request_id ) diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py index 13805c77d..45d996f9b 100644 --- a/netbox/extras/webhooks_worker.py +++ b/netbox/extras/webhooks_worker.py @@ -10,7 +10,7 @@ from extras.constants import WEBHOOK_CT_JSON, WEBHOOK_CT_X_WWW_FORM_ENCODED, OBJ @job('default') -def process_webhook(webhook, data, model_name, event, timestamp, username): +def process_webhook(webhook, data, model_name, event, timestamp, username, request_id): """ Make a POST request to the defined Webhook """ @@ -19,6 +19,7 @@ def process_webhook(webhook, data, model_name, event, timestamp, username): 'timestamp': timestamp, 'model': model_name, 'username': username, + 'request_id': request_id, 'data': data } headers = { From 3f5f75c71fcab43ef6dc7a8024eef08da449dcff Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 28 Mar 2019 09:57:26 -0400 Subject: [PATCH 18/25] Fixes #3001: Fix API representation of ObjectChange action and add changed_object_type --- CHANGELOG.md | 1 + netbox/extras/api/serializers.py | 19 +++++++++++++++---- netbox/extras/api/views.py | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94969799b..3e845a791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ v2.5.9 (FUTURE) * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE * [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry * [#2998](https://github.com/digitalocean/netbox/issues/2998) - Limit device query to non-racked devices if no rack selected when creating a cable +* [#3001](https://github.com/digitalocean/netbox/issues/3001) - Fix API representation of ObjectChange `action` and add `changed_object_type` * [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering * [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index 88de52929..6e860a8c7 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -208,14 +208,25 @@ class ReportDetailSerializer(ReportSerializer): # class ObjectChangeSerializer(serializers.ModelSerializer): - user = NestedUserSerializer(read_only=True) - content_type = ContentTypeField(read_only=True) - changed_object = serializers.SerializerMethodField(read_only=True) + user = NestedUserSerializer( + read_only=True + ) + action = ChoiceField( + choices=OBJECTCHANGE_ACTION_CHOICES, + read_only=True + ) + changed_object_type = ContentTypeField( + read_only=True + ) + changed_object = serializers.SerializerMethodField( + read_only=True + ) class Meta: model = ObjectChange fields = [ - 'id', 'time', 'user', 'user_name', 'request_id', 'action', 'content_type', 'changed_object', 'object_data', + 'id', 'time', 'user', 'user_name', 'request_id', 'action', 'changed_object_type', 'changed_object', + 'object_data', ] def get_changed_object(self, obj): diff --git a/netbox/extras/api/views.py b/netbox/extras/api/views.py index 3fcb14920..ec30c6a66 100644 --- a/netbox/extras/api/views.py +++ b/netbox/extras/api/views.py @@ -10,7 +10,7 @@ from taggit.models import Tag from extras import filters from extras.models import ( - ConfigContext, CustomField, ExportTemplate, Graph, ImageAttachment, ObjectChange, ReportResult, TopologyMap, + ConfigContext, ExportTemplate, Graph, ImageAttachment, ObjectChange, ReportResult, TopologyMap, ) from extras.reports import get_report, get_reports from utilities.api import FieldChoicesViewSet, IsAuthenticatedOrLoginNotRequired, ModelViewSet @@ -24,6 +24,7 @@ from . import serializers class ExtrasFieldChoicesViewSet(FieldChoicesViewSet): fields = ( (Graph, ['type']), + (ObjectChange, ['action']), ) From dff31654020d1e91b79be3fbee58be37dd1cf034 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 28 Mar 2019 10:06:25 -0400 Subject: [PATCH 19/25] Fixes #3026: Tweak prefix/IP filter forms to filter using VRF ID rather than route distinguisher --- CHANGELOG.md | 3 ++- netbox/ipam/forms.py | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e845a791..a69780d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ v2.5.9 (FUTURE) ## Bug Fixes -* [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes Deterministic Ordering of Interfaces +* [#2207](https://github.com/digitalocean/netbox/issues/2207) - Fixes deterministic ordering of interfaces * [#2577](https://github.com/digitalocean/netbox/issues/2577) - Clarification of wording in API regarding filtering * [#2924](https://github.com/digitalocean/netbox/issues/2924) - Add interface type for QSFP28 50GE * [#2936](https://github.com/digitalocean/netbox/issues/2936) - Fix device role selection showing duplicate first entry @@ -16,6 +16,7 @@ v2.5.9 (FUTURE) * [#3001](https://github.com/digitalocean/netbox/issues/3001) - Fix API representation of ObjectChange `action` and add `changed_object_type` * [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering * [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint +* [#3026](https://github.com/digitalocean/netbox/issues/3026) - Tweak prefix/IP filter forms to filter using VRF ID rather than route distinguisher v2.5.8 (2019-03-11) diff --git a/netbox/ipam/forms.py b/netbox/ipam/forms.py index 1274164ca..f96f1a6a2 100644 --- a/netbox/ipam/forms.py +++ b/netbox/ipam/forms.py @@ -524,14 +524,12 @@ class PrefixFilterForm(BootstrapMixin, CustomFieldFilterForm): label='Mask length', widget=StaticSelect2() ) - vrf = FilterChoiceField( + vrf_id = FilterChoiceField( queryset=VRF.objects.all(), - to_field_name='rd', label='VRF', null_label='-- Global --', widget=APISelectMultiple( api_url="/api/ipam/vrfs/", - value_field="rd", null_option=True, ) ) @@ -973,14 +971,12 @@ class IPAddressFilterForm(BootstrapMixin, CustomFieldFilterForm): label='Mask length', widget=StaticSelect2() ) - vrf = FilterChoiceField( + vrf_id = FilterChoiceField( queryset=VRF.objects.all(), - to_field_name='rd', label='VRF', null_label='-- Global --', widget=APISelectMultiple( api_url="/api/ipam/vrfs/", - value_field="rd", null_option=True, ) ) From 498f132cadcfadafb11ff8a2882734c4e8ecec4d Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 28 Mar 2019 10:16:28 -0400 Subject: [PATCH 20/25] Fixes #3027: Ignore empty local context data when rendering config contexts --- CHANGELOG.md | 1 + netbox/extras/models.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a69780d3f..9cb11f667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ v2.5.9 (FUTURE) * [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering * [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint * [#3026](https://github.com/digitalocean/netbox/issues/3026) - Tweak prefix/IP filter forms to filter using VRF ID rather than route distinguisher +* [#3027](https://github.com/digitalocean/netbox/issues/3027) - Ignore empty local context data when rendering config contexts v2.5.8 (2019-03-11) diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 1b106a62a..ad31c3821 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -720,7 +720,7 @@ class ConfigContextModel(models.Model): data = deepmerge(data, context.data) # If the object has local config context data defined, merge it last - if self.local_context_data is not None: + if self.local_context_data: data = deepmerge(data, self.local_context_data) return data From 110387e81b9274bb208feb9f90a7e4220a2bc85c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 2 Apr 2019 11:05:16 -0400 Subject: [PATCH 21/25] Fixes #3019: Fix tag population when running NetBox within a path --- CHANGELOG.md | 1 + netbox/project-static/js/forms.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb11f667..81ac2de96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ v2.5.9 (FUTURE) * [#2998](https://github.com/digitalocean/netbox/issues/2998) - Limit device query to non-racked devices if no rack selected when creating a cable * [#3001](https://github.com/digitalocean/netbox/issues/3001) - Fix API representation of ObjectChange `action` and add `changed_object_type` * [#3014](https://github.com/digitalocean/netbox/issues/3014) - Fixes VM Role filtering +* [#3019](https://github.com/digitalocean/netbox/issues/3019) - Fix tag population when running NetBox within a path * [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint * [#3026](https://github.com/digitalocean/netbox/issues/3026) - Tweak prefix/IP filter forms to filter using VRF ID rather than route distinguisher * [#3027](https://github.com/digitalocean/netbox/issues/3027) - Ignore empty local context data when rendering config contexts diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 81ddb9ffd..3c1ed5a2a 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -250,7 +250,7 @@ $(document).ready(function() { ajax: { delay: 250, - url: "/api/extras/tags/", + url: netbox_api_path + "extras/tags/", data: function(params) { // Paging. Note that `params.page` indexes at 1 From d23ca041cfe5a68fa9c6e7ea4755596634e5b800 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 2 Apr 2019 11:17:14 -0400 Subject: [PATCH 22/25] Ensure fallback to default serializer when attempting to load nested serializer --- netbox/utilities/api.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/netbox/utilities/api.py b/netbox/utilities/api.py index e0e7f3c71..fbebd09ff 100644 --- a/netbox/utilities/api.py +++ b/netbox/utilities/api.py @@ -21,6 +21,10 @@ class ServiceUnavailable(APIException): default_detail = "Service temporarily unavailable, please try again later." +class SerializerNotFound(Exception): + pass + + def get_serializer_for_model(model, prefix=''): """ Dynamically resolve and return the appropriate serializer for a model. @@ -32,7 +36,7 @@ def get_serializer_for_model(model, prefix=''): try: return dynamic_import(serializer_name) except AttributeError: - raise Exception( + raise SerializerNotFound( "Could not determine serializer for {}.{} with prefix '{}'".format(app_name, model_name, prefix) ) @@ -236,9 +240,10 @@ class ModelViewSet(_ModelViewSet): # exists request = self.get_serializer_context()['request'] if request.query_params.get('brief', False): - serializer_class = get_serializer_for_model(self.queryset.model, prefix='Nested') - if serializer_class is not None: - return serializer_class + try: + return get_serializer_for_model(self.queryset.model, prefix='Nested') + except SerializerNotFound: + pass # Fall back to the hard-coded serializer class return self.serializer_class From 3602d5a84c37c88148e1eef0c9d34e8b8401fe83 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 2 Apr 2019 11:42:49 -0400 Subject: [PATCH 23/25] Fixes #3032: Save assigned tags when creating a new secret --- CHANGELOG.md | 1 + netbox/secrets/views.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ac2de96..1c0c9bf3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ v2.5.9 (FUTURE) * [#3022](https://github.com/digitalocean/netbox/issues/3022) - Add missing cable termination types to DCIM `_choices` endpoint * [#3026](https://github.com/digitalocean/netbox/issues/3026) - Tweak prefix/IP filter forms to filter using VRF ID rather than route distinguisher * [#3027](https://github.com/digitalocean/netbox/issues/3027) - Ignore empty local context data when rendering config contexts +* [#3032](https://github.com/digitalocean/netbox/issues/3032) - Save assigned tags when creating a new secret v2.5.8 (2019-03-11) diff --git a/netbox/secrets/views.py b/netbox/secrets/views.py index 91d8caf0d..99b725528 100644 --- a/netbox/secrets/views.py +++ b/netbox/secrets/views.py @@ -120,6 +120,8 @@ def secret_add(request, pk): secret.plaintext = str(form.cleaned_data['plaintext']) secret.encrypt(master_key) secret.save() + form.save_m2m() + messages.success(request, "Added new secret: {}.".format(secret)) if '_addanother' in request.POST: return redirect('dcim:device_addsecret', pk=device.pk) From 738a20ad34f9cf009307b362167e4312a211ca0e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 2 Apr 2019 11:54:00 -0400 Subject: [PATCH 24/25] Release v2.5.9 --- CHANGELOG.md | 4 +++- netbox/netbox/settings.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c0c9bf3a..cd2e02e57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -v2.5.9 (FUTURE) +v2.5.9 (2019-04-01) ## Enhancements @@ -21,6 +21,8 @@ v2.5.9 (FUTURE) * [#3027](https://github.com/digitalocean/netbox/issues/3027) - Ignore empty local context data when rendering config contexts * [#3032](https://github.com/digitalocean/netbox/issues/3032) - Save assigned tags when creating a new secret +--- + v2.5.8 (2019-03-11) ## Enhancements diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 389fead42..aee431382 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -22,7 +22,7 @@ except ImportError: ) -VERSION = '2.5.9-dev' +VERSION = '2.5.9' BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) From 7c6d2a6281915711a27c312696c160d3291c71d5 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 2 Apr 2019 12:37:39 -0400 Subject: [PATCH 25/25] Post-release version bump --- 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 aee431382..471b6acb0 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -22,7 +22,7 @@ except ImportError: ) -VERSION = '2.5.9' +VERSION = '2.5.10-dev' BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))