From 14b9a12a2fbb24b5491c90ae333dff26035de7f2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 10:27:33 -0400 Subject: [PATCH 01/74] 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 c7116b0af..8b1541a23 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -16,7 +16,7 @@ from django.core.validators import URLValidator # Environment setup # -VERSION = '2.8.1' +VERSION = '2.8.2-dev' # Hostname HOSTNAME = platform.node() From c0b1ae49236afb6a96525d42fb6d81086cdac5a1 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 11:02:35 -0400 Subject: [PATCH 02/74] Initialize v2.9 development --- 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 8b1541a23..711402c54 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -16,7 +16,7 @@ from django.core.validators import URLValidator # Environment setup # -VERSION = '2.8.2-dev' +VERSION = '2.9.0-dev' # Hostname HOSTNAME = platform.node() From 750deac2cf096500cee763c9c825eb9e7ccadd6f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 15:25:47 -0400 Subject: [PATCH 03/74] Initial implementation of UserConfig model --- netbox/users/migrations/0004_userconfig.py | 28 ++++++ netbox/users/models.py | 103 +++++++++++++++++++++ netbox/users/tests/test_models.py | 88 ++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 netbox/users/migrations/0004_userconfig.py create mode 100644 netbox/users/tests/test_models.py diff --git a/netbox/users/migrations/0004_userconfig.py b/netbox/users/migrations/0004_userconfig.py new file mode 100644 index 000000000..f8ca3e01b --- /dev/null +++ b/netbox/users/migrations/0004_userconfig.py @@ -0,0 +1,28 @@ +# Generated by Django 3.0.5 on 2020-04-23 15:49 + +from django.conf import settings +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('users', '0002_standardize_description'), + ] + + operations = [ + migrations.CreateModel( + name='UserConfig', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), + ('data', django.contrib.postgres.fields.jsonb.JSONField(default=dict)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='config', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'ordering': ['user'], + }, + ), + ] diff --git a/netbox/users/models.py b/netbox/users/models.py index 5be784777..012eadfa0 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -2,6 +2,7 @@ import binascii import os from django.contrib.auth.models import User +from django.contrib.postgres.fields import JSONField from django.core.validators import MinLengthValidator from django.db import models from django.utils import timezone @@ -9,9 +10,111 @@ from django.utils import timezone __all__ = ( 'Token', + 'UserConfig', ) +class UserConfig(models.Model): + """ + This model stores arbitrary user-specific preferences in a JSON data structure. + """ + user = models.OneToOneField( + to=User, + on_delete=models.CASCADE, + related_name='config' + ) + data = JSONField( + default=dict + ) + + class Meta: + ordering = ['user'] + + def get(self, path): + """ + Retrieve a configuration parameter specified by its dotted path. Example: + + userconfig.get('foo.bar.baz') + + :param path: Dotted path to the configuration key. For example, 'foo.bar' returns self.data['foo']['bar']. + """ + d = self.data + keys = path.split('.') + + # Iterate down the hierarchy, returning None for any invalid keys + for key in keys: + if type(d) is dict: + d = d.get(key) + else: + return None + + return d + + def set(self, path, value, commit=False): + """ + Define or overwrite a configuration parameter. Example: + + userconfig.set('foo.bar.baz', 123) + + Leaf nodes (those which are not dictionaries of other nodes) cannot be overwritten as dictionaries. Similarly, + branch nodes (dictionaries) cannot be overwritten as single values. (A TypeError exception will be raised.) In + both cases, the existing key must first be cleared. This safeguard is in place to help avoid inadvertently + overwriting the wrong key. + + :param path: Dotted path to the configuration key. For example, 'foo.bar' sets self.data['foo']['bar']. + :param value: The value to be written. This can be any type supported by JSON. + :param commit: If true, the UserConfig instance will be saved once the new value has been applied. + """ + d = self.data + keys = path.split('.') + + # Iterate through the hierarchy to find the key we're setting. Raise TypeError if we encounter any + # interim leaf nodes (keys which do not contain dictionaries). + for i, key in enumerate(keys[:-1]): + if key in d and type(d[key]) is dict: + d = d[key] + elif key in d: + err_path = '.'.join(path.split('.')[:i + 1]) + raise TypeError(f"Key '{err_path}' is a leaf node; cannot assign new keys") + else: + d = d.setdefault(key, {}) + + # Set a key based on the last item in the path. Raise TypeError if attempting to overwrite a non-leaf node. + key = keys[-1] + if key in d and type(d[key]) is dict: + raise TypeError(f"Key '{path}' has child keys; cannot assign a value") + else: + d[key] = value + + if commit: + self.save() + + def clear(self, path, commit=False): + """ + Delete a configuration parameter specified by its dotted path. The key and any child keys will be deleted. + Example: + + userconfig.clear('foo.bar.baz') + + A KeyError is raised in the event any key along the path does not exist. + + :param path: Dotted path to the configuration key. For example, 'foo.bar' deletes self.data['foo']['bar']. + :param commit: If true, the UserConfig instance will be saved once the new value has been applied. + """ + d = self.data + keys = path.split('.') + + for key in keys[:-1]: + if key in d and type(d[key]) is dict: + d = d[key] + + key = keys[-1] + del(d[key]) + + if commit: + self.save() + + class Token(models.Model): """ An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens. diff --git a/netbox/users/tests/test_models.py b/netbox/users/tests/test_models.py new file mode 100644 index 000000000..55dba997b --- /dev/null +++ b/netbox/users/tests/test_models.py @@ -0,0 +1,88 @@ +from django.contrib.auth.models import User +from django.test import TestCase + +from users.models import UserConfig + + +class UserConfigTest(TestCase): + + def setUp(self): + + user = User.objects.create_user(username='testuser') + initial_data = { + 'a': True, + 'b': { + 'foo': 101, + 'bar': 102, + }, + 'c': { + 'foo': { + 'x': 201, + }, + 'bar': { + 'y': 202, + }, + 'baz': { + 'z': 203, + } + } + } + + self.userconfig = UserConfig(user=user, data=initial_data) + + def test_get(self): + userconfig = self.userconfig + + # Retrieve root and nested values + self.assertEqual(userconfig.get('a'), True) + self.assertEqual(userconfig.get('b.foo'), 101) + self.assertEqual(userconfig.get('c.baz.z'), 203) + + # Invalid values should return None + self.assertIsNone(userconfig.get('invalid')) + self.assertIsNone(userconfig.get('a.invalid')) + self.assertIsNone(userconfig.get('b.foo.invalid')) + self.assertIsNone(userconfig.get('b.foo.x.invalid')) + + def test_set(self): + userconfig = self.userconfig + + # Overwrite existing values + userconfig.set('a', 'abc') + userconfig.set('c.foo.x', 'abc') + self.assertEqual(userconfig.data['a'], 'abc') + self.assertEqual(userconfig.data['c']['foo']['x'], 'abc') + + # Create new values + userconfig.set('d', 'abc') + userconfig.set('b.baz', 'abc') + self.assertEqual(userconfig.data['d'], 'abc') + self.assertEqual(userconfig.data['b']['baz'], 'abc') + self.assertIsNone(userconfig.pk) + + # Set a value and commit to the database + userconfig.set('a', 'def', commit=True) + self.assertEqual(userconfig.data['a'], 'def') + self.assertIsNotNone(userconfig.pk) + + # Attempt to change a branch node to a leaf node + with self.assertRaises(TypeError): + userconfig.set('b', 1) + + # Attempt to change a leaf node to a branch node + with self.assertRaises(TypeError): + userconfig.set('a.x', 1) + + def test_clear(self): + userconfig = self.userconfig + + # Clear existing values + userconfig.clear('a') + userconfig.clear('b.foo') + self.assertTrue('a' not in userconfig.data) + self.assertTrue('foo' not in userconfig.data['b']) + self.assertEqual(userconfig.data['b']['bar'], 102) + + # Clear an invalid value + with self.assertRaises(KeyError): + userconfig.clear('invalid') From afa0565a44c43cf15d6fdfe2f05c88a6579350ea Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 15:53:43 -0400 Subject: [PATCH 04/74] Show user config in admin UI --- netbox/users/admin.py | 10 +++++++++- netbox/users/migrations/0004_userconfig.py | 4 ++-- netbox/users/models.py | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/netbox/users/admin.py b/netbox/users/admin.py index 289a1efcd..42e651712 100644 --- a/netbox/users/admin.py +++ b/netbox/users/admin.py @@ -3,17 +3,25 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin as UserAdmin_ from django.contrib.auth.models import User -from .models import Token +from .models import Token, UserConfig # Unregister the built-in UserAdmin so that we can use our custom admin view below admin.site.unregister(User) +class UserConfigInline(admin.TabularInline): + model = UserConfig + readonly_fields = ('data',) + can_delete = False + verbose_name = 'Preferences' + + @admin.register(User) class UserAdmin(UserAdmin_): list_display = [ 'username', 'email', 'first_name', 'last_name', 'is_superuser', 'is_staff', 'is_active' ] + inlines = (UserConfigInline,) class TokenAdminForm(forms.ModelForm): diff --git a/netbox/users/migrations/0004_userconfig.py b/netbox/users/migrations/0004_userconfig.py index f8ca3e01b..ba8438741 100644 --- a/netbox/users/migrations/0004_userconfig.py +++ b/netbox/users/migrations/0004_userconfig.py @@ -1,5 +1,3 @@ -# Generated by Django 3.0.5 on 2020-04-23 15:49 - from django.conf import settings import django.contrib.postgres.fields.jsonb from django.db import migrations, models @@ -23,6 +21,8 @@ class Migration(migrations.Migration): ], options={ 'ordering': ['user'], + 'verbose_name': 'User Preferences', + 'verbose_name_plural': 'User Preferences' }, ), ] diff --git a/netbox/users/models.py b/netbox/users/models.py index 012eadfa0..228b5aace 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -29,6 +29,7 @@ class UserConfig(models.Model): class Meta: ordering = ['user'] + verbose_name = verbose_name_plural = 'User Preferences' def get(self, path): """ From f3012ed839a3dc68eb9d18d298dce31ceb081dd2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 16:36:12 -0400 Subject: [PATCH 05/74] Automatically create UserConfig for users --- .../migrations/0005_create_userconfigs.py | 27 +++++++++++++++++++ netbox/users/models.py | 18 ++++++++++--- netbox/users/tests/test_models.py | 9 ++++--- 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 netbox/users/migrations/0005_create_userconfigs.py diff --git a/netbox/users/migrations/0005_create_userconfigs.py b/netbox/users/migrations/0005_create_userconfigs.py new file mode 100644 index 000000000..39ce174f6 --- /dev/null +++ b/netbox/users/migrations/0005_create_userconfigs.py @@ -0,0 +1,27 @@ +from django.contrib.auth import get_user_model +from django.db import migrations + + +def create_userconfigs(apps, schema_editor): + """ + Create an empty UserConfig instance for each existing User. + """ + User = get_user_model() + UserConfig = apps.get_model('users', 'UserConfig') + UserConfig.objects.bulk_create( + [UserConfig(user_id=user.pk) for user in User.objects.all()] + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0004_userconfig'), + ] + + operations = [ + migrations.RunPython( + code=create_userconfigs, + reverse_code=migrations.RunPython.noop + ), + ] diff --git a/netbox/users/models.py b/netbox/users/models.py index 228b5aace..d401ad68e 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -5,6 +5,8 @@ from django.contrib.auth.models import User from django.contrib.postgres.fields import JSONField from django.core.validators import MinLengthValidator from django.db import models +from django.db.models.signals import post_save +from django.dispatch import receiver from django.utils import timezone @@ -31,23 +33,24 @@ class UserConfig(models.Model): ordering = ['user'] verbose_name = verbose_name_plural = 'User Preferences' - def get(self, path): + def get(self, path, default=None): """ Retrieve a configuration parameter specified by its dotted path. Example: userconfig.get('foo.bar.baz') :param path: Dotted path to the configuration key. For example, 'foo.bar' returns self.data['foo']['bar']. + :param default: Default value to return for a nonexistent key (default: None). """ d = self.data keys = path.split('.') - # Iterate down the hierarchy, returning None for any invalid keys + # Iterate down the hierarchy, returning the default value if any invalid key is encountered for key in keys: if type(d) is dict: d = d.get(key) else: - return None + return default return d @@ -116,6 +119,15 @@ class UserConfig(models.Model): self.save() +@receiver(post_save, sender=User) +def create_userconfig(instance, created, **kwargs): + """ + Automatically create a new UserConfig when a new User is created. + """ + if created: + UserConfig(user=instance).save() + + class Token(models.Model): """ An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens. diff --git a/netbox/users/tests/test_models.py b/netbox/users/tests/test_models.py index 55dba997b..a6d0916ac 100644 --- a/netbox/users/tests/test_models.py +++ b/netbox/users/tests/test_models.py @@ -9,7 +9,7 @@ class UserConfigTest(TestCase): def setUp(self): user = User.objects.create_user(username='testuser') - initial_data = { + user.config.data = { 'a': True, 'b': { 'foo': 101, @@ -27,8 +27,9 @@ class UserConfigTest(TestCase): } } } + user.config.save() - self.userconfig = UserConfig(user=user, data=initial_data) + self.userconfig = user.config def test_get(self): userconfig = self.userconfig @@ -58,12 +59,12 @@ class UserConfigTest(TestCase): userconfig.set('b.baz', 'abc') self.assertEqual(userconfig.data['d'], 'abc') self.assertEqual(userconfig.data['b']['baz'], 'abc') - self.assertIsNone(userconfig.pk) # Set a value and commit to the database userconfig.set('a', 'def', commit=True) + + userconfig.refresh_from_db() self.assertEqual(userconfig.data['a'], 'def') - self.assertIsNotNone(userconfig.pk) # Attempt to change a branch node to a leaf node with self.assertRaises(TypeError): From 30c3d6ee406eed8bf30cad1d19ade37caac356c0 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 23 Apr 2020 16:48:13 -0400 Subject: [PATCH 06/74] Remember user's per_page preference (POC for UserConfig) --- netbox/utilities/paginator.py | 19 +++++++++++++++++++ netbox/utilities/views.py | 5 ++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/netbox/utilities/paginator.py b/netbox/utilities/paginator.py index cf91df3ca..d6e0ad10c 100644 --- a/netbox/utilities/paginator.py +++ b/netbox/utilities/paginator.py @@ -37,3 +37,22 @@ class EnhancedPage(Page): page_list.insert(page_list.index(i), False) return page_list + + +def get_paginate_count(request): + """ + Determine the length of a page, using the following in order: + + 1. per_page URL query parameter + 2. Saved user preference + 3. PAGINATE_COUNT global setting. + """ + if 'per_page' in request.GET: + try: + per_page = int(request.GET.get('per_page')) + request.user.config.set('paginate_count', per_page, commit=True) + return per_page + except ValueError: + pass + + return request.user.config.get('paginate_count', settings.PAGINATE_COUNT) diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index b671eec9c..294acb1d1 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -2,7 +2,6 @@ import logging import sys from copy import deepcopy -from django.conf import settings from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldDoesNotExist, ValidationError @@ -29,7 +28,7 @@ from utilities.forms import BootstrapMixin, CSVDataField from utilities.utils import csv_format, prepare_cloned_fields from .error_handlers import handle_protectederror from .forms import ConfirmationForm, ImportForm -from .paginator import EnhancedPaginator +from .paginator import EnhancedPaginator, get_paginate_count class GetReturnURLMixin(object): @@ -172,7 +171,7 @@ class ObjectListView(View): # Apply the request context paginate = { 'paginator_class': EnhancedPaginator, - 'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT) + 'per_page': get_paginate_count(request) } RequestConfig(request, paginate).configure(table) From d8494e44e78eab1730952239fa365a5a5f85333b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 09:23:58 -0400 Subject: [PATCH 07/74] Document available user preferences --- docs/development/user-preferences.md | 9 +++++++++ mkdocs.yml | 1 + netbox/templates/users/preferences.html | 18 ++++++++++++++++++ netbox/utilities/paginator.py | 4 ++-- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 docs/development/user-preferences.md create mode 100644 netbox/templates/users/preferences.html diff --git a/docs/development/user-preferences.md b/docs/development/user-preferences.md new file mode 100644 index 000000000..b81117ac9 --- /dev/null +++ b/docs/development/user-preferences.md @@ -0,0 +1,9 @@ +# User Preferences + +The `users.UserConfig` model holds individual preferences for each user in the form of JSON data. This page serves as a manifest of all recognized user preferences in NetBox. + +## Available Preferences + +| Name | Description | +| ---- | ----------- | +| pagination.per_page | The number of items to display per page of a paginated table | diff --git a/mkdocs.yml b/mkdocs.yml index d1ced6d8c..bed73eb9c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -72,6 +72,7 @@ nav: - Utility Views: 'development/utility-views.md' - Extending Models: 'development/extending-models.md' - Application Registry: 'development/application-registry.md' + - User Preferences: 'development/user-preferences.md' - Release Checklist: 'development/release-checklist.md' - Squashing Migrations: 'development/squashing-migrations.md' - Release Notes: diff --git a/netbox/templates/users/preferences.html b/netbox/templates/users/preferences.html new file mode 100644 index 000000000..65254645c --- /dev/null +++ b/netbox/templates/users/preferences.html @@ -0,0 +1,18 @@ +{% extends 'users/_user.html' %} +{% load helpers %} + +{% block title %}User Preferences{% endblock %} + +{% block usercontent %} + + + + + + + + + {% for %} + +
PreferenceValue
+{% endblock %} diff --git a/netbox/utilities/paginator.py b/netbox/utilities/paginator.py index d6e0ad10c..cef7c941f 100644 --- a/netbox/utilities/paginator.py +++ b/netbox/utilities/paginator.py @@ -50,9 +50,9 @@ def get_paginate_count(request): if 'per_page' in request.GET: try: per_page = int(request.GET.get('per_page')) - request.user.config.set('paginate_count', per_page, commit=True) + request.user.config.set('pagination.per_page', per_page, commit=True) return per_page except ValueError: pass - return request.user.config.get('paginate_count', settings.PAGINATE_COUNT) + return request.user.config.get('pagination.per_page', settings.PAGINATE_COUNT) From 7c8c85e435bd056c42dedf6939f0d262645eb710 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 09:50:26 -0400 Subject: [PATCH 08/74] Add all() method to UserConfig --- netbox/users/models.py | 8 ++++++++ netbox/users/tests/test_models.py | 14 ++++++++++++++ netbox/utilities/utils.py | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/netbox/users/models.py b/netbox/users/models.py index d401ad68e..c83de3f90 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -9,6 +9,8 @@ from django.db.models.signals import post_save from django.dispatch import receiver from django.utils import timezone +from utilities.utils import flatten_dict + __all__ = ( 'Token', @@ -54,6 +56,12 @@ class UserConfig(models.Model): return d + def all(self): + """ + Return a dictionary of all defined keys and their values. + """ + return flatten_dict(self.data) + def set(self, path, value, commit=False): """ Define or overwrite a configuration parameter. Example: diff --git a/netbox/users/tests/test_models.py b/netbox/users/tests/test_models.py index a6d0916ac..ec1a00326 100644 --- a/netbox/users/tests/test_models.py +++ b/netbox/users/tests/test_models.py @@ -45,6 +45,20 @@ class UserConfigTest(TestCase): self.assertIsNone(userconfig.get('b.foo.invalid')) self.assertIsNone(userconfig.get('b.foo.x.invalid')) + def test_all(self): + userconfig = self.userconfig + flattened_data = { + 'a': True, + 'b.foo': 101, + 'b.bar': 102, + 'c.foo.x': 201, + 'c.bar.y': 202, + 'c.baz.z': 203, + } + + # Retrieve a flattened dictionary containing all config data + self.assertEqual(userconfig.all(), flattened_data) + def test_set(self): userconfig = self.userconfig diff --git a/netbox/utilities/utils.py b/netbox/utilities/utils.py index 446622118..351b1fd68 100644 --- a/netbox/utilities/utils.py +++ b/netbox/utilities/utils.py @@ -239,3 +239,21 @@ def shallow_compare_dict(source_dict, destination_dict, exclude=None): difference[key] = destination_dict[key] return difference + + +def flatten_dict(d, prefix='', separator='.'): + """ + Flatten netsted dictionaries into a single level by joining key names with a separator. + + :param d: The dictionary to be flattened + :param prefix: Initial prefix (if any) + :param separator: The character to use when concatenating key names + """ + ret = {} + for k, v in d.items(): + key = separator.join([prefix, k]) if prefix else k + if type(v) is dict: + ret.update(flatten_dict(v, prefix=key)) + else: + ret[key] = v + return ret From 587339bea0457c9a9003fe94e09616c19476fa3f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 10:29:06 -0400 Subject: [PATCH 09/74] Add page for user to view/clear preferences --- netbox/templates/users/_user.html | 3 ++ netbox/templates/users/preferences.html | 39 ++++++++++++++++++------- netbox/users/urls.py | 1 + netbox/users/views.py | 24 +++++++++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/netbox/templates/users/_user.html b/netbox/templates/users/_user.html index 441caf289..d03d44fa6 100644 --- a/netbox/templates/users/_user.html +++ b/netbox/templates/users/_user.html @@ -12,6 +12,9 @@ Profile + + Preferences + {% if not request.user.ldap_username %} Change Password diff --git a/netbox/templates/users/preferences.html b/netbox/templates/users/preferences.html index 65254645c..0884c7f17 100644 --- a/netbox/templates/users/preferences.html +++ b/netbox/templates/users/preferences.html @@ -4,15 +4,32 @@ {% block title %}User Preferences{% endblock %} {% block usercontent %} - - - - - - - - - {% for %} - -
PreferenceValue
+ {% if preferences %} +
+ {% csrf_token %} + + + + + + + + + + {% for key, value in preferences.items %} + + + + + + {% endfor %} + +
PreferenceValue
{{ key }}{{ value }}
+ +
+ {% else %} +

No preferences found

+ {% endif %} {% endblock %} diff --git a/netbox/users/urls.py b/netbox/users/urls.py index dae540726..b8b16cdf8 100644 --- a/netbox/users/urls.py +++ b/netbox/users/urls.py @@ -6,6 +6,7 @@ app_name = 'user' urlpatterns = [ path('profile/', views.ProfileView.as_view(), name='profile'), + path('preferences/', views.UserConfigView.as_view(), name='preferences'), path('password/', views.ChangePasswordView.as_view(), name='change_password'), path('api-tokens/', views.TokenListView.as_view(), name='token_list'), path('api-tokens/add/', views.TokenEditView.as_view(), name='token_add'), diff --git a/netbox/users/views.py b/netbox/users/views.py index ae1345b6b..c3e366542 100644 --- a/netbox/users/views.py +++ b/netbox/users/views.py @@ -111,6 +111,30 @@ class ProfileView(LoginRequiredMixin, View): }) +class UserConfigView(LoginRequiredMixin, View): + template_name = 'users/preferences.html' + + def get(self, request): + + return render(request, self.template_name, { + 'preferences': request.user.config.all(), + 'active_tab': 'preferences', + }) + + def post(self, request): + userconfig = request.user.config + data = userconfig.all() + + # Delete selected preferences + for key in request.POST.getlist('pk'): + if key in data: + userconfig.clear(key) + userconfig.save() + messages.success(request, "Your preferences have been updated.") + + return redirect('user:preferences') + + class ChangePasswordView(LoginRequiredMixin, View): template_name = 'users/change_password.html' From dc9617c7aa6f3a78e6174601c34579babea6d450 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 10:37:02 -0400 Subject: [PATCH 10/74] Fix returning default for unknown userconfig key --- netbox/users/models.py | 2 +- netbox/users/tests/test_models.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/netbox/users/models.py b/netbox/users/models.py index c83de3f90..02356696f 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -49,7 +49,7 @@ class UserConfig(models.Model): # Iterate down the hierarchy, returning the default value if any invalid key is encountered for key in keys: - if type(d) is dict: + if type(d) is dict and key in d: d = d.get(key) else: return default diff --git a/netbox/users/tests/test_models.py b/netbox/users/tests/test_models.py index ec1a00326..0157d8fdd 100644 --- a/netbox/users/tests/test_models.py +++ b/netbox/users/tests/test_models.py @@ -45,6 +45,12 @@ class UserConfigTest(TestCase): self.assertIsNone(userconfig.get('b.foo.invalid')) self.assertIsNone(userconfig.get('b.foo.x.invalid')) + # Invalid values with a provided default should return the default + self.assertEqual(userconfig.get('invalid', 'DEFAULT'), 'DEFAULT') + self.assertEqual(userconfig.get('a.invalid', 'DEFAULT'), 'DEFAULT') + self.assertEqual(userconfig.get('b.foo.invalid', 'DEFAULT'), 'DEFAULT') + self.assertEqual(userconfig.get('b.foo.x.invalid', 'DEFAULT'), 'DEFAULT') + def test_all(self): userconfig = self.userconfig flattened_data = { From 178052b2f6bc19d0d0b063070d40ae028e934157 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 10:38:09 -0400 Subject: [PATCH 11/74] Prepare for merge into 2.8 --- 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 711402c54..8b1541a23 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -16,7 +16,7 @@ from django.core.validators import URLValidator # Environment setup # -VERSION = '2.9.0-dev' +VERSION = '2.8.2-dev' # Hostname HOSTNAME = platform.node() From ad099d79f20d535bc1c846e9a6a450834ef7761b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 11:03:14 -0400 Subject: [PATCH 12/74] Changelog for #3294, #4531 --- docs/release-notes/version-2.8.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index e6eabf8ca..ddc86316d 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -1,5 +1,14 @@ # NetBox v2.8 +## v2.8.2 (FUTURE) + +### Enhancements + +* [#3294](https://github.com/netbox-community/netbox/issues/3294) - Implement mechanism for storing user preferences +* [#4531](https://github.com/netbox-community/netbox/issues/4531) - Retain user's pagination preference + +--- + ## v2.8.1 (2020-04-23) ### Notes From f019c8d2ce5209079087bf9bc30bcae24d409143 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 11:31:01 -0400 Subject: [PATCH 13/74] Fixes #4527: Fix assignment of certain tags to config contexts --- docs/release-notes/version-2.8.md | 4 ++++ netbox/extras/forms.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index ddc86316d..c2dd7ba80 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -7,6 +7,10 @@ * [#3294](https://github.com/netbox-community/netbox/issues/3294) - Implement mechanism for storing user preferences * [#4531](https://github.com/netbox-community/netbox/issues/4531) - Retain user's pagination preference +### Bug Fixes + +* [#4527](https://github.com/netbox-community/netbox/issues/4527) - Fix assignment of certain tags to config contexts + --- ## v2.8.1 (2020-04-23) diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index 7ec9d2285..676d7ceba 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -229,7 +229,6 @@ class ConfigContextForm(BootstrapMixin, forms.ModelForm): ) tags = DynamicModelMultipleChoiceField( queryset=Tag.objects.all(), - to_field_name='slug', required=False ) data = JSONField( From bdbf21b3e2d3ceac2207e1eac7c199ec29240b7e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 12:01:41 -0400 Subject: [PATCH 14/74] Closes #4421: Retain user's preference for config context format --- docs/release-notes/version-2.8.md | 3 ++- netbox/extras/views.py | 17 ++++++++++++++++- netbox/project-static/js/configcontext.js | 11 ----------- netbox/templates/extras/configcontext.html | 6 +----- .../extras/inc/configcontext_data.html | 7 ++----- .../extras/inc/configcontext_format.html | 4 ++-- .../templates/extras/object_configcontext.html | 10 +++------- 7 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 netbox/project-static/js/configcontext.js diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index c2dd7ba80..5b73cc85d 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -5,7 +5,8 @@ ### Enhancements * [#3294](https://github.com/netbox-community/netbox/issues/3294) - Implement mechanism for storing user preferences -* [#4531](https://github.com/netbox-community/netbox/issues/4531) - Retain user's pagination preference +* [#4421](https://github.com/netbox-community/netbox/issues/4421) - Retain user's preference for config context format +* [#4531](https://github.com/netbox-community/netbox/issues/4531) - Retain user's preference for page length ### Bug Fixes diff --git a/netbox/extras/views.py b/netbox/extras/views.py index bb7d76dd0..613e45132 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -119,11 +119,18 @@ class ConfigContextView(PermissionRequiredMixin, View): permission_required = 'extras.view_configcontext' def get(self, request, pk): - configcontext = get_object_or_404(ConfigContext, pk=pk) + # Determine user's preferred output format + if request.GET.get('format') in ['json', 'yaml']: + format = request.GET.get('format') + request.user.config.set('extras.configcontext.format', format, commit=True) + else: + format = request.user.config.get('extras.configcontext.format', 'json') + return render(request, 'extras/configcontext.html', { 'configcontext': configcontext, + 'format': format, }) @@ -171,11 +178,19 @@ class ObjectConfigContextView(View): source_contexts = ConfigContext.objects.get_for_object(obj) model_name = self.object_class._meta.model_name + # Determine user's preferred output format + if request.GET.get('format') in ['json', 'yaml']: + format = request.GET.get('format') + request.user.config.set('extras.configcontext.format', format, commit=True) + else: + format = request.user.config.get('extras.configcontext.format', 'json') + return render(request, 'extras/object_configcontext.html', { model_name: obj, 'obj': obj, 'rendered_context': obj.get_config_context(), 'source_contexts': source_contexts, + 'format': format, 'base_template': self.base_template, 'active_tab': 'config-context', }) diff --git a/netbox/project-static/js/configcontext.js b/netbox/project-static/js/configcontext.js deleted file mode 100644 index 1d731e696..000000000 --- a/netbox/project-static/js/configcontext.js +++ /dev/null @@ -1,11 +0,0 @@ -$('.rendered-context-format').on('click', function() { - if (!$(this).hasClass('active')) { - // Update selection in the button group - $('span.rendered-context-format').removeClass('active'); - $('span.rendered-context-format[data-format=' + $(this).data('format') + ']').addClass('active'); - - // Hide all rendered contexts and only show the selected one - $('div.rendered-context-data').hide(); - $('div.rendered-context-data[data-format=' + $(this).data('format') + ']').show(); - } -}); diff --git a/netbox/templates/extras/configcontext.html b/netbox/templates/extras/configcontext.html index 998ab7681..21e8cdab6 100644 --- a/netbox/templates/extras/configcontext.html +++ b/netbox/templates/extras/configcontext.html @@ -215,13 +215,9 @@ {% include 'extras/inc/configcontext_format.html' %}
- {% include 'extras/inc/configcontext_data.html' with data=configcontext.data %} + {% include 'extras/inc/configcontext_data.html' with data=configcontext.data format=format %}
{% endblock %} - -{% block javascript %} - -{% endblock %} diff --git a/netbox/templates/extras/inc/configcontext_data.html b/netbox/templates/extras/inc/configcontext_data.html index d91960e2c..085887748 100644 --- a/netbox/templates/extras/inc/configcontext_data.html +++ b/netbox/templates/extras/inc/configcontext_data.html @@ -1,8 +1,5 @@ {% load helpers %} -
-
{{ data|render_json }}
-
-
- {% include 'extras/inc/configcontext_data.html' with data=rendered_context %} + {% include 'extras/inc/configcontext_data.html' with data=rendered_context format=format %}
@@ -24,7 +24,7 @@
{% if obj.local_context_data %} - {% include 'extras/inc/configcontext_data.html' with data=obj.local_context_data %} + {% include 'extras/inc/configcontext_data.html' with data=obj.local_context_data format=format %} {% else %} None {% endif %} @@ -49,7 +49,7 @@ {% if context.description %}
{{ context.description }} {% endif %} - {% include 'extras/inc/configcontext_data.html' with data=context.data %} + {% include 'extras/inc/configcontext_data.html' with data=context.data format=format %}
{% empty %}
@@ -60,7 +60,3 @@
{% endblock %} - -{% block javascript %} - -{% endblock %} From ffba1c1d438340282a55edcac9534004a8821286 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 13:11:01 -0400 Subject: [PATCH 15/74] Add extras.configcontext.format to preferences doc --- docs/development/user-preferences.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/development/user-preferences.md b/docs/development/user-preferences.md index b81117ac9..f9ca05188 100644 --- a/docs/development/user-preferences.md +++ b/docs/development/user-preferences.md @@ -6,4 +6,5 @@ The `users.UserConfig` model holds individual preferences for each user in the f | Name | Description | | ---- | ----------- | +| extras.configcontext.format | Preferred format when rendering config context data (JSON or YAML) | | pagination.per_page | The number of items to display per page of a paginated table | From fed9408b9086873ab795e1d23eb1fdd209ef86a5 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 14:59:38 -0400 Subject: [PATCH 16/74] #4416: Establish a dedicated view for VirtualChassis objects --- netbox/dcim/models/__init__.py | 2 +- netbox/dcim/tables.py | 23 ++--- netbox/dcim/urls.py | 1 + netbox/dcim/views.py | 12 ++- netbox/templates/dcim/device.html | 16 +--- netbox/templates/dcim/virtualchassis.html | 111 ++++++++++++++++++++++ 6 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 netbox/templates/dcim/virtualchassis.html diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index 096065cab..1716208fd 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -1722,7 +1722,7 @@ class VirtualChassis(ChangeLoggedModel): return str(self.master) if hasattr(self, 'master') else 'New Virtual Chassis' def get_absolute_url(self): - return self.master.get_absolute_url() + return reverse('dcim:virtualchassis', kwargs={'pk': self.pk}) def clean(self): diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 7131a6be3..0e5e9dc7a 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -165,15 +165,6 @@ UTILIZATION_GRAPH = """ {% utilization_graph value %} """ -VIRTUALCHASSIS_ACTIONS = """ - - - -{% if perms.dcim.change_virtualchassis %} - -{% endif %} -""" - CABLE_TERMINATION_PARENT = """ {% if value.device %} {{ value.device }} @@ -1050,17 +1041,17 @@ class InventoryItemTable(BaseTable): class VirtualChassisTable(BaseTable): pk = ToggleColumn() - master = tables.LinkColumn() - member_count = tables.Column(verbose_name='Members') - actions = tables.TemplateColumn( - template_code=VIRTUALCHASSIS_ACTIONS, - attrs={'td': {'class': 'text-right noprint'}}, - verbose_name='' + name = tables.Column( + accessor=Accessor('master__name'), + linkify=True + ) + member_count = tables.Column( + verbose_name='Members' ) class Meta(BaseTable.Meta): model = VirtualChassis - fields = ('pk', 'master', 'domain', 'member_count', 'actions') + fields = ('pk', 'name', 'domain', 'member_count') # diff --git a/netbox/dcim/urls.py b/netbox/dcim/urls.py index 36a272cf8..cbaea4b76 100644 --- a/netbox/dcim/urls.py +++ b/netbox/dcim/urls.py @@ -321,6 +321,7 @@ urlpatterns = [ # Virtual chassis path('virtual-chassis/', views.VirtualChassisListView.as_view(), name='virtualchassis_list'), path('virtual-chassis/add/', views.VirtualChassisCreateView.as_view(), name='virtualchassis_add'), + path('virtual-chassis//', views.VirtualChassisView.as_view(), name='virtualchassis'), path('virtual-chassis//edit/', views.VirtualChassisEditView.as_view(), name='virtualchassis_edit'), path('virtual-chassis//delete/', views.VirtualChassisDeleteView.as_view(), name='virtualchassis_delete'), path('virtual-chassis//changelog/', ObjectChangeLogView.as_view(), name='virtualchassis_changelog', kwargs={'model': VirtualChassis}), diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 9ca4c2edc..78b54789d 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -32,7 +32,6 @@ from virtualization.models import VirtualMachine from . import filters, forms, tables from .choices import DeviceFaceChoices from .constants import NONCONNECTABLE_IFACE_TYPES -from .exceptions import CableTraceSplit from .models import ( Cable, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay, DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate, @@ -2368,6 +2367,17 @@ class VirtualChassisListView(PermissionRequiredMixin, ObjectListView): action_buttons = ('export',) +class VirtualChassisView(PermissionRequiredMixin, View): + permission_required = 'dcim.view_virtualchassis' + + def get(self, request, pk): + virtualchassis = get_object_or_404(VirtualChassis.objects.prefetch_related('members'), pk=pk) + + return render(request, 'dcim/virtualchassis.html', { + 'virtualchassis': virtualchassis, + }) + + class VirtualChassisCreateView(PermissionRequiredMixin, View): permission_required = 'dcim.add_virtualchassis' diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 250774022..ef1a301e2 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -232,19 +232,9 @@ {% endfor %} {% endif %} diff --git a/netbox/templates/dcim/virtualchassis.html b/netbox/templates/dcim/virtualchassis.html new file mode 100644 index 000000000..a97c42e4f --- /dev/null +++ b/netbox/templates/dcim/virtualchassis.html @@ -0,0 +1,111 @@ +{% extends 'base.html' %} +{% load buttons %} +{% load custom_links %} +{% load helpers %} +{% load plugins %} + +{% block header %} +
+
+ +
+
+
+
+ + + + +
+
+
+
+
+ {% plugin_buttons virtualchassis %} + {% if perms.dcim.change_virtualchassis %} + {% edit_button virtualchassis %} + {% endif %} + {% if perms.dcim.delete_virtualchassis %} + {% delete_button virtualchassis %} + {% endif %} +
+

{% block title %}{{ virtualchassis }}{% endblock %}

+ {% include 'inc/created_updated.html' with obj=virtualchassis %} +
+ {% custom_links virtualchassis %} +
+ +{% endblock %} + +{% block content %} +
+
+
+
+ Virtual Chassis +
+ + + + + +
Domain{{ virtualchassis.domain|placeholder }}
+
+ {% include 'extras/inc/tags_panel.html' with tags=virtualchassis.tags.all url='dcim:virtualchassis_list' %} + {% plugin_left_page virtualchassis %} +
+
+
+
+ Members +
+ + + + + + + + {% for vc_member in virtualchassis.members.all %} + + + + + + + {% endfor %} +
DevicePositionMasterPriority
+ {{ vc_member }} + {{ vc_member.vc_position }}{% if virtualchassis.master == vc_member %}{% endif %}{{ vc_member.vc_priority|placeholder }}
+ {% if perms.dcim.change_virtualchassis %} + + {% endif %} +
+ {% plugin_right_page virtualchassis %} +
+
+
+
+ {% plugin_full_width_page virtualchassis %} +
+
+{% endblock %} From eb14c08cab142d023737741e3e3ef1a3b85699c8 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 15:01:23 -0400 Subject: [PATCH 17/74] #4416: Enable custom links for virtual chassis --- netbox/dcim/models/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index 1716208fd..4b30d20d1 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -1695,7 +1695,7 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel): # Virtual chassis # -@extras_features('export_templates', 'webhooks') +@extras_features('custom_links', 'export_templates', 'webhooks') class VirtualChassis(ChangeLoggedModel): """ A collection of Devices which operate with a shared control plane (e.g. a switch stack). From d8cb58c74653da88d9aade40548b146a9311f5e6 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 15:20:52 -0400 Subject: [PATCH 18/74] #4416: Add bulk edit & delete views for VirtualChassis --- netbox/dcim/forms.py | 14 ++++++++++++++ netbox/dcim/tests/test_views.py | 3 --- netbox/dcim/urls.py | 2 ++ netbox/dcim/views.py | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 29710971e..98b321b90 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -4388,6 +4388,20 @@ class VCMemberSelectForm(BootstrapMixin, forms.Form): return device +class VirtualChassisBulkEditForm(BootstrapMixin, BulkEditForm): + pk = forms.ModelMultipleChoiceField( + queryset=VirtualChassis.objects.all(), + widget=forms.MultipleHiddenInput() + ) + domain = forms.CharField( + max_length=30, + required=False + ) + + class Meta: + nullable_fields = ['domain'] + + class VirtualChassisFilterForm(BootstrapMixin, CustomFieldFilterForm): model = VirtualChassis q = forms.CharField( diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 2feaf625b..b1aaf4449 100644 --- a/netbox/dcim/tests/test_views.py +++ b/netbox/dcim/tests/test_views.py @@ -1507,10 +1507,7 @@ class VirtualChassisTestCase(ViewTestCases.PrimaryObjectViewTestCase): model = VirtualChassis # Disable inapplicable tests - test_get_object = None test_import_objects = None - test_bulk_edit_objects = None - test_bulk_delete_objects = None # TODO: Requires special form handling test_create_object = None diff --git a/netbox/dcim/urls.py b/netbox/dcim/urls.py index cbaea4b76..0b1f6250e 100644 --- a/netbox/dcim/urls.py +++ b/netbox/dcim/urls.py @@ -321,6 +321,8 @@ urlpatterns = [ # Virtual chassis path('virtual-chassis/', views.VirtualChassisListView.as_view(), name='virtualchassis_list'), path('virtual-chassis/add/', views.VirtualChassisCreateView.as_view(), name='virtualchassis_add'), + path('virtual-chassis/edit/', views.VirtualChassisBulkEditView.as_view(), name='virtualchassis_bulk_edit'), + path('virtual-chassis/delete/', views.VirtualChassisBulkDeleteView.as_view(), name='virtualchassis_bulk_delete'), path('virtual-chassis//', views.VirtualChassisView.as_view(), name='virtualchassis'), path('virtual-chassis//edit/', views.VirtualChassisEditView.as_view(), name='virtualchassis_edit'), path('virtual-chassis//delete/', views.VirtualChassisDeleteView.as_view(), name='virtualchassis_delete'), diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 78b54789d..66b59add4 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -2605,6 +2605,23 @@ class VirtualChassisRemoveMemberView(PermissionRequiredMixin, GetReturnURLMixin, }) +class VirtualChassisBulkEditView(PermissionRequiredMixin, BulkEditView): + permission_required = 'dcim.change_virtualchassis' + queryset = VirtualChassis.objects.all() + filterset = filters.VirtualChassisFilterSet + table = tables.VirtualChassisTable + form = forms.VirtualChassisBulkEditForm + default_return_url = 'dcim:virtualchassis_list' + + +class VirtualChassisBulkDeleteView(PermissionRequiredMixin, BulkDeleteView): + permission_required = 'dcim.delete_virtualchassis' + queryset = VirtualChassis.objects.all() + filterset = filters.VirtualChassisFilterSet + table = tables.VirtualChassisTable + default_return_url = 'dcim:virtualchassis_list' + + # # Power panels # From 4971054c34c0a168606336f46ce8dbae32d894f7 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Apr 2020 15:43:58 -0400 Subject: [PATCH 19/74] Standardize import statement as django_rq is no longer optional --- netbox/extras/webhooks.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py index d1d5a59ab..fdf69d6d5 100644 --- a/netbox/extras/webhooks.py +++ b/netbox/extras/webhooks.py @@ -3,11 +3,11 @@ import hmac from django.contrib.contenttypes.models import ContentType from django.utils import timezone +from django_rq import get_queue from extras.models import Webhook from utilities.api import get_serializer_for_model from .choices import * -from .constants import * from .utils import FeatureQuery @@ -50,12 +50,8 @@ def enqueue_webhooks(instance, user, request_id, action): } serializer = serializer_class(instance, context=serializer_context) - # We must only import django_rq if the Webhooks feature is enabled. - # Only if we have gotten to ths point, is the feature enabled - from django_rq import get_queue + # Enqueue the webhooks webhook_queue = get_queue('default') - - # enqueue the webhooks: for webhook in webhooks: webhook_queue.enqueue( "extras.webhooks_worker.process_webhook", From 0ee1112d9de7dfb8b02c7fb8b9326298a7f2c73d Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Apr 2020 16:56:25 -0400 Subject: [PATCH 20/74] Initial support for table column reordering --- netbox/circuits/tables.py | 11 ++++++++++- netbox/utilities/tables.py | 18 +++++++++++++++++- netbox/utilities/views.py | 3 ++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/netbox/circuits/tables.py b/netbox/circuits/tables.py index a425b3ace..a7e1b0e84 100644 --- a/netbox/circuits/tables.py +++ b/netbox/circuits/tables.py @@ -76,7 +76,16 @@ class CircuitTable(BaseTable): z_side = tables.Column( verbose_name='Z Side' ) + install_date = tables.Column( + visible=False + ) + commit_rate = tables.Column( + visible=False + ) class Meta(BaseTable.Meta): model = Circuit - fields = ('pk', 'cid', 'status', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'description') + fields = ( + 'pk', 'cid', 'status', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate', + 'description', + ) diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 9e91aebd2..bdbaa0b9b 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -6,13 +6,29 @@ class BaseTable(tables.Table): """ Default table for object lists """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, columns=None, **kwargs): super().__init__(*args, **kwargs) # Set default empty_text if none was provided if self.empty_text is None: self.empty_text = 'No {} found'.format(self._meta.model._meta.verbose_name_plural) + # Apply custom column ordering + if columns is not None: + pk = self.base_columns.pop('pk', None) + + for name, column in self.base_columns.items(): + if name in columns: + self.columns.show(name) + else: + self.columns.hide(name) + self.sequence = columns + + # Always include PK column, if defined on the table + if pk: + self.base_columns['pk'] = pk + self.sequence.insert(0, 'pk') + class Meta: attrs = { 'class': 'table table-hover table-headings', diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index 294acb1d1..1782f1457 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -164,7 +164,8 @@ class ObjectListView(View): permissions[action] = request.user.has_perm(perm_name) # Construct the table based on the user's permissions - table = self.table(self.queryset) + columns = request.user.config.get(f"tables.{self.table.__name__}.columns") + table = self.table(self.queryset, columns=columns) if 'pk' in table.base_columns and (permissions['change'] or permissions['delete']): table.columns.show('pk') From e8d493578b4890743abae7cbbdd9da1143876b23 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 12:14:51 -0400 Subject: [PATCH 21/74] Create form for setting table preferences --- netbox/templates/inc/table_config_form.html | 23 +++++++++ netbox/templates/utilities/obj_list.html | 3 ++ netbox/utilities/forms.py | 55 ++++++++++++++++----- netbox/utilities/tables.py | 22 +++++++-- netbox/utilities/views.py | 7 ++- 5 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 netbox/templates/inc/table_config_form.html diff --git a/netbox/templates/inc/table_config_form.html b/netbox/templates/inc/table_config_form.html new file mode 100644 index 000000000..7a831be3c --- /dev/null +++ b/netbox/templates/inc/table_config_form.html @@ -0,0 +1,23 @@ +{% load form_helpers %} + + + diff --git a/netbox/templates/utilities/obj_list.html b/netbox/templates/utilities/obj_list.html index f5482baf0..ea28c7682 100644 --- a/netbox/templates/utilities/obj_list.html +++ b/netbox/templates/utilities/obj_list.html @@ -18,6 +18,9 @@

{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}

+ {% if table_config_form %} + {% include 'inc/table_config_form.html' %} + {% endif %} {% with bulk_edit_url=content_type.model_class|url_name:"bulk_edit" bulk_delete_url=content_type.model_class|url_name:"bulk_delete" %} {% if permissions.change or permissions.delete %}
diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py index d95c86527..f8d098d66 100644 --- a/netbox/utilities/forms.py +++ b/netbox/utilities/forms.py @@ -137,6 +137,27 @@ def form_from_model(model, fields): return type('FormFromModel', (forms.Form,), form_fields) +def apply_bootstrap_classes(form): + """ + Apply Bootstrap CSS classes to form elements. + """ + exempt_widgets = [ + forms.CheckboxInput, + forms.ClearableFileInput, + forms.FileInput, + forms.RadioSelect + ] + + for field_name, field in form.fields.items(): + if field.widget.__class__ not in exempt_widgets: + css = field.widget.attrs.get('class', '') + field.widget.attrs['class'] = ' '.join([css, 'form-control']).strip() + if field.required and not isinstance(field.widget, forms.FileInput): + field.widget.attrs['required'] = 'required' + if 'placeholder' not in field.widget.attrs: + field.widget.attrs['placeholder'] = field.label + + # # Widgets # @@ -663,19 +684,7 @@ class BootstrapMixin(forms.BaseForm): """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - - exempt_widgets = [ - forms.CheckboxInput, forms.ClearableFileInput, forms.FileInput, forms.RadioSelect - ] - - for field_name, field in self.fields.items(): - if field.widget.__class__ not in exempt_widgets: - css = field.widget.attrs.get('class', '') - field.widget.attrs['class'] = ' '.join([css, 'form-control']).strip() - if field.required and not isinstance(field.widget, forms.FileInput): - field.widget.attrs['required'] = 'required' - if 'placeholder' not in field.widget.attrs: - field.widget.attrs['placeholder'] = field.label + apply_bootstrap_classes(self) class ReturnURLForm(forms.Form): @@ -752,3 +761,23 @@ class ImportForm(BootstrapMixin, forms.Form): raise forms.ValidationError({ 'data': "Invalid YAML data: {}".format(err) }) + + +class TableConfigForm(forms.Form): + """ + Form for configuring user's table preferences. + """ + def __init__(self, table, *args, **kwargs): + super().__init__(*args, **kwargs) + + field_name = f"tables.{table.__class__.__name__}.columns" + self.fields[field_name] = forms.MultipleChoiceField( + choices=table.configurable_columns, + initial=table.visible_columns, + label='Columns', + widget=forms.SelectMultiple( + attrs={'size': 10} + ) + ) + + apply_bootstrap_classes(self) diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index bdbaa0b9b..7da664c43 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -6,6 +6,11 @@ class BaseTable(tables.Table): """ Default table for object lists """ + class Meta: + attrs = { + 'class': 'table table-hover table-headings', + } + def __init__(self, *args, columns=None, **kwargs): super().__init__(*args, **kwargs) @@ -29,10 +34,19 @@ class BaseTable(tables.Table): self.base_columns['pk'] = pk self.sequence.insert(0, 'pk') - class Meta: - attrs = { - 'class': 'table table-hover table-headings', - } + @property + def configurable_columns(self): + selected_columns = [ + (name, self.columns[name].verbose_name) for name in self.sequence if name != 'pk' + ] + available_columns = [ + (name, column.verbose_name) for name, column in self.columns.items() if name not in self.sequence and name != 'pk' + ] + return selected_columns + available_columns + + @property + def visible_columns(self): + return [name for name in self.sequence if self.columns[name].visible] class ToggleColumn(tables.CheckBoxColumn): diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index 1782f1457..8da8a1961 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -24,7 +24,7 @@ from django_tables2 import RequestConfig from extras.models import CustomField, CustomFieldValue, ExportTemplate from extras.querysets import CustomFieldQueryset from utilities.exceptions import AbortTransaction -from utilities.forms import BootstrapMixin, CSVDataField +from utilities.forms import BootstrapMixin, CSVDataField, TableConfigForm from utilities.utils import csv_format, prepare_cloned_fields from .error_handlers import handle_protectederror from .forms import ConfirmationForm, ImportForm @@ -176,11 +176,16 @@ class ObjectListView(View): } RequestConfig(request, paginate).configure(table) + table_config_form = TableConfigForm( + table=table + ) + context = { 'content_type': content_type, 'table': table, 'permissions': permissions, 'action_buttons': self.action_buttons, + 'table_config_form': table_config_form, 'filter_form': self.filterset_form(request.GET, label_suffix='') if self.filterset_form else None, } context.update(self.extra_context()) From 3442ec77a7cc4dbc34d02f6d3f1085e8ad21c1fe Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 13:21:58 -0400 Subject: [PATCH 22/74] Enable setting/clearing of table column prefs --- netbox/templates/inc/table_config_form.html | 2 +- netbox/utilities/forms.py | 61 +++++++++------------ netbox/utilities/views.py | 22 ++++++-- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/netbox/templates/inc/table_config_form.html b/netbox/templates/inc/table_config_form.html index 7a831be3c..311345b4f 100644 --- a/netbox/templates/inc/table_config_form.html +++ b/netbox/templates/inc/table_config_form.html @@ -9,7 +9,7 @@
diff --git a/netbox/templates/utilities/obj_list.html b/netbox/templates/utilities/obj_list.html index ea28c7682..4cfa8b1ce 100644 --- a/netbox/templates/utilities/obj_list.html +++ b/netbox/templates/utilities/obj_list.html @@ -5,6 +5,9 @@ {% block content %}
{% block buttons %}{% endblock %} + {% if table_config_form %} + + {% endif %} {% if permissions.add and 'add' in action_buttons %} {% add_button content_type.model_class|url_name:"add" %} {% endif %} @@ -18,9 +21,6 @@

{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}

- {% if table_config_form %} - {% include 'inc/table_config_form.html' %} - {% endif %} {% with bulk_edit_url=content_type.model_class|url_name:"bulk_edit" bulk_delete_url=content_type.model_class|url_name:"bulk_delete" %} {% if permissions.change or permissions.delete %}
@@ -71,6 +71,9 @@ {% endwith %} {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
+ {% if table_config_form %} + {% include 'inc/table_config_form.html' %} + {% endif %}
{% if filter_form %}
diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py index e0ce09997..c1d925999 100644 --- a/netbox/utilities/forms.py +++ b/netbox/utilities/forms.py @@ -765,7 +765,8 @@ class TableConfigForm(BootstrapMixin, forms.Form): choices=[], widget=forms.SelectMultiple( attrs={'size': 10} - ) + ), + help_text="Use the buttons below to arrange columns in the desired order, then select all columns to display." ) def __init__(self, table, *args, **kwargs): diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index 8b4942201..eca124a4a 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -202,7 +202,7 @@ class ObjectListView(View): request.user.config.clear(preference_name, commit=True) messages.success(request, "Your preferences have been updated.") - return redirect(request.path) + return redirect(request.get_full_path()) def alter_queryset(self, request): # .all() is necessary to avoid caching queries From 96eafe6dc157c635c6069179094dfe3085ee9c36 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 14:32:32 -0400 Subject: [PATCH 24/74] Document table columns preference --- docs/development/user-preferences.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/development/user-preferences.md b/docs/development/user-preferences.md index f9ca05188..80088186c 100644 --- a/docs/development/user-preferences.md +++ b/docs/development/user-preferences.md @@ -8,3 +8,4 @@ The `users.UserConfig` model holds individual preferences for each user in the f | ---- | ----------- | | extras.configcontext.format | Preferred format when rendering config context data (JSON or YAML) | | pagination.per_page | The number of items to display per page of a paginated table | +| tables.${table_name}.columns | The ordered list of columns to display when viewing the table | From 725e3cdbf3a304deaf62f4cde7871c256336cb76 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 16:20:11 -0400 Subject: [PATCH 25/74] Extend circuits tables to include all relevant model fields --- netbox/circuits/tables.py | 25 +++++++++++++++---------- netbox/circuits/views.py | 6 +++--- netbox/netbox/views.py | 2 +- netbox/utilities/tables.py | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/netbox/circuits/tables.py b/netbox/circuits/tables.py index a7e1b0e84..b04d0cbfc 100644 --- a/netbox/circuits/tables.py +++ b/netbox/circuits/tables.py @@ -27,18 +27,23 @@ STATUS_LABEL = """ class ProviderTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() + portal_url = tables.URLColumn( + visible=False + ) + noc_contact = tables.Column( + visible=False + ) + admin_contact = tables.Column( + visible=False + ) + circuit_count = tables.Column( + accessor=Accessor('count_circuits'), + verbose_name='Circuits' + ) class Meta(BaseTable.Meta): model = Provider - fields = ('pk', 'name', 'asn', 'account',) - - -class ProviderDetailTable(ProviderTable): - circuit_count = tables.Column(accessor=Accessor('count_circuits'), verbose_name='Circuits') - - class Meta(ProviderTable.Meta): - model = Provider - fields = ('pk', 'name', 'asn', 'account', 'circuit_count') + fields = ('pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count') # @@ -86,6 +91,6 @@ class CircuitTable(BaseTable): class Meta(BaseTable.Meta): model = Circuit fields = ( - 'pk', 'cid', 'status', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate', + 'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate', 'description', ) diff --git a/netbox/circuits/views.py b/netbox/circuits/views.py index b092e1855..709d2a726 100644 --- a/netbox/circuits/views.py +++ b/netbox/circuits/views.py @@ -28,7 +28,7 @@ class ProviderListView(PermissionRequiredMixin, ObjectListView): queryset = Provider.objects.annotate(count_circuits=Count('circuits')) filterset = filters.ProviderFilterSet filterset_form = forms.ProviderFilterForm - table = tables.ProviderDetailTable + table = tables.ProviderTable class ProviderView(PermissionRequiredMixin, View): @@ -87,7 +87,7 @@ class ProviderBulkImportView(PermissionRequiredMixin, BulkImportView): class ProviderBulkEditView(PermissionRequiredMixin, BulkEditView): permission_required = 'circuits.change_provider' - queryset = Provider.objects.all() + queryset = Provider.objects.annotate(count_circuits=Count('circuits')) filterset = filters.ProviderFilterSet table = tables.ProviderTable form = forms.ProviderBulkEditForm @@ -96,7 +96,7 @@ class ProviderBulkEditView(PermissionRequiredMixin, BulkEditView): class ProviderBulkDeleteView(PermissionRequiredMixin, BulkDeleteView): permission_required = 'circuits.delete_provider' - queryset = Provider.objects.all() + queryset = Provider.objects.annotate(count_circuits=Count('circuits')) filterset = filters.ProviderFilterSet table = tables.ProviderTable default_return_url = 'circuits:provider_list' diff --git a/netbox/netbox/views.py b/netbox/netbox/views.py index 25c32338b..98272a50a 100644 --- a/netbox/netbox/views.py +++ b/netbox/netbox/views.py @@ -44,7 +44,7 @@ SEARCH_TYPES = OrderedDict(( # Circuits ('provider', { 'permission': 'circuits.view_provider', - 'queryset': Provider.objects.all(), + 'queryset': Provider.objects.annotate(count_circuits=Count('circuits')), 'filterset': ProviderFilterSet, 'table': ProviderTable, 'url': 'circuits:provider_list', diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 7da664c43..be0890274 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -37,10 +37,10 @@ class BaseTable(tables.Table): @property def configurable_columns(self): selected_columns = [ - (name, self.columns[name].verbose_name) for name in self.sequence if name != 'pk' + (name, self.columns[name].verbose_name) for name in self.sequence if name not in ['pk', 'actions'] ] available_columns = [ - (name, column.verbose_name) for name, column in self.columns.items() if name not in self.sequence and name != 'pk' + (name, column.verbose_name) for name, column in self.columns.items() if name not in self.sequence and name not in ['pk', 'actions'] ] return selected_columns + available_columns From 8ec2e3cc7b5bf75abd929456121f6b1ca6fa0ee8 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 16:33:06 -0400 Subject: [PATCH 26/74] Introduce default_columns Meta parameter to reduce boilerplate --- netbox/circuits/tables.py | 18 +++--------------- netbox/utilities/tables.py | 7 +++++++ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/netbox/circuits/tables.py b/netbox/circuits/tables.py index b04d0cbfc..0878279ec 100644 --- a/netbox/circuits/tables.py +++ b/netbox/circuits/tables.py @@ -27,15 +27,6 @@ STATUS_LABEL = """ class ProviderTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - portal_url = tables.URLColumn( - visible=False - ) - noc_contact = tables.Column( - visible=False - ) - admin_contact = tables.Column( - visible=False - ) circuit_count = tables.Column( accessor=Accessor('count_circuits'), verbose_name='Circuits' @@ -44,6 +35,7 @@ class ProviderTable(BaseTable): class Meta(BaseTable.Meta): model = Provider fields = ('pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count') + default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count') # @@ -63,6 +55,7 @@ class CircuitTypeTable(BaseTable): class Meta(BaseTable.Meta): model = CircuitType fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions') + default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions') # @@ -81,12 +74,6 @@ class CircuitTable(BaseTable): z_side = tables.Column( verbose_name='Z Side' ) - install_date = tables.Column( - visible=False - ) - commit_rate = tables.Column( - visible=False - ) class Meta(BaseTable.Meta): model = Circuit @@ -94,3 +81,4 @@ class CircuitTable(BaseTable): 'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate', 'description', ) + default_columns = ('pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'description') diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index be0890274..57adb4256 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -18,6 +18,13 @@ class BaseTable(tables.Table): if self.empty_text is None: self.empty_text = 'No {} found'.format(self._meta.model._meta.verbose_name_plural) + # Hide non-default columns + default_columns = getattr(self.Meta, 'default_columns', list()) + if default_columns: + for column in self.columns: + if column.name not in default_columns: + self.columns.hide(column.name) + # Apply custom column ordering if columns is not None: pk = self.base_columns.pop('pk', None) From 55b40d92d474c0bc11ec09017e69df8e4997ec6f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Apr 2020 17:06:16 -0400 Subject: [PATCH 27/74] Extend DCIM tables (WIP) --- netbox/dcim/tables.py | 165 +++++++++++++++++++++++++++++++++--------- 1 file changed, 129 insertions(+), 36 deletions(-) diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 0e5e9dc7a..75b319ff5 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -205,9 +205,13 @@ def get_component_template_actions(model_name): class RegionTable(BaseTable): pk = ToggleColumn() - name = tables.TemplateColumn(template_code=MPTT_LINK, orderable=False) - site_count = tables.Column(verbose_name='Sites') - slug = tables.Column(verbose_name='Slug') + name = tables.TemplateColumn( + template_code=MPTT_LINK, + orderable=False + ) + site_count = tables.Column( + verbose_name='Sites' + ) actions = tables.TemplateColumn( template_code=REGION_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -216,7 +220,8 @@ class RegionTable(BaseTable): class Meta(BaseTable.Meta): model = Region - fields = ('pk', 'name', 'site_count', 'description', 'slug', 'actions') + fields = ('pk', 'name', 'slug', 'site_count', 'description', 'actions') + default_columns = ('pk', 'name', 'site_count', 'description', 'actions') # @@ -225,14 +230,27 @@ class RegionTable(BaseTable): class SiteTable(BaseTable): pk = ToggleColumn() - name = tables.LinkColumn(order_by=('_name',)) - status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status') - region = tables.TemplateColumn(template_code=SITE_REGION_LINK) - tenant = tables.TemplateColumn(template_code=COL_TENANT) + name = tables.LinkColumn( + order_by=('_name',) + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + region = tables.TemplateColumn( + template_code=SITE_REGION_LINK + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) class Meta(BaseTable.Meta): model = Site - fields = ('pk', 'name', 'status', 'facility', 'region', 'tenant', 'asn', 'description') + fields = ( + 'pk', 'name', 'slug', 'status', 'facility', 'region', 'tenant', 'asn', 'time_zone', 'description', + 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone', + 'contact_email', + ) + default_columns = ('pk', 'name', 'status', 'facility', 'region', 'tenant', 'asn', 'description') # @@ -253,7 +271,6 @@ class RackGroupTable(BaseTable): rack_count = tables.Column( verbose_name='Racks' ) - slug = tables.Column() actions = tables.TemplateColumn( template_code=RACKGROUP_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -263,6 +280,7 @@ class RackGroupTable(BaseTable): class Meta(BaseTable.Meta): model = RackGroup fields = ('pk', 'name', 'site', 'rack_count', 'description', 'slug', 'actions') + default_columns = ('pk', 'name', 'site', 'rack_count', 'description', 'actions') # @@ -282,6 +300,7 @@ class RackRoleTable(BaseTable): class Meta(BaseTable.Meta): model = RackRole fields = ('pk', 'name', 'rack_count', 'color', 'description', 'slug', 'actions') + default_columns = ('pk', 'name', 'rack_count', 'color', 'description', 'actions') # @@ -290,17 +309,37 @@ class RackRoleTable(BaseTable): class RackTable(BaseTable): pk = ToggleColumn() - name = tables.LinkColumn(order_by=('_name',)) - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - group = tables.Column(accessor=Accessor('group.name'), verbose_name='Group') - tenant = tables.TemplateColumn(template_code=COL_TENANT) - status = tables.TemplateColumn(STATUS_LABEL) - role = tables.TemplateColumn(RACK_ROLE) - u_height = tables.TemplateColumn("{{ record.u_height }}U", verbose_name='Height') + name = tables.LinkColumn( + order_by=('_name',) + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + group = tables.Column( + accessor=Accessor('group.name') + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + role = tables.TemplateColumn( + template_code=RACK_ROLE + ) + u_height = tables.TemplateColumn( + template_code="{{ record.u_height }}U", + verbose_name='Height' + ) class Meta(BaseTable.Meta): model = Rack - fields = ('pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'u_height') + fields = ( + 'pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'serial', 'asset_tag', 'type', + 'width', 'u_height', + ) + default_columns = ('pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'u_height') class RackDetailTable(RackTable): @@ -321,6 +360,10 @@ class RackDetailTable(RackTable): class Meta(RackTable.Meta): fields = ( + 'pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'serial', 'asset_tag', 'type', + 'width', 'u_height', 'device_count', 'get_utilization', 'get_power_utilization', + ) + default_columns = ( 'pk', 'name', 'site', 'group', 'status', 'facility_id', 'tenant', 'role', 'u_height', 'device_count', 'get_utilization', 'get_power_utilization', ) @@ -364,6 +407,9 @@ class RackReservationTable(BaseTable): fields = ( 'pk', 'reservation', 'site', 'rack', 'unit_list', 'user', 'created', 'tenant', 'description', 'actions', ) + default_columns = ( + 'pk', 'reservation', 'site', 'rack', 'unit_list', 'user', 'description', 'actions', + ) # @@ -416,9 +462,12 @@ class DeviceTypeTable(BaseTable): class Meta(BaseTable.Meta): model = DeviceType fields = ( - 'pk', 'model', 'manufacturer', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', + 'pk', 'model', 'manufacturer', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'instance_count', ) + default_columns = ( + 'pk', 'model', 'manufacturer', 'part_number', 'u_height', 'is_full_depth', 'instance_count', + ) # @@ -427,7 +476,9 @@ class DeviceTypeTable(BaseTable): class ConsolePortTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('consoleporttemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -441,7 +492,10 @@ class ConsolePortTemplateTable(BaseTable): class ConsolePortImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = ConsolePort @@ -451,7 +505,9 @@ class ConsolePortImportTable(BaseTable): class ConsoleServerPortTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('consoleserverporttemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -465,7 +521,10 @@ class ConsoleServerPortTemplateTable(BaseTable): class ConsoleServerPortImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = ConsoleServerPort @@ -475,7 +534,9 @@ class ConsoleServerPortImportTable(BaseTable): class PowerPortTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('powerporttemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -489,7 +550,10 @@ class PowerPortTemplateTable(BaseTable): class PowerPortImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = PowerPort @@ -499,7 +563,9 @@ class PowerPortImportTable(BaseTable): class PowerOutletTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('poweroutlettemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -513,7 +579,10 @@ class PowerOutletTemplateTable(BaseTable): class PowerOutletImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = PowerOutlet @@ -523,7 +592,9 @@ class PowerOutletImportTable(BaseTable): class InterfaceTemplateTable(BaseTable): pk = ToggleColumn() - mgmt_only = tables.TemplateColumn("{% if value %}OOB Management{% endif %}") + mgmt_only = tables.TemplateColumn( + template_code="{% if value %}OOB Management{% endif %}" + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('interfacetemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -537,18 +608,30 @@ class InterfaceTemplateTable(BaseTable): class InterfaceImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') - virtual_machine = tables.LinkColumn('virtualization:virtualmachine', args=[Accessor('virtual_machine.pk')], verbose_name='Virtual Machine') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) + virtual_machine = tables.LinkColumn( + viewname='virtualization:virtualmachine', + args=[Accessor('virtual_machine.pk')], + verbose_name='Virtual Machine' + ) class Meta(BaseTable.Meta): model = Interface - fields = ('device', 'virtual_machine', 'name', 'description', 'lag', 'type', 'enabled', 'mac_address', 'mtu', 'mgmt_only', 'mode') + fields = ( + 'device', 'virtual_machine', 'name', 'description', 'lag', 'type', 'enabled', 'mac_address', 'mtu', + 'mgmt_only', 'mode', + ) empty_text = False class FrontPortTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) rear_port_position = tables.Column( verbose_name='Position' ) @@ -565,7 +648,10 @@ class FrontPortTemplateTable(BaseTable): class FrontPortImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = FrontPort @@ -575,7 +661,9 @@ class FrontPortImportTable(BaseTable): class RearPortTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('rearporttemplate'), attrs={'td': {'class': 'text-right noprint'}}, @@ -589,7 +677,10 @@ class RearPortTemplateTable(BaseTable): class RearPortImportTable(BaseTable): - device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device') + device = tables.LinkColumn( + viewname='dcim:device', + args=[Accessor('device.pk')] + ) class Meta(BaseTable.Meta): model = RearPort @@ -599,7 +690,9 @@ class RearPortImportTable(BaseTable): class DeviceBayTemplateTable(BaseTable): pk = ToggleColumn() - name = tables.Column(order_by=('_name',)) + name = tables.Column( + order_by=('_name',) + ) actions = tables.TemplateColumn( template_code=get_component_template_actions('devicebaytemplate'), attrs={'td': {'class': 'text-right noprint'}}, From 39ea14202e1bcf4dbee6c3d1435a2be1151c60f0 Mon Sep 17 00:00:00 2001 From: kobayashi Date: Wed, 29 Apr 2020 00:06:26 -0400 Subject: [PATCH 28/74] Fix 4549 webhook body encode in utf-8 --- docs/release-notes/version-2.8.md | 1 + netbox/extras/webhooks.py | 2 +- netbox/extras/webhooks_worker.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index 5b73cc85d..8f95141ca 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -11,6 +11,7 @@ ### Bug Fixes * [#4527](https://github.com/netbox-community/netbox/issues/4527) - Fix assignment of certain tags to config contexts +* [#4549](https://github.com/netbox-community/netbox/issues/4549) - Fix encoding unicode webhook body data --- diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py index fdf69d6d5..8a7a07560 100644 --- a/netbox/extras/webhooks.py +++ b/netbox/extras/webhooks.py @@ -17,7 +17,7 @@ def generate_signature(request_body, secret): """ hmac_prep = hmac.new( key=secret.encode('utf8'), - msg=request_body.encode('utf8'), + msg=request_body, digestmod=hashlib.sha512 ) return hmac_prep.hexdigest() diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py index 1b1b76dd9..15913c899 100644 --- a/netbox/extras/webhooks_worker.py +++ b/netbox/extras/webhooks_worker.py @@ -46,7 +46,7 @@ def process_webhook(webhook, data, model_name, event, timestamp, username, reque 'method': webhook.http_method, 'url': webhook.payload_url, 'headers': headers, - 'data': body, + 'data': body.encode('utf8'), } logger.info( "Sending {} request to {} ({} {})".format( From 6e832de4a99c9a45d4155023162f1b25b84bf62f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 09:31:52 -0400 Subject: [PATCH 29/74] Remove squashed migrations --- ...0001_initial_squashed_0006_terminations.py | 134 ----- ...n_squashed_0017_circuittype_description.py | 254 ---------- ...ion.py => 0018_standardize_description.py} | 2 +- ...010_devicebay_installed_device_set_null.py | 101 ---- ...number_squashed_0022_color_names_to_rgb.py | 154 ------ ...shed_0043_device_component_name_lengths.py | 478 ------------------ ...tion_squashed_0061_platform_napalm_args.py | 354 ------------- ...face_mtu_squashed_0065_front_rear_ports.py | 124 ----- ...lifiers_squashed_0070_custom_tag_models.py | 146 ------ ...0001_initial_squashed_0013_objectchange.py | 265 ---------- ...igcontexts_squashed_0019_tag_taggeditem.py | 106 ---- ...021_add_color_comments_changelog_to_tag.py | 93 ---- ..._links_squashed_0034_configcontext_tags.py | 227 --------- ...groups_squashed_0011_rir_add_is_private.py | 100 ---- ...18_remove_service_uniqueness_constraint.py | 171 ------- ...n_squashed_0020_ipaddress_add_role_carp.py | 34 -- ...rdering_squashed_0025_custom_tag_models.py | 145 ------ ...ls_first_squashed_0032_role_description.py | 140 ----- ...initial_squashed_0006_custom_tag_models.py | 81 --- ...01_initial_squashed_0005_change_logging.py | 45 -- ..._tokens_squashed_0003_token_permissions.py | 35 -- ...ion.py => 0004_standardize_description.py} | 2 +- ...{0004_userconfig.py => 0005_userconfig.py} | 2 +- ...rconfigs.py => 0006_create_userconfigs.py} | 2 +- ..._status_squashed_0009_custom_tag_models.py | 89 ---- ..._tenant_squashed_0012_vm_name_nonunique.py | 50 -- 26 files changed, 4 insertions(+), 3330 deletions(-) delete mode 100644 netbox/circuits/migrations/0001_initial_squashed_0006_terminations.py delete mode 100644 netbox/circuits/migrations/0007_circuit_add_description_squashed_0017_circuittype_description.py rename netbox/circuits/migrations/{0008_standardize_description.py => 0018_standardize_description.py} (88%) delete mode 100644 netbox/dcim/migrations/0003_auto_20160628_1721_squashed_0010_devicebay_installed_device_set_null.py delete mode 100644 netbox/dcim/migrations/0011_devicetype_part_number_squashed_0022_color_names_to_rgb.py delete mode 100644 netbox/dcim/migrations/0023_devicetype_comments_squashed_0043_device_component_name_lengths.py delete mode 100644 netbox/dcim/migrations/0044_virtualization_squashed_0061_platform_napalm_args.py delete mode 100644 netbox/dcim/migrations/0062_interface_mtu_squashed_0065_front_rear_ports.py delete mode 100644 netbox/dcim/migrations/0067_device_type_remove_qualifiers_squashed_0070_custom_tag_models.py delete mode 100644 netbox/extras/migrations/0001_initial_squashed_0013_objectchange.py delete mode 100644 netbox/extras/migrations/0014_configcontexts_squashed_0019_tag_taggeditem.py delete mode 100644 netbox/extras/migrations/0020_tag_data_squashed_0021_add_color_comments_changelog_to_tag.py delete mode 100644 netbox/extras/migrations/0022_custom_links_squashed_0034_configcontext_tags.py delete mode 100644 netbox/ipam/migrations/0003_ipam_add_vlangroups_squashed_0011_rir_add_is_private.py delete mode 100644 netbox/ipam/migrations/0012_services_squashed_0018_remove_service_uniqueness_constraint.py delete mode 100644 netbox/ipam/migrations/0019_virtualization_squashed_0020_ipaddress_add_role_carp.py delete mode 100644 netbox/ipam/migrations/0021_vrf_ordering_squashed_0025_custom_tag_models.py delete mode 100644 netbox/ipam/migrations/0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description.py delete mode 100644 netbox/secrets/migrations/0001_initial_squashed_0006_custom_tag_models.py delete mode 100644 netbox/tenancy/migrations/0001_initial_squashed_0005_change_logging.py delete mode 100644 netbox/users/migrations/0001_api_tokens_squashed_0003_token_permissions.py rename netbox/users/migrations/{0002_standardize_description.py => 0004_standardize_description.py} (83%) rename netbox/users/migrations/{0004_userconfig.py => 0005_userconfig.py} (94%) rename netbox/users/migrations/{0005_create_userconfigs.py => 0006_create_userconfigs.py} (94%) delete mode 100644 netbox/virtualization/migrations/0002_virtualmachine_add_status_squashed_0009_custom_tag_models.py delete mode 100644 netbox/virtualization/migrations/0010_cluster_add_tenant_squashed_0012_vm_name_nonunique.py diff --git a/netbox/circuits/migrations/0001_initial_squashed_0006_terminations.py b/netbox/circuits/migrations/0001_initial_squashed_0006_terminations.py deleted file mode 100644 index 4eec30667..000000000 --- a/netbox/circuits/migrations/0001_initial_squashed_0006_terminations.py +++ /dev/null @@ -1,134 +0,0 @@ -import django.db.models.deletion -from django.db import migrations, models - -import dcim.fields - - -def circuits_to_terms(apps, schema_editor): - Circuit = apps.get_model('circuits', 'Circuit') - CircuitTermination = apps.get_model('circuits', 'CircuitTermination') - for c in Circuit.objects.all(): - CircuitTermination( - circuit=c, - term_side=b'A', - site=c.site, - interface=c.interface, - port_speed=c.port_speed, - upstream_speed=c.upstream_speed, - xconnect_id=c.xconnect_id, - pp_info=c.pp_info, - ).save() - - -class Migration(migrations.Migration): - - replaces = [('circuits', '0001_initial'), ('circuits', '0002_auto_20160622_1821'), ('circuits', '0003_provider_32bit_asn_support'), ('circuits', '0004_circuit_add_tenant'), ('circuits', '0005_circuit_add_upstream_speed'), ('circuits', '0006_terminations')] - - dependencies = [ - ('tenancy', '0001_initial'), - ('dcim', '0001_initial'), - ('dcim', '0022_color_names_to_rgb'), - ] - - operations = [ - migrations.CreateModel( - name='CircuitType', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='Provider', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True)), - ('last_updated', models.DateTimeField(auto_now=True)), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('asn', dcim.fields.ASNField(blank=True, null=True, verbose_name=b'ASN')), - ('account', models.CharField(blank=True, max_length=30, verbose_name=b'Account number')), - ('portal_url', models.URLField(blank=True, verbose_name=b'Portal')), - ('noc_contact', models.TextField(blank=True, verbose_name=b'NOC contact')), - ('admin_contact', models.TextField(blank=True, verbose_name=b'Admin contact')), - ('comments', models.TextField(blank=True)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='Circuit', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True)), - ('last_updated', models.DateTimeField(auto_now=True)), - ('cid', models.CharField(max_length=50, verbose_name=b'Circuit ID')), - ('install_date', models.DateField(blank=True, null=True, verbose_name=b'Date installed')), - ('port_speed', models.PositiveIntegerField(verbose_name=b'Port speed (Kbps)')), - ('commit_rate', models.PositiveIntegerField(blank=True, null=True, verbose_name=b'Commit rate (Kbps)')), - ('xconnect_id', models.CharField(blank=True, max_length=50, verbose_name=b'Cross-connect ID')), - ('pp_info', models.CharField(blank=True, max_length=100, verbose_name=b'Patch panel/port(s)')), - ('comments', models.TextField(blank=True)), - ('interface', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='circuit', to='dcim.Interface')), - ('provider', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.Provider')), - ('site', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='dcim.Site')), - ('type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.CircuitType')), - ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='tenancy.Tenant')), - ('upstream_speed', models.PositiveIntegerField(blank=True, help_text=b'Upstream speed, if different from port speed', null=True, verbose_name=b'Upstream speed (Kbps)')), - ], - options={ - 'ordering': ['provider', 'cid'], - 'unique_together': {('provider', 'cid')}, - }, - ), - migrations.CreateModel( - name='CircuitTermination', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('term_side', models.CharField(choices=[(b'A', b'A'), (b'Z', b'Z')], max_length=1, verbose_name='Termination')), - ('port_speed', models.PositiveIntegerField(verbose_name=b'Port speed (Kbps)')), - ('upstream_speed', models.PositiveIntegerField(blank=True, help_text=b'Upstream speed, if different from port speed', null=True, verbose_name=b'Upstream speed (Kbps)')), - ('xconnect_id', models.CharField(blank=True, max_length=50, verbose_name=b'Cross-connect ID')), - ('pp_info', models.CharField(blank=True, max_length=100, verbose_name=b'Patch panel/port(s)')), - ('circuit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='terminations', to='circuits.Circuit')), - ('interface', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='circuit_termination', to='dcim.Interface')), - ('site', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuit_terminations', to='dcim.Site')), - ], - options={ - 'ordering': ['circuit', 'term_side'], - 'unique_together': {('circuit', 'term_side')}, - }, - ), - migrations.RunPython( - code=circuits_to_terms, - ), - migrations.RemoveField( - model_name='circuit', - name='interface', - ), - migrations.RemoveField( - model_name='circuit', - name='port_speed', - ), - migrations.RemoveField( - model_name='circuit', - name='pp_info', - ), - migrations.RemoveField( - model_name='circuit', - name='site', - ), - migrations.RemoveField( - model_name='circuit', - name='upstream_speed', - ), - migrations.RemoveField( - model_name='circuit', - name='xconnect_id', - ), - ] diff --git a/netbox/circuits/migrations/0007_circuit_add_description_squashed_0017_circuittype_description.py b/netbox/circuits/migrations/0007_circuit_add_description_squashed_0017_circuittype_description.py deleted file mode 100644 index 5bcd863a4..000000000 --- a/netbox/circuits/migrations/0007_circuit_add_description_squashed_0017_circuittype_description.py +++ /dev/null @@ -1,254 +0,0 @@ -import sys - -import django.db.models.deletion -import taggit.managers -from django.db import migrations, models - -import dcim.fields - -CONNECTION_STATUS_CONNECTED = True - -CIRCUIT_STATUS_CHOICES = ( - (0, 'deprovisioning'), - (1, 'active'), - (2, 'planned'), - (3, 'provisioning'), - (4, 'offline'), - (5, 'decommissioned') -) - - -def circuit_terminations_to_cables(apps, schema_editor): - """ - Copy all existing CircuitTermination Interface associations as Cables - """ - ContentType = apps.get_model('contenttypes', 'ContentType') - CircuitTermination = apps.get_model('circuits', 'CircuitTermination') - Interface = apps.get_model('dcim', 'Interface') - Cable = apps.get_model('dcim', 'Cable') - - # Load content types - circuittermination_type = ContentType.objects.get_for_model(CircuitTermination) - interface_type = ContentType.objects.get_for_model(Interface) - - # Create a new Cable instance from each console connection - if 'test' not in sys.argv: - print("\n Adding circuit terminations... ", end='', flush=True) - for circuittermination in CircuitTermination.objects.filter(interface__isnull=False): - - # Create the new Cable - cable = Cable.objects.create( - termination_a_type=circuittermination_type, - termination_a_id=circuittermination.id, - termination_b_type=interface_type, - termination_b_id=circuittermination.interface_id, - status=CONNECTION_STATUS_CONNECTED - ) - - # Cache the Cable on its two termination points - CircuitTermination.objects.filter(pk=circuittermination.pk).update( - cable=cable, - connected_endpoint=circuittermination.interface, - connection_status=CONNECTION_STATUS_CONNECTED - ) - # Cache the connected Cable on the Interface - Interface.objects.filter(pk=circuittermination.interface_id).update( - cable=cable, - _connected_circuittermination=circuittermination, - connection_status=CONNECTION_STATUS_CONNECTED - ) - - cable_count = Cable.objects.filter(termination_a_type=circuittermination_type).count() - if 'test' not in sys.argv: - print("{} cables created".format(cable_count)) - - -def circuit_status_to_slug(apps, schema_editor): - Circuit = apps.get_model('circuits', 'Circuit') - for id, slug in CIRCUIT_STATUS_CHOICES: - Circuit.objects.filter(status=str(id)).update(status=slug) - - -class Migration(migrations.Migration): - - replaces = [('circuits', '0007_circuit_add_description'), ('circuits', '0008_circuittermination_interface_protect_on_delete'), ('circuits', '0009_unicode_literals'), ('circuits', '0010_circuit_status'), ('circuits', '0011_tags'), ('circuits', '0012_change_logging'), ('circuits', '0013_cables'), ('circuits', '0014_circuittermination_description'), ('circuits', '0015_custom_tag_models'), ('circuits', '0016_3569_circuit_fields'), ('circuits', '0017_circuittype_description')] - - dependencies = [ - ('circuits', '0006_terminations'), - ('extras', '0019_tag_taggeditem'), - ('taggit', '0002_auto_20150616_2121'), - ('dcim', '0066_cables'), - ] - - operations = [ - migrations.AddField( - model_name='circuit', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - migrations.AlterField( - model_name='circuittermination', - name='interface', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuit_termination', to='dcim.Interface'), - ), - migrations.AlterField( - model_name='circuit', - name='cid', - field=models.CharField(max_length=50, verbose_name='Circuit ID'), - ), - migrations.AlterField( - model_name='circuit', - name='commit_rate', - field=models.PositiveIntegerField(blank=True, null=True, verbose_name='Commit rate (Kbps)'), - ), - migrations.AlterField( - model_name='circuit', - name='install_date', - field=models.DateField(blank=True, null=True, verbose_name='Date installed'), - ), - migrations.AlterField( - model_name='circuittermination', - name='port_speed', - field=models.PositiveIntegerField(verbose_name='Port speed (Kbps)'), - ), - migrations.AlterField( - model_name='circuittermination', - name='pp_info', - field=models.CharField(blank=True, max_length=100, verbose_name='Patch panel/port(s)'), - ), - migrations.AlterField( - model_name='circuittermination', - name='term_side', - field=models.CharField(choices=[('A', 'A'), ('Z', 'Z')], max_length=1, verbose_name='Termination'), - ), - migrations.AlterField( - model_name='circuittermination', - name='upstream_speed', - field=models.PositiveIntegerField(blank=True, help_text='Upstream speed, if different from port speed', null=True, verbose_name='Upstream speed (Kbps)'), - ), - migrations.AlterField( - model_name='circuittermination', - name='xconnect_id', - field=models.CharField(blank=True, max_length=50, verbose_name='Cross-connect ID'), - ), - migrations.AlterField( - model_name='provider', - name='account', - field=models.CharField(blank=True, max_length=30, verbose_name='Account number'), - ), - migrations.AlterField( - model_name='provider', - name='admin_contact', - field=models.TextField(blank=True, verbose_name='Admin contact'), - ), - migrations.AlterField( - model_name='provider', - name='asn', - field=dcim.fields.ASNField(blank=True, null=True, verbose_name='ASN'), - ), - migrations.AlterField( - model_name='provider', - name='noc_contact', - field=models.TextField(blank=True, verbose_name='NOC contact'), - ), - migrations.AlterField( - model_name='provider', - name='portal_url', - field=models.URLField(blank=True, verbose_name='Portal'), - ), - migrations.AddField( - model_name='circuit', - name='status', - field=models.PositiveSmallIntegerField(choices=[[2, 'Planned'], [3, 'Provisioning'], [1, 'Active'], [4, 'Offline'], [0, 'Deprovisioning'], [5, 'Decommissioned']], default=1), - ), - migrations.AddField( - model_name='circuit', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='provider', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='circuittype', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='circuittype', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='circuit', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='circuit', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='provider', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='provider', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='circuittermination', - name='connected_endpoint', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.Interface'), - ), - migrations.AddField( - model_name='circuittermination', - name='connection_status', - field=models.NullBooleanField(), - ), - migrations.AddField( - model_name='circuittermination', - name='cable', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.Cable'), - ), - migrations.RunPython( - code=circuit_terminations_to_cables, - ), - migrations.RemoveField( - model_name='circuittermination', - name='interface', - ), - migrations.AddField( - model_name='circuittermination', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - migrations.AlterField( - model_name='circuit', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='provider', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='circuit', - name='status', - field=models.CharField(default='active', max_length=50), - ), - migrations.RunPython( - code=circuit_status_to_slug, - ), - migrations.AddField( - model_name='circuittype', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - ] diff --git a/netbox/circuits/migrations/0008_standardize_description.py b/netbox/circuits/migrations/0018_standardize_description.py similarity index 88% rename from netbox/circuits/migrations/0008_standardize_description.py rename to netbox/circuits/migrations/0018_standardize_description.py index fecdee3ca..a0a213e17 100644 --- a/netbox/circuits/migrations/0008_standardize_description.py +++ b/netbox/circuits/migrations/0018_standardize_description.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('circuits', '0007_circuit_add_description_squashed_0017_circuittype_description'), + ('circuits', '0017_circuittype_description'), ] operations = [ diff --git a/netbox/dcim/migrations/0003_auto_20160628_1721_squashed_0010_devicebay_installed_device_set_null.py b/netbox/dcim/migrations/0003_auto_20160628_1721_squashed_0010_devicebay_installed_device_set_null.py deleted file mode 100644 index a9f80f49b..000000000 --- a/netbox/dcim/migrations/0003_auto_20160628_1721_squashed_0010_devicebay_installed_device_set_null.py +++ /dev/null @@ -1,101 +0,0 @@ -import django.db.models.deletion -from django.db import migrations, models - -import dcim.fields - - -def copy_primary_ip(apps, schema_editor): - Device = apps.get_model('dcim', 'Device') - for d in Device.objects.select_related('primary_ip'): - if not d.primary_ip: - continue - if d.primary_ip.family == 4: - d.primary_ip4 = d.primary_ip - elif d.primary_ip.family == 6: - d.primary_ip6 = d.primary_ip - d.save() - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0003_auto_20160628_1721'), ('dcim', '0004_auto_20160701_2049'), ('dcim', '0005_auto_20160706_1722'), ('dcim', '0006_add_device_primary_ip4_ip6'), ('dcim', '0007_device_copy_primary_ip'), ('dcim', '0008_device_remove_primary_ip'), ('dcim', '0009_site_32bit_asn_support'), ('dcim', '0010_devicebay_installed_device_set_null')] - - dependencies = [ - ('ipam', '0001_initial'), - ('dcim', '0002_auto_20160622_1821'), - ] - - operations = [ - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[0, b'Virtual'], [800, b'10/100M (100BASE-TX)'], [1000, b'1GE (1000BASE-T)'], [1100, b'1GE (SFP)'], [1150, b'10GE (10GBASE-T)'], [1200, b'10GE (SFP+)'], [1300, b'10GE (XFP)'], [1400, b'40GE (QSFP+)']], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[0, b'Virtual'], [800, b'10/100M (100BASE-TX)'], [1000, b'1GE (1000BASE-T)'], [1100, b'1GE (SFP)'], [1150, b'10GE (10GBASE-T)'], [1200, b'10GE (SFP+)'], [1300, b'10GE (XFP)'], [1400, b'40GE (QSFP+)']], default=1200), - ), - migrations.AddField( - model_name='devicetype', - name='subdevice_role', - field=models.NullBooleanField(choices=[(None, b'None'), (True, b'Parent'), (False, b'Child')], default=None, help_text=b'Parent devices house child devices in device bays. Select "None" if this device type is neither a parent nor a child.', verbose_name=b'Parent/child status'), - ), - migrations.CreateModel( - name='DeviceBayTemplate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=30)), - ('device_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='device_bay_templates', to='dcim.DeviceType')), - ], - options={ - 'ordering': ['device_type', 'name'], - 'unique_together': {('device_type', 'name')}, - }, - ), - migrations.CreateModel( - name='DeviceBay', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, verbose_name=b'Name')), - ('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='device_bays', to='dcim.Device')), - ('installed_device', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='parent_bay', to='dcim.Device')), - ], - options={ - 'ordering': ['device', 'name'], - 'unique_together': {('device', 'name')}, - }, - ), - migrations.AddField( - model_name='interface', - name='mac_address', - field=dcim.fields.MACAddressField(blank=True, null=True, verbose_name=b'MAC Address'), - ), - migrations.AddField( - model_name='device', - name='primary_ip4', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_ip4_for', to='ipam.IPAddress', verbose_name=b'Primary IPv4'), - ), - migrations.AddField( - model_name='device', - name='primary_ip6', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_ip6_for', to='ipam.IPAddress', verbose_name=b'Primary IPv6'), - ), - migrations.RunPython( - code=copy_primary_ip, - ), - migrations.RemoveField( - model_name='device', - name='primary_ip', - ), - migrations.AlterField( - model_name='site', - name='asn', - field=dcim.fields.ASNField(blank=True, null=True, verbose_name=b'ASN'), - ), - migrations.AlterField( - model_name='devicebay', - name='installed_device', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parent_bay', to='dcim.Device'), - ), - ] diff --git a/netbox/dcim/migrations/0011_devicetype_part_number_squashed_0022_color_names_to_rgb.py b/netbox/dcim/migrations/0011_devicetype_part_number_squashed_0022_color_names_to_rgb.py deleted file mode 100644 index dac983398..000000000 --- a/netbox/dcim/migrations/0011_devicetype_part_number_squashed_0022_color_names_to_rgb.py +++ /dev/null @@ -1,154 +0,0 @@ -import django.core.validators -import django.db.models.deletion -from django.db import migrations, models - -import utilities.fields - -COLOR_CONVERSION = { - 'teal': '009688', - 'green': '4caf50', - 'blue': '2196f3', - 'purple': '9c27b0', - 'yellow': 'ffeb3b', - 'orange': 'ff9800', - 'red': 'f44336', - 'light_gray': 'c0c0c0', - 'medium_gray': '9e9e9e', - 'dark_gray': '607d8b', -} - - -def color_names_to_rgb(apps, schema_editor): - RackRole = apps.get_model('dcim', 'RackRole') - DeviceRole = apps.get_model('dcim', 'DeviceRole') - for color_name, color_rgb in COLOR_CONVERSION.items(): - RackRole.objects.filter(color=color_name).update(color=color_rgb) - DeviceRole.objects.filter(color=color_name).update(color=color_rgb) - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0011_devicetype_part_number'), ('dcim', '0012_site_rack_device_add_tenant'), ('dcim', '0013_add_interface_form_factors'), ('dcim', '0014_rack_add_type_width'), ('dcim', '0015_rack_add_u_height_validator'), ('dcim', '0016_module_add_manufacturer'), ('dcim', '0017_rack_add_role'), ('dcim', '0018_device_add_asset_tag'), ('dcim', '0019_new_iface_form_factors'), ('dcim', '0020_rack_desc_units'), ('dcim', '0021_add_ff_flexstack'), ('dcim', '0022_color_names_to_rgb')] - - dependencies = [ - ('dcim', '0010_devicebay_installed_device_set_null'), - ('tenancy', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='devicetype', - name='part_number', - field=models.CharField(blank=True, help_text=b'Discrete part number (optional)', max_length=50), - ), - migrations.AddField( - model_name='device', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='devices', to='tenancy.Tenant'), - ), - migrations.AddField( - model_name='rack', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='racks', to='tenancy.Tenant'), - ), - migrations.AddField( - model_name='site', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='sites', to='tenancy.Tenant'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet', [[800, b'100BASE-TX (10/100M)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Modular', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1300, b'XFP (10GE)'], [1200, b'SFP+ (10GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet', [[800, b'100BASE-TX (10/100M)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Modular', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1300, b'XFP (10GE)'], [1200, b'SFP+ (10GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus']]]], default=1200), - ), - migrations.AddField( - model_name='rack', - name='type', - field=models.PositiveSmallIntegerField(blank=True, choices=[(100, b'2-post frame'), (200, b'4-post frame'), (300, b'4-post cabinet'), (1000, b'Wall-mounted frame'), (1100, b'Wall-mounted cabinet')], null=True, verbose_name=b'Type'), - ), - migrations.AddField( - model_name='rack', - name='width', - field=models.PositiveSmallIntegerField(choices=[(19, b'19 inches'), (23, b'23 inches')], default=19, help_text=b'Rail-to-rail width', verbose_name=b'Width'), - ), - migrations.AlterField( - model_name='rack', - name='u_height', - field=models.PositiveSmallIntegerField(default=42, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100)], verbose_name=b'Height (U)'), - ), - migrations.AddField( - model_name='module', - name='manufacturer', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='modules', to='dcim.Manufacturer'), - ), - migrations.CreateModel( - name='RackRole', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('color', models.CharField(choices=[[b'teal', b'Teal'], [b'green', b'Green'], [b'blue', b'Blue'], [b'purple', b'Purple'], [b'yellow', b'Yellow'], [b'orange', b'Orange'], [b'red', b'Red'], [b'light_gray', b'Light Gray'], [b'medium_gray', b'Medium Gray'], [b'dark_gray', b'Dark Gray']], max_length=30)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.AddField( - model_name='rack', - name='role', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='racks', to='dcim.RackRole'), - ), - migrations.AddField( - model_name='device', - name='asset_tag', - field=utilities.fields.NullableCharField(blank=True, help_text=b'A unique tag used to identify this device', max_length=50, null=True, unique=True, verbose_name=b'Asset tag'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AddField( - model_name='rack', - name='desc_units', - field=models.BooleanField(default=False, help_text=b'Units are numbered top-to-bottom', verbose_name=b'Descending units'), - ), - migrations.AlterField( - model_name='device', - name='position', - field=models.PositiveSmallIntegerField(blank=True, help_text=b'The lowest-numbered unit occupied by the device', null=True, validators=[django.core.validators.MinValueValidator(1)], verbose_name=b'Position (U)'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.RunPython( - code=color_names_to_rgb, - ), - migrations.AlterField( - model_name='devicerole', - name='color', - field=utilities.fields.ColorField(max_length=6), - ), - migrations.AlterField( - model_name='rackrole', - name='color', - field=utilities.fields.ColorField(max_length=6), - ), - ] diff --git a/netbox/dcim/migrations/0023_devicetype_comments_squashed_0043_device_component_name_lengths.py b/netbox/dcim/migrations/0023_devicetype_comments_squashed_0043_device_component_name_lengths.py deleted file mode 100644 index 064832e80..000000000 --- a/netbox/dcim/migrations/0023_devicetype_comments_squashed_0043_device_component_name_lengths.py +++ /dev/null @@ -1,478 +0,0 @@ -import django.contrib.postgres.fields -import django.core.validators -import django.db.models.deletion -import mptt.fields -from django.conf import settings -from django.db import migrations, models - -import dcim.fields -import utilities.fields - - -def copy_site_from_rack(apps, schema_editor): - Device = apps.get_model('dcim', 'Device') - for device in Device.objects.all(): - device.site = device.rack.site - device.save() - - -def rpc_client_to_napalm_driver(apps, schema_editor): - """ - Migrate legacy RPC clients to their respective NAPALM drivers - """ - Platform = apps.get_model('dcim', 'Platform') - - Platform.objects.filter(rpc_client='juniper-junos').update(napalm_driver='junos') - Platform.objects.filter(rpc_client='cisco-ios').update(napalm_driver='ios') - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0023_devicetype_comments'), ('dcim', '0024_site_add_contact_fields'), ('dcim', '0025_devicetype_add_interface_ordering'), ('dcim', '0026_add_rack_reservations'), ('dcim', '0027_device_add_site'), ('dcim', '0028_device_copy_rack_to_site'), ('dcim', '0029_allow_rackless_devices'), ('dcim', '0030_interface_add_lag'), ('dcim', '0031_regions'), ('dcim', '0032_device_increase_name_length'), ('dcim', '0033_rackreservation_rack_editable'), ('dcim', '0034_rename_module_to_inventoryitem'), ('dcim', '0035_device_expand_status_choices'), ('dcim', '0036_add_ff_juniper_vcp'), ('dcim', '0037_unicode_literals'), ('dcim', '0038_wireless_interfaces'), ('dcim', '0039_interface_add_enabled_mtu'), ('dcim', '0040_inventoryitem_add_asset_tag_description'), ('dcim', '0041_napalm_integration'), ('dcim', '0042_interface_ff_10ge_cx4'), ('dcim', '0043_device_component_name_lengths')] - - dependencies = [ - ('dcim', '0022_color_names_to_rgb'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.AddField( - model_name='devicetype', - name='comments', - field=models.TextField(blank=True), - ), - migrations.AddField( - model_name='site', - name='contact_email', - field=models.EmailField(blank=True, max_length=254, verbose_name=b'Contact E-mail'), - ), - migrations.AddField( - model_name='site', - name='contact_name', - field=models.CharField(blank=True, max_length=50), - ), - migrations.AddField( - model_name='site', - name='contact_phone', - field=models.CharField(blank=True, max_length=20), - ), - migrations.AddField( - model_name='devicetype', - name='interface_ordering', - field=models.PositiveSmallIntegerField(choices=[[1, b'Slot/position'], [2, b'Name (alphabetically)']], default=1), - ), - migrations.CreateModel( - name='RackReservation', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('units', django.contrib.postgres.fields.ArrayField(base_field=models.PositiveSmallIntegerField(), size=None)), - ('created', models.DateTimeField(auto_now_add=True)), - ('description', models.CharField(max_length=100)), - ('rack', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='dcim.Rack')), - ('user', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['created'], - }, - ), - migrations.AddField( - model_name='device', - name='site', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='devices', to='dcim.Site'), - ), - migrations.RunPython( - code=copy_site_from_rack, - ), - migrations.AlterField( - model_name='device', - name='rack', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='devices', to='dcim.Rack'), - ), - migrations.AlterField( - model_name='device', - name='site', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='devices', to='dcim.Site'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual'], [200, b'Link Aggregation Group (LAG)']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual'], [200, b'Link Aggregation Group (LAG)']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.CreateModel( - name='Region', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('lft', models.PositiveIntegerField(db_index=True, editable=False)), - ('rght', models.PositiveIntegerField(db_index=True, editable=False)), - ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)), - ('level', models.PositiveIntegerField(db_index=True, editable=False)), - ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='dcim.Region')), - ], - options={ - 'abstract': False, - }, - ), - migrations.AddField( - model_name='site', - name='region', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sites', to='dcim.Region'), - ), - migrations.AlterField( - model_name='device', - name='name', - field=utilities.fields.NullableCharField(blank=True, max_length=64, null=True, unique=True), - ), - migrations.AlterField( - model_name='rackreservation', - name='rack', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reservations', to='dcim.Rack'), - ), - migrations.RenameModel( - old_name='Module', - new_name='InventoryItem', - ), - migrations.AlterField( - model_name='inventoryitem', - name='device', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inventory_items', to='dcim.Device'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='parent', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='child_items', to='dcim.InventoryItem'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='manufacturer', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='inventory_items', to='dcim.Manufacturer'), - ), - migrations.AlterField( - model_name='device', - name='status', - field=models.PositiveIntegerField(choices=[[1, b'Active'], [0, b'Offline'], [2, b'Planned'], [3, b'Staged'], [4, b'Failed'], [5, b'Inventory']], default=1, verbose_name=b'Status'), - ), - migrations.AlterField( - model_name='device', - name='status', - field=models.PositiveSmallIntegerField(choices=[[1, b'Active'], [0, b'Offline'], [2, b'Planned'], [3, b'Staged'], [4, b'Failed'], [5, b'Inventory']], default=1, verbose_name=b'Status'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual'], [200, b'Link Aggregation Group (LAG)']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus'], [5200, b'Juniper VCP']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[[b'Virtual interfaces', [[0, b'Virtual'], [200, b'Link Aggregation Group (LAG)']]], [b'Ethernet (fixed)', [[800, b'100BASE-TX (10/100ME)'], [1000, b'1000BASE-T (1GE)'], [1150, b'10GBASE-T (10GE)']]], [b'Ethernet (modular)', [[1050, b'GBIC (1GE)'], [1100, b'SFP (1GE)'], [1200, b'SFP+ (10GE)'], [1300, b'XFP (10GE)'], [1310, b'XENPAK (10GE)'], [1320, b'X2 (10GE)'], [1350, b'SFP28 (25GE)'], [1400, b'QSFP+ (40GE)'], [1500, b'CFP (100GE)'], [1600, b'QSFP28 (100GE)']]], [b'FibreChannel', [[3010, b'SFP (1GFC)'], [3020, b'SFP (2GFC)'], [3040, b'SFP (4GFC)'], [3080, b'SFP+ (8GFC)'], [3160, b'SFP+ (16GFC)']]], [b'Serial', [[4000, b'T1 (1.544 Mbps)'], [4010, b'E1 (2.048 Mbps)'], [4040, b'T3 (45 Mbps)'], [4050, b'E3 (34 Mbps)'], [4050, b'E3 (34 Mbps)']]], [b'Stacking', [[5000, b'Cisco StackWise'], [5050, b'Cisco StackWise Plus'], [5100, b'Cisco FlexStack'], [5150, b'Cisco FlexStack Plus'], [5200, b'Juniper VCP']]], [b'Other', [[32767, b'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='consoleport', - name='connection_status', - field=models.NullBooleanField(choices=[[False, 'Planned'], [True, 'Connected']], default=True), - ), - migrations.AlterField( - model_name='consoleport', - name='cs_port', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='connected_console', to='dcim.ConsoleServerPort', verbose_name='Console server port'), - ), - migrations.AlterField( - model_name='device', - name='asset_tag', - field=utilities.fields.NullableCharField(blank=True, help_text='A unique tag used to identify this device', max_length=50, null=True, unique=True, verbose_name='Asset tag'), - ), - migrations.AlterField( - model_name='device', - name='face', - field=models.PositiveSmallIntegerField(blank=True, choices=[[0, 'Front'], [1, 'Rear']], null=True, verbose_name='Rack face'), - ), - migrations.AlterField( - model_name='device', - name='position', - field=models.PositiveSmallIntegerField(blank=True, help_text='The lowest-numbered unit occupied by the device', null=True, validators=[django.core.validators.MinValueValidator(1)], verbose_name='Position (U)'), - ), - migrations.AlterField( - model_name='device', - name='primary_ip4', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_ip4_for', to='ipam.IPAddress', verbose_name='Primary IPv4'), - ), - migrations.AlterField( - model_name='device', - name='primary_ip6', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_ip6_for', to='ipam.IPAddress', verbose_name='Primary IPv6'), - ), - migrations.AlterField( - model_name='device', - name='serial', - field=models.CharField(blank=True, max_length=50, verbose_name='Serial number'), - ), - migrations.AlterField( - model_name='device', - name='status', - field=models.PositiveSmallIntegerField(choices=[[1, 'Active'], [0, 'Offline'], [2, 'Planned'], [3, 'Staged'], [4, 'Failed'], [5, 'Inventory']], default=1, verbose_name='Status'), - ), - migrations.AlterField( - model_name='devicebay', - name='name', - field=models.CharField(max_length=50, verbose_name='Name'), - ), - migrations.AlterField( - model_name='devicetype', - name='interface_ordering', - field=models.PositiveSmallIntegerField(choices=[[1, 'Slot/position'], [2, 'Name (alphabetically)']], default=1), - ), - migrations.AlterField( - model_name='devicetype', - name='is_console_server', - field=models.BooleanField(default=False, help_text='This type of device has console server ports', verbose_name='Is a console server'), - ), - migrations.AlterField( - model_name='devicetype', - name='is_full_depth', - field=models.BooleanField(default=True, help_text='Device consumes both front and rear rack faces', verbose_name='Is full depth'), - ), - migrations.AlterField( - model_name='devicetype', - name='is_network_device', - field=models.BooleanField(default=True, help_text='This type of device has network interfaces', verbose_name='Is a network device'), - ), - migrations.AlterField( - model_name='devicetype', - name='is_pdu', - field=models.BooleanField(default=False, help_text='This type of device has power outlets', verbose_name='Is a PDU'), - ), - migrations.AlterField( - model_name='devicetype', - name='part_number', - field=models.CharField(blank=True, help_text='Discrete part number (optional)', max_length=50), - ), - migrations.AlterField( - model_name='devicetype', - name='subdevice_role', - field=models.NullBooleanField(choices=[(None, 'None'), (True, 'Parent'), (False, 'Child')], default=None, help_text='Parent devices house child devices in device bays. Select "None" if this device type is neither a parent nor a child.', verbose_name='Parent/child status'), - ), - migrations.AlterField( - model_name='devicetype', - name='u_height', - field=models.PositiveSmallIntegerField(default=1, verbose_name='Height (U)'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AddField( - model_name='interface', - name='lag', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='member_interfaces', to='dcim.Interface', verbose_name='Parent LAG'), - ), - migrations.AlterField( - model_name='interface', - name='mac_address', - field=dcim.fields.MACAddressField(blank=True, null=True, verbose_name='MAC Address'), - ), - migrations.AlterField( - model_name='interface', - name='mgmt_only', - field=models.BooleanField(default=False, help_text='This interface is used only for out-of-band management', verbose_name='OOB Management'), - ), - migrations.AlterField( - model_name='interfaceconnection', - name='connection_status', - field=models.BooleanField(choices=[[False, 'Planned'], [True, 'Connected']], default=True, verbose_name='Status'), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='mgmt_only', - field=models.BooleanField(default=False, verbose_name='Management only'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='discovered', - field=models.BooleanField(default=False, verbose_name='Discovered'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='name', - field=models.CharField(max_length=50, verbose_name='Name'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='part_id', - field=models.CharField(blank=True, max_length=50, verbose_name='Part ID'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='serial', - field=models.CharField(blank=True, max_length=50, verbose_name='Serial number'), - ), - migrations.AlterField( - model_name='platform', - name='rpc_client', - field=models.CharField(blank=True, choices=[['juniper-junos', 'Juniper Junos (NETCONF)'], ['cisco-ios', 'Cisco IOS (SSH)'], ['opengear', 'Opengear (SSH)']], max_length=30, verbose_name='RPC client'), - ), - migrations.AlterField( - model_name='powerport', - name='connection_status', - field=models.NullBooleanField(choices=[[False, 'Planned'], [True, 'Connected']], default=True), - ), - migrations.AlterField( - model_name='rack', - name='desc_units', - field=models.BooleanField(default=False, help_text='Units are numbered top-to-bottom', verbose_name='Descending units'), - ), - migrations.AlterField( - model_name='rack', - name='facility_id', - field=utilities.fields.NullableCharField(blank=True, max_length=30, null=True, verbose_name='Facility ID'), - ), - migrations.AlterField( - model_name='rack', - name='type', - field=models.PositiveSmallIntegerField(blank=True, choices=[(100, '2-post frame'), (200, '4-post frame'), (300, '4-post cabinet'), (1000, 'Wall-mounted frame'), (1100, 'Wall-mounted cabinet')], null=True, verbose_name='Type'), - ), - migrations.AlterField( - model_name='rack', - name='u_height', - field=models.PositiveSmallIntegerField(default=42, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100)], verbose_name='Height (U)'), - ), - migrations.AlterField( - model_name='rack', - name='width', - field=models.PositiveSmallIntegerField(choices=[(19, '19 inches'), (23, '23 inches')], default=19, help_text='Rail-to-rail width', verbose_name='Width'), - ), - migrations.AlterField( - model_name='site', - name='asn', - field=dcim.fields.ASNField(blank=True, null=True, verbose_name='ASN'), - ), - migrations.AlterField( - model_name='site', - name='contact_email', - field=models.EmailField(blank=True, max_length=254, verbose_name='Contact E-mail'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AddField( - model_name='interface', - name='enabled', - field=models.BooleanField(default=True), - ), - migrations.AddField( - model_name='interface', - name='mtu', - field=models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='MTU'), - ), - migrations.AddField( - model_name='inventoryitem', - name='asset_tag', - field=utilities.fields.NullableCharField(blank=True, help_text='A unique tag used to identify this item', max_length=50, null=True, unique=True, verbose_name='Asset tag'), - ), - migrations.AddField( - model_name='inventoryitem', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - migrations.AlterModelOptions( - name='device', - options={'ordering': ['name'], 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))}, - ), - migrations.AddField( - model_name='platform', - name='napalm_driver', - field=models.CharField(blank=True, help_text='The name of the NAPALM driver to use when interacting with devices.', max_length=50, verbose_name='NAPALM driver'), - ), - migrations.AlterField( - model_name='platform', - name='rpc_client', - field=models.CharField(blank=True, choices=[['juniper-junos', 'Juniper Junos (NETCONF)'], ['cisco-ios', 'Cisco IOS (SSH)'], ['opengear', 'Opengear (SSH)']], max_length=30, verbose_name='Legacy RPC client'), - ), - migrations.RunPython( - code=rpc_client_to_napalm_driver, - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='consoleport', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='consoleporttemplate', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='consoleserverport', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='consoleserverporttemplate', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='devicebaytemplate', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='interface', - name='name', - field=models.CharField(max_length=64), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='name', - field=models.CharField(max_length=64), - ), - migrations.AlterField( - model_name='poweroutlet', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='poweroutlettemplate', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='powerport', - name='name', - field=models.CharField(max_length=50), - ), - migrations.AlterField( - model_name='powerporttemplate', - name='name', - field=models.CharField(max_length=50), - ), - ] diff --git a/netbox/dcim/migrations/0044_virtualization_squashed_0061_platform_napalm_args.py b/netbox/dcim/migrations/0044_virtualization_squashed_0061_platform_napalm_args.py deleted file mode 100644 index 18ef39fe7..000000000 --- a/netbox/dcim/migrations/0044_virtualization_squashed_0061_platform_napalm_args.py +++ /dev/null @@ -1,354 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.core.validators -import django.db.models.deletion -import taggit.managers -import timezone_field.fields -from django.conf import settings -from django.db import migrations, models - -import utilities.fields - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0044_virtualization'), ('dcim', '0045_devicerole_vm_role'), ('dcim', '0046_rack_lengthen_facility_id'), ('dcim', '0047_more_100ge_form_factors'), ('dcim', '0048_rack_serial'), ('dcim', '0049_rackreservation_change_user'), ('dcim', '0050_interface_vlan_tagging'), ('dcim', '0051_rackreservation_tenant'), ('dcim', '0052_virtual_chassis'), ('dcim', '0053_platform_manufacturer'), ('dcim', '0054_site_status_timezone_description'), ('dcim', '0055_virtualchassis_ordering'), ('dcim', '0056_django2'), ('dcim', '0057_tags'), ('dcim', '0058_relax_rack_naming_constraints'), ('dcim', '0059_site_latitude_longitude'), ('dcim', '0060_change_logging'), ('dcim', '0061_platform_napalm_args')] - - dependencies = [ - ('virtualization', '0001_virtualization'), - ('tenancy', '0003_unicode_literals'), - ('ipam', '0020_ipaddress_add_role_carp'), - ('dcim', '0043_device_component_name_lengths'), - ('taggit', '0002_auto_20150616_2121'), - ] - - operations = [ - migrations.AddField( - model_name='device', - name='cluster', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='devices', to='virtualization.Cluster'), - ), - migrations.AddField( - model_name='interface', - name='virtual_machine', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='virtualization.VirtualMachine'), - ), - migrations.AlterField( - model_name='interface', - name='device', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='dcim.Device'), - ), - migrations.AddField( - model_name='devicerole', - name='vm_role', - field=models.BooleanField(default=True, help_text='Virtual machines may be assigned to this role', verbose_name='VM Role'), - ), - migrations.AlterField( - model_name='rack', - name='facility_id', - field=utilities.fields.NullableCharField(blank=True, max_length=50, null=True, verbose_name='Facility ID'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1510, 'CFP2 (100GE)'], [1520, 'CFP4 (100GE)'], [1550, 'Cisco CPAK (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1510, 'CFP2 (100GE)'], [1520, 'CFP4 (100GE)'], [1550, 'Cisco CPAK (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AddField( - model_name='rack', - name='serial', - field=models.CharField(blank=True, max_length=50, verbose_name='Serial number'), - ), - migrations.AlterField( - model_name='rackreservation', - name='user', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL), - ), - migrations.AddField( - model_name='interface', - name='mode', - field=models.PositiveSmallIntegerField(blank=True, choices=[[100, 'Access'], [200, 'Tagged'], [300, 'Tagged All']], null=True), - ), - migrations.AddField( - model_name='interface', - name='tagged_vlans', - field=models.ManyToManyField(blank=True, related_name='interfaces_as_tagged', to='ipam.VLAN', verbose_name='Tagged VLANs'), - ), - migrations.AddField( - model_name='rackreservation', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='rackreservations', to='tenancy.Tenant'), - ), - migrations.CreateModel( - name='VirtualChassis', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('domain', models.CharField(blank=True, max_length=30)), - ('master', models.OneToOneField(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='vc_master_for', to='dcim.Device')), - ], - options={ - 'ordering': ['master'], - 'verbose_name_plural': 'virtual chassis', - }, - ), - migrations.AddField( - model_name='device', - name='virtual_chassis', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='members', to='dcim.VirtualChassis'), - ), - migrations.AddField( - model_name='device', - name='vc_position', - field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(255)]), - ), - migrations.AddField( - model_name='device', - name='vc_priority', - field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(255)]), - ), - migrations.AlterUniqueTogether( - name='device', - unique_together={('rack', 'position', 'face'), ('virtual_chassis', 'vc_position')}, - ), - migrations.AlterField( - model_name='platform', - name='napalm_driver', - field=models.CharField(blank=True, help_text='The name of the NAPALM driver to use when interacting with devices', max_length=50, verbose_name='NAPALM driver'), - ), - migrations.AddField( - model_name='site', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - migrations.AddField( - model_name='site', - name='status', - field=models.PositiveSmallIntegerField(choices=[[1, 'Active'], [2, 'Planned'], [4, 'Retired']], default=1), - ), - migrations.AddField( - model_name='site', - name='time_zone', - field=timezone_field.fields.TimeZoneField(blank=True), - ), - migrations.AlterField( - model_name='virtualchassis', - name='master', - field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='vc_master_for', to='dcim.Device'), - ), - migrations.AddField( - model_name='interface', - name='untagged_vlan', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='interfaces_as_untagged', to='ipam.VLAN', verbose_name='Untagged VLAN'), - ), - migrations.AddField( - model_name='platform', - name='manufacturer', - field=models.ForeignKey(blank=True, help_text='Optionally limit this platform to devices of a certain manufacturer', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='platforms', to='dcim.Manufacturer'), - ), - migrations.AddField( - model_name='device', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='devicetype', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='rack', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='site', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='consoleport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='consoleserverport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='devicebay', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='interface', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='inventoryitem', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='poweroutlet', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='powerport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='virtualchassis', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), - ), - migrations.AlterModelOptions( - name='rack', - options={'ordering': ['site', 'group', 'name']}, - ), - migrations.AlterUniqueTogether( - name='rack', - unique_together={('group', 'name'), ('group', 'facility_id')}, - ), - migrations.AddField( - model_name='site', - name='latitude', - field=models.DecimalField(blank=True, decimal_places=6, max_digits=8, null=True), - ), - migrations.AddField( - model_name='site', - name='longitude', - field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True), - ), - migrations.AddField( - model_name='devicerole', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='devicerole', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='devicetype', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='devicetype', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='manufacturer', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='manufacturer', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='platform', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='platform', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='rackgroup', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='rackgroup', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='rackreservation', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='rackrole', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='rackrole', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='region', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='region', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='virtualchassis', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='virtualchassis', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='device', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='device', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='rack', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='rack', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='rackreservation', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='site', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='site', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='platform', - name='napalm_args', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, help_text='Additional arguments to pass when initiating the NAPALM driver (JSON format)', null=True, verbose_name='NAPALM arguments'), - ), - ] diff --git a/netbox/dcim/migrations/0062_interface_mtu_squashed_0065_front_rear_ports.py b/netbox/dcim/migrations/0062_interface_mtu_squashed_0065_front_rear_ports.py deleted file mode 100644 index 71ce4191f..000000000 --- a/netbox/dcim/migrations/0062_interface_mtu_squashed_0065_front_rear_ports.py +++ /dev/null @@ -1,124 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.core.validators -import django.db.models.deletion -import taggit.managers -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0062_interface_mtu'), ('dcim', '0063_device_local_context_data'), ('dcim', '0064_remove_platform_rpc_client'), ('dcim', '0065_front_rear_ports')] - - dependencies = [ - ('taggit', '0002_auto_20150616_2121'), - ('dcim', '0061_platform_napalm_args'), - ] - - operations = [ - migrations.AlterField( - model_name='interface', - name='mtu', - field=models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(65536)], verbose_name='MTU'), - ), - migrations.AlterField( - model_name='interface', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1510, 'CFP2 (100GE)'], [1520, 'CFP4 (100GE)'], [1550, 'Cisco CPAK (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['SONET', [[6100, 'OC-3/STM-1'], [6200, 'OC-12/STM-4'], [6300, 'OC-48/STM-16'], [6400, 'OC-192/STM-64'], [6500, 'OC-768/STM-256'], [6600, 'OC-1920/STM-640'], [6700, 'OC-3840/STM-1234']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)'], [3320, 'SFP28 (32GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP'], [5300, 'Extreme SummitStack'], [5310, 'Extreme SummitStack-128'], [5320, 'Extreme SummitStack-256'], [5330, 'Extreme SummitStack-512']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AlterField( - model_name='interfacetemplate', - name='form_factor', - field=models.PositiveSmallIntegerField(choices=[['Virtual interfaces', [[0, 'Virtual'], [200, 'Link Aggregation Group (LAG)']]], ['Ethernet (fixed)', [[800, '100BASE-TX (10/100ME)'], [1000, '1000BASE-T (1GE)'], [1150, '10GBASE-T (10GE)'], [1170, '10GBASE-CX4 (10GE)']]], ['Ethernet (modular)', [[1050, 'GBIC (1GE)'], [1100, 'SFP (1GE)'], [1200, 'SFP+ (10GE)'], [1300, 'XFP (10GE)'], [1310, 'XENPAK (10GE)'], [1320, 'X2 (10GE)'], [1350, 'SFP28 (25GE)'], [1400, 'QSFP+ (40GE)'], [1500, 'CFP (100GE)'], [1510, 'CFP2 (100GE)'], [1520, 'CFP4 (100GE)'], [1550, 'Cisco CPAK (100GE)'], [1600, 'QSFP28 (100GE)']]], ['Wireless', [[2600, 'IEEE 802.11a'], [2610, 'IEEE 802.11b/g'], [2620, 'IEEE 802.11n'], [2630, 'IEEE 802.11ac'], [2640, 'IEEE 802.11ad']]], ['SONET', [[6100, 'OC-3/STM-1'], [6200, 'OC-12/STM-4'], [6300, 'OC-48/STM-16'], [6400, 'OC-192/STM-64'], [6500, 'OC-768/STM-256'], [6600, 'OC-1920/STM-640'], [6700, 'OC-3840/STM-1234']]], ['FibreChannel', [[3010, 'SFP (1GFC)'], [3020, 'SFP (2GFC)'], [3040, 'SFP (4GFC)'], [3080, 'SFP+ (8GFC)'], [3160, 'SFP+ (16GFC)'], [3320, 'SFP28 (32GFC)']]], ['Serial', [[4000, 'T1 (1.544 Mbps)'], [4010, 'E1 (2.048 Mbps)'], [4040, 'T3 (45 Mbps)'], [4050, 'E3 (34 Mbps)']]], ['Stacking', [[5000, 'Cisco StackWise'], [5050, 'Cisco StackWise Plus'], [5100, 'Cisco FlexStack'], [5150, 'Cisco FlexStack Plus'], [5200, 'Juniper VCP'], [5300, 'Extreme SummitStack'], [5310, 'Extreme SummitStack-128'], [5320, 'Extreme SummitStack-256'], [5330, 'Extreme SummitStack-512']]], ['Other', [[32767, 'Other']]]], default=1200), - ), - migrations.AddField( - model_name='device', - name='local_context_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), - ), - migrations.RemoveField( - model_name='platform', - name='rpc_client', - ), - migrations.CreateModel( - name='RearPort', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=64)), - ('type', models.PositiveSmallIntegerField()), - ('positions', models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(64)])), - ('description', models.CharField(blank=True, max_length=100)), - ('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rearports', to='dcim.Device')), - ('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')), - ], - options={ - 'ordering': ['device', 'name'], - 'unique_together': {('device', 'name')}, - }, - ), - migrations.CreateModel( - name='RearPortTemplate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=64)), - ('type', models.PositiveSmallIntegerField()), - ('positions', models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(64)])), - ('device_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rearport_templates', to='dcim.DeviceType')), - ], - options={ - 'ordering': ['device_type', 'name'], - 'unique_together': {('device_type', 'name')}, - }, - ), - migrations.CreateModel( - name='FrontPortTemplate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=64)), - ('type', models.PositiveSmallIntegerField()), - ('rear_port_position', models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(64)])), - ('device_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='frontport_templates', to='dcim.DeviceType')), - ('rear_port', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='frontport_templates', to='dcim.RearPortTemplate')), - ], - options={ - 'ordering': ['device_type', 'name'], - 'unique_together': {('rear_port', 'rear_port_position'), ('device_type', 'name')}, - }, - ), - migrations.CreateModel( - name='FrontPort', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=64)), - ('type', models.PositiveSmallIntegerField()), - ('rear_port_position', models.PositiveSmallIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(64)])), - ('description', models.CharField(blank=True, max_length=100)), - ('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='frontports', to='dcim.Device')), - ('rear_port', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='frontports', to='dcim.RearPort')), - ('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')), - ], - options={ - 'ordering': ['device', 'name'], - 'unique_together': {('device', 'name'), ('rear_port', 'rear_port_position')}, - }, - ), - migrations.AlterField( - model_name='consoleporttemplate', - name='device_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='consoleport_templates', to='dcim.DeviceType'), - ), - migrations.AlterField( - model_name='consoleserverporttemplate', - name='device_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='consoleserverport_templates', to='dcim.DeviceType'), - ), - migrations.AlterField( - model_name='poweroutlettemplate', - name='device_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='poweroutlet_templates', to='dcim.DeviceType'), - ), - migrations.AlterField( - model_name='powerporttemplate', - name='device_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='powerport_templates', to='dcim.DeviceType'), - ), - ] diff --git a/netbox/dcim/migrations/0067_device_type_remove_qualifiers_squashed_0070_custom_tag_models.py b/netbox/dcim/migrations/0067_device_type_remove_qualifiers_squashed_0070_custom_tag_models.py deleted file mode 100644 index 6fbf115d9..000000000 --- a/netbox/dcim/migrations/0067_device_type_remove_qualifiers_squashed_0070_custom_tag_models.py +++ /dev/null @@ -1,146 +0,0 @@ -import taggit.managers -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('dcim', '0067_device_type_remove_qualifiers'), ('dcim', '0068_rack_new_fields'), ('dcim', '0069_deprecate_nullablecharfield'), ('dcim', '0070_custom_tag_models')] - - dependencies = [ - ('extras', '0019_tag_taggeditem'), - ('dcim', '0066_cables'), - ] - - operations = [ - migrations.RemoveField( - model_name='devicetype', - name='is_console_server', - ), - migrations.RemoveField( - model_name='devicetype', - name='is_network_device', - ), - migrations.RemoveField( - model_name='devicetype', - name='is_pdu', - ), - migrations.RemoveField( - model_name='devicetype', - name='interface_ordering', - ), - migrations.AddField( - model_name='rack', - name='status', - field=models.PositiveSmallIntegerField(default=3), - ), - migrations.AddField( - model_name='rack', - name='outer_depth', - field=models.PositiveSmallIntegerField(blank=True, null=True), - ), - migrations.AddField( - model_name='rack', - name='outer_unit', - field=models.PositiveSmallIntegerField(blank=True, null=True), - ), - migrations.AddField( - model_name='rack', - name='outer_width', - field=models.PositiveSmallIntegerField(blank=True, null=True), - ), - migrations.AlterField( - model_name='device', - name='asset_tag', - field=models.CharField(blank=True, max_length=50, null=True, unique=True), - ), - migrations.AlterField( - model_name='device', - name='name', - field=models.CharField(blank=True, max_length=64, null=True, unique=True), - ), - migrations.AlterField( - model_name='inventoryitem', - name='asset_tag', - field=models.CharField(blank=True, max_length=50, null=True, unique=True), - ), - migrations.AddField( - model_name='rack', - name='asset_tag', - field=models.CharField(blank=True, max_length=50, null=True, unique=True), - ), - migrations.AlterField( - model_name='rack', - name='facility_id', - field=models.CharField(blank=True, max_length=50, null=True), - ), - migrations.AlterField( - model_name='consoleport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='consoleserverport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='device', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='devicebay', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='devicetype', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='frontport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='interface', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='inventoryitem', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='poweroutlet', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='powerport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='rack', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='rearport', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='site', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AlterField( - model_name='virtualchassis', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - ] diff --git a/netbox/extras/migrations/0001_initial_squashed_0013_objectchange.py b/netbox/extras/migrations/0001_initial_squashed_0013_objectchange.py deleted file mode 100644 index 112a8c9af..000000000 --- a/netbox/extras/migrations/0001_initial_squashed_0013_objectchange.py +++ /dev/null @@ -1,265 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.db.models.deletion -from django.conf import settings -from django.db import connection, migrations, models -from django.db.utils import OperationalError - -import extras.models - - -def verify_postgresql_version(apps, schema_editor): - """ - Verify that PostgreSQL is version 9.4 or higher. - """ - # https://www.postgresql.org/docs/current/libpq-status.html#LIBPQ-PQSERVERVERSION - DB_MINIMUM_VERSION = 90400 # 9.4.0 - - try: - pg_version = connection.pg_version - - if pg_version < DB_MINIMUM_VERSION: - raise Exception("PostgreSQL 9.4.0 ({}) or higher is required ({} found). Upgrade PostgreSQL and then run migrations again.".format(DB_MINIMUM_VERSION, pg_version)) - - # Skip if the database is missing (e.g. for CI testing) or misconfigured. - except OperationalError: - pass - - -def is_filterable_to_filter_logic(apps, schema_editor): - CustomField = apps.get_model('extras', 'CustomField') - CustomField.objects.filter(is_filterable=False).update(filter_logic=0) - CustomField.objects.filter(is_filterable=True).update(filter_logic=1) - # Select fields match on primary key only - CustomField.objects.filter(is_filterable=True, type=600).update(filter_logic=2) - - -class Migration(migrations.Migration): - - replaces = [('extras', '0001_initial'), ('extras', '0002_custom_fields'), ('extras', '0003_exporttemplate_add_description'), ('extras', '0004_topologymap_change_comma_to_semicolon'), ('extras', '0005_useraction_add_bulk_create'), ('extras', '0006_add_imageattachments'), ('extras', '0007_unicode_literals'), ('extras', '0008_reports'), ('extras', '0009_topologymap_type'), ('extras', '0010_customfield_filter_logic'), ('extras', '0011_django2'), ('extras', '0012_webhooks'), ('extras', '0013_objectchange')] - - dependencies = [ - ('dcim', '0002_auto_20160622_1821'), - ('contenttypes', '0002_remove_content_type_name'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='CustomField', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type', models.PositiveSmallIntegerField(choices=[(100, 'Text'), (200, 'Integer'), (300, 'Boolean (true/false)'), (400, 'Date'), (500, 'URL'), (600, 'Selection')], default=100)), - ('name', models.CharField(max_length=50, unique=True)), - ('label', models.CharField(blank=True, help_text="Name of the field as displayed to users (if not provided, the field's name will be used)", max_length=50)), - ('description', models.CharField(blank=True, max_length=100)), - ('required', models.BooleanField(default=False, help_text='Determines whether this field is required when creating new objects or editing an existing object.')), - ('is_filterable', models.BooleanField(default=True, help_text='This field can be used to filter objects.')), - ('default', models.CharField(blank=True, help_text='Default value for the field. Use "true" or "false" for booleans.', max_length=100)), - ('weight', models.PositiveSmallIntegerField(default=100, help_text='Fields with higher weights appear lower in a form')), - ('obj_type', models.ManyToManyField(help_text='The object(s) to which this field applies.', related_name='custom_fields', to='contenttypes.ContentType', verbose_name='Object(s)')), - ], - options={ - 'ordering': ['weight', 'name'], - }, - ), - migrations.CreateModel( - name='CustomFieldValue', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('obj_id', models.PositiveIntegerField()), - ('serialized_value', models.CharField(max_length=255)), - ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='values', to='extras.CustomField')), - ('obj_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), - ], - options={ - 'ordering': ['obj_type', 'obj_id'], - 'unique_together': {('field', 'obj_type', 'obj_id')}, - }, - ), - migrations.CreateModel( - name='ExportTemplate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('template_code', models.TextField()), - ('mime_type', models.CharField(blank=True, max_length=15)), - ('file_extension', models.CharField(blank=True, max_length=15)), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), - ('description', models.CharField(blank=True, max_length=200)), - ], - options={ - 'ordering': ['content_type', 'name'], - 'unique_together': {('content_type', 'name')}, - }, - ), - migrations.CreateModel( - name='CustomFieldChoice', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('value', models.CharField(max_length=100)), - ('weight', models.PositiveSmallIntegerField(default=100, help_text='Higher weights appear lower in the list')), - ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='extras.CustomField')), - ], - options={ - 'ordering': ['field', 'weight', 'value'], - 'unique_together': {('field', 'value')}, - }, - ), - migrations.CreateModel( - name='Graph', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type', models.PositiveSmallIntegerField(choices=[(100, 'Interface'), (200, 'Provider'), (300, 'Site')])), - ('weight', models.PositiveSmallIntegerField(default=1000)), - ('name', models.CharField(max_length=100, verbose_name='Name')), - ('source', models.CharField(max_length=500, verbose_name='Source URL')), - ('link', models.URLField(blank=True, verbose_name='Link URL')), - ], - options={ - 'ordering': ['type', 'weight', 'name'], - }, - ), - migrations.CreateModel( - name='ImageAttachment', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('object_id', models.PositiveIntegerField()), - ('image', models.ImageField(height_field='image_height', upload_to=extras.models.image_upload, width_field='image_width')), - ('image_height', models.PositiveSmallIntegerField()), - ('image_width', models.PositiveSmallIntegerField()), - ('name', models.CharField(blank=True, max_length=50)), - ('created', models.DateTimeField(auto_now_add=True)), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='TopologyMap', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('device_patterns', models.TextField(help_text='Identify devices to include in the diagram using regular expressions, one per line. Each line will result in a new tier of the drawing. Separate multiple regexes within a line using semicolons. Devices will be rendered in the order they are defined.')), - ('description', models.CharField(blank=True, max_length=100)), - ('site', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='topology_maps', to='dcim.Site')), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='UserAction', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('time', models.DateTimeField(auto_now_add=True)), - ('object_id', models.PositiveIntegerField(blank=True, null=True)), - ('action', models.PositiveSmallIntegerField(choices=[(1, 'created'), (7, 'bulk created'), (2, 'imported'), (3, 'modified'), (4, 'bulk edited'), (5, 'deleted'), (6, 'bulk deleted')])), - ('message', models.TextField(blank=True)), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='actions', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-time'], - }, - ), - migrations.RunPython( - code=verify_postgresql_version, - ), - migrations.CreateModel( - name='ReportResult', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('report', models.CharField(max_length=255, unique=True)), - ('created', models.DateTimeField(auto_now_add=True)), - ('failed', models.BooleanField()), - ('data', django.contrib.postgres.fields.jsonb.JSONField()), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['report'], - }, - ), - migrations.AddField( - model_name='topologymap', - name='type', - field=models.PositiveSmallIntegerField(choices=[(1, 'Network'), (2, 'Console'), (3, 'Power')], default=1), - ), - migrations.AddField( - model_name='customfield', - name='filter_logic', - field=models.PositiveSmallIntegerField(choices=[(0, 'Disabled'), (1, 'Loose'), (2, 'Exact')], default=1, help_text='Loose matches any instance of a given string; exact matches the entire field.'), - ), - migrations.AlterField( - model_name='customfield', - name='required', - field=models.BooleanField(default=False, help_text='If true, this field is required when creating new objects or editing an existing object.'), - ), - migrations.AlterField( - model_name='customfield', - name='weight', - field=models.PositiveSmallIntegerField(default=100, help_text='Fields with higher weights appear lower in a form.'), - ), - migrations.RunPython( - code=is_filterable_to_filter_logic, - ), - migrations.RemoveField( - model_name='customfield', - name='is_filterable', - ), - migrations.AlterField( - model_name='customfield', - name='obj_type', - field=models.ManyToManyField(help_text='The object(s) to which this field applies.', limit_choices_to={'model__in': ('provider', 'circuit', 'site', 'rack', 'devicetype', 'device', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'tenant', 'cluster', 'virtualmachine')}, related_name='custom_fields', to='contenttypes.ContentType', verbose_name='Object(s)'), - ), - migrations.AlterField( - model_name='customfieldchoice', - name='field', - field=models.ForeignKey(limit_choices_to={'type': 600}, on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='extras.CustomField'), - ), - migrations.AlterField( - model_name='exporttemplate', - name='content_type', - field=models.ForeignKey(limit_choices_to={'model__in': ['provider', 'circuit', 'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', 'consoleport', 'powerport', 'interfaceconnection', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'tenant', 'cluster', 'virtualmachine']}, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'), - ), - migrations.CreateModel( - name='Webhook', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=150, unique=True)), - ('type_create', models.BooleanField(default=False, help_text='Call this webhook when a matching object is created.')), - ('type_update', models.BooleanField(default=False, help_text='Call this webhook when a matching object is updated.')), - ('type_delete', models.BooleanField(default=False, help_text='Call this webhook when a matching object is deleted.')), - ('payload_url', models.CharField(help_text='A POST will be sent to this URL when the webhook is called.', max_length=500, verbose_name='URL')), - ('http_content_type', models.PositiveSmallIntegerField(choices=[(1, 'application/json'), (2, 'application/x-www-form-urlencoded')], default=1, verbose_name='HTTP content type')), - ('secret', models.CharField(blank=True, help_text="When provided, the request will include a 'X-Hook-Signature' header containing a HMAC hex digest of the payload body using the secret as the key. The secret is not transmitted in the request.", max_length=255)), - ('enabled', models.BooleanField(default=True)), - ('ssl_verification', models.BooleanField(default=True, help_text='Enable SSL certificate verification. Disable with caution!', verbose_name='SSL verification')), - ('obj_type', models.ManyToManyField(help_text='The object(s) to which this Webhook applies.', related_name='webhooks', to='contenttypes.ContentType', verbose_name='Object types')), - ], - options={ - 'unique_together': {('payload_url', 'type_create', 'type_update', 'type_delete')}, - }, - ), - migrations.CreateModel( - name='ObjectChange', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('time', models.DateTimeField(auto_now_add=True)), - ('user_name', models.CharField(editable=False, max_length=150)), - ('request_id', models.UUIDField(editable=False)), - ('action', models.PositiveSmallIntegerField(choices=[(1, 'Created'), (2, 'Updated'), (3, 'Deleted')])), - ('changed_object_id', models.PositiveIntegerField()), - ('related_object_id', models.PositiveIntegerField(blank=True, null=True)), - ('object_repr', models.CharField(editable=False, max_length=200)), - ('object_data', django.contrib.postgres.fields.jsonb.JSONField(editable=False)), - ('changed_object_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), - ('related_object_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='changes', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-time'], - }, - ), - ] diff --git a/netbox/extras/migrations/0014_configcontexts_squashed_0019_tag_taggeditem.py b/netbox/extras/migrations/0014_configcontexts_squashed_0019_tag_taggeditem.py deleted file mode 100644 index 6f8b63649..000000000 --- a/netbox/extras/migrations/0014_configcontexts_squashed_0019_tag_taggeditem.py +++ /dev/null @@ -1,106 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.db.models.deletion -from django.db import migrations, models - - -def set_template_language(apps, schema_editor): - """ - Set the language for all existing ExportTemplates to Django (Jinja2 is the default for new ExportTemplates). - """ - ExportTemplate = apps.get_model('extras', 'ExportTemplate') - ExportTemplate.objects.update(template_language=10) - - -class Migration(migrations.Migration): - - replaces = [('extras', '0014_configcontexts'), ('extras', '0015_remove_useraction'), ('extras', '0016_exporttemplate_add_cable'), ('extras', '0017_exporttemplate_mime_type_length'), ('extras', '0018_exporttemplate_add_jinja2'), ('extras', '0019_tag_taggeditem')] - - dependencies = [ - ('extras', '0013_objectchange'), - ('tenancy', '0005_change_logging'), - ('dcim', '0061_platform_napalm_args'), - ('contenttypes', '0002_remove_content_type_name'), - ] - - operations = [ - migrations.CreateModel( - name='ConfigContext', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100, unique=True)), - ('weight', models.PositiveSmallIntegerField(default=1000)), - ('description', models.CharField(blank=True, max_length=100)), - ('is_active', models.BooleanField(default=True)), - ('data', django.contrib.postgres.fields.jsonb.JSONField()), - ('platforms', models.ManyToManyField(blank=True, related_name='_configcontext_platforms_+', to='dcim.Platform')), - ('regions', models.ManyToManyField(blank=True, related_name='_configcontext_regions_+', to='dcim.Region')), - ('roles', models.ManyToManyField(blank=True, related_name='_configcontext_roles_+', to='dcim.DeviceRole')), - ('sites', models.ManyToManyField(blank=True, related_name='_configcontext_sites_+', to='dcim.Site')), - ('tenant_groups', models.ManyToManyField(blank=True, related_name='_configcontext_tenant_groups_+', to='tenancy.TenantGroup')), - ('tenants', models.ManyToManyField(blank=True, related_name='_configcontext_tenants_+', to='tenancy.Tenant')), - ], - options={ - 'ordering': ['weight', 'name'], - }, - ), - migrations.AlterField( - model_name='customfield', - name='obj_type', - field=models.ManyToManyField(help_text='The object(s) to which this field applies.', limit_choices_to={'model__in': ('provider', 'circuit', 'site', 'rack', 'devicetype', 'device', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', 'secret', 'tenant', 'cluster', 'virtualmachine')}, related_name='custom_fields', to='contenttypes.ContentType', verbose_name='Object(s)'), - ), - migrations.AlterField( - model_name='exporttemplate', - name='content_type', - field=models.ForeignKey(limit_choices_to={'model__in': ['provider', 'circuit', 'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', 'consoleport', 'powerport', 'interfaceconnection', 'virtualchassis', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', 'secret', 'tenant', 'cluster', 'virtualmachine']}, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'), - ), - migrations.AlterField( - model_name='webhook', - name='obj_type', - field=models.ManyToManyField(help_text='The object(s) to which this Webhook applies.', limit_choices_to={'model__in': ('provider', 'circuit', 'site', 'rack', 'devicetype', 'device', 'virtualchassis', 'consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'devicebay', 'inventoryitem', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', 'secret', 'tenant', 'cluster', 'virtualmachine')}, related_name='webhooks', to='contenttypes.ContentType', verbose_name='Object types'), - ), - migrations.DeleteModel( - name='UserAction', - ), - migrations.AlterField( - model_name='exporttemplate', - name='content_type', - field=models.ForeignKey(limit_choices_to={'model__in': ['provider', 'circuit', 'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', 'consoleport', 'powerport', 'interface', 'cable', 'virtualchassis', 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', 'secret', 'tenant', 'cluster', 'virtualmachine']}, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'), - ), - migrations.AlterField( - model_name='exporttemplate', - name='mime_type', - field=models.CharField(blank=True, max_length=50), - ), - migrations.AddField( - model_name='exporttemplate', - name='template_language', - field=models.PositiveSmallIntegerField(default=20), - ), - migrations.RunPython( - code=set_template_language, - ), - migrations.CreateModel( - name='Tag', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=100, unique=True)), - ('slug', models.SlugField(max_length=100, unique=True)), - ], - options={ - 'abstract': False, - }, - ), - migrations.CreateModel( - name='TaggedItem', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('object_id', models.IntegerField(db_index=True)), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extras_taggeditem_tagged_items', to='contenttypes.ContentType')), - ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extras_taggeditem_items', to='extras.Tag')), - ], - options={ - 'abstract': False, - 'index_together': {('content_type', 'object_id')}, - }, - ), - ] diff --git a/netbox/extras/migrations/0020_tag_data_squashed_0021_add_color_comments_changelog_to_tag.py b/netbox/extras/migrations/0020_tag_data_squashed_0021_add_color_comments_changelog_to_tag.py deleted file mode 100644 index a673bf880..000000000 --- a/netbox/extras/migrations/0020_tag_data_squashed_0021_add_color_comments_changelog_to_tag.py +++ /dev/null @@ -1,93 +0,0 @@ -from django.db import migrations, models - -import utilities.fields - - -def copy_tags(apps, schema_editor): - """ - Copy data from taggit_tag to extras_tag - """ - TaggitTag = apps.get_model('taggit', 'Tag') - ExtrasTag = apps.get_model('extras', 'Tag') - - tags_values = TaggitTag.objects.all().values('id', 'name', 'slug') - tags = [ExtrasTag(**tag) for tag in tags_values] - ExtrasTag.objects.bulk_create(tags) - - -def copy_taggeditems(apps, schema_editor): - """ - Copy data from taggit_taggeditem to extras_taggeditem - """ - TaggitTaggedItem = apps.get_model('taggit', 'TaggedItem') - ExtrasTaggedItem = apps.get_model('extras', 'TaggedItem') - - tagged_items_values = TaggitTaggedItem.objects.all().values('id', 'object_id', 'content_type_id', 'tag_id') - tagged_items = [ExtrasTaggedItem(**tagged_item) for tagged_item in tagged_items_values] - ExtrasTaggedItem.objects.bulk_create(tagged_items) - - -def delete_taggit_taggeditems(apps, schema_editor): - """ - Delete all TaggedItem instances from taggit_taggeditem - """ - TaggitTaggedItem = apps.get_model('taggit', 'TaggedItem') - TaggitTaggedItem.objects.all().delete() - - -def delete_taggit_tags(apps, schema_editor): - """ - Delete all Tag instances from taggit_tag - """ - TaggitTag = apps.get_model('taggit', 'Tag') - TaggitTag.objects.all().delete() - - -class Migration(migrations.Migration): - - replaces = [('extras', '0020_tag_data'), ('extras', '0021_add_color_comments_changelog_to_tag')] - - dependencies = [ - ('extras', '0019_tag_taggeditem'), - ('virtualization', '0009_custom_tag_models'), - ('tenancy', '0006_custom_tag_models'), - ('secrets', '0006_custom_tag_models'), - ('dcim', '0070_custom_tag_models'), - ('ipam', '0025_custom_tag_models'), - ('circuits', '0015_custom_tag_models'), - ] - - operations = [ - migrations.RunPython( - code=copy_tags, - ), - migrations.RunPython( - code=copy_taggeditems, - ), - migrations.RunPython( - code=delete_taggit_taggeditems, - ), - migrations.RunPython( - code=delete_taggit_tags, - ), - migrations.AddField( - model_name='tag', - name='color', - field=utilities.fields.ColorField(default='9e9e9e', max_length=6), - ), - migrations.AddField( - model_name='tag', - name='comments', - field=models.TextField(blank=True, default=''), - ), - migrations.AddField( - model_name='tag', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='tag', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - ] diff --git a/netbox/extras/migrations/0022_custom_links_squashed_0034_configcontext_tags.py b/netbox/extras/migrations/0022_custom_links_squashed_0034_configcontext_tags.py deleted file mode 100644 index b10841a6a..000000000 --- a/netbox/extras/migrations/0022_custom_links_squashed_0034_configcontext_tags.py +++ /dev/null @@ -1,227 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.db.models.deletion -from django.db import migrations, models - -import extras.models - -CUSTOMFIELD_TYPE_CHOICES = ( - (100, 'text'), - (200, 'integer'), - (300, 'boolean'), - (400, 'date'), - (500, 'url'), - (600, 'select') -) - -CUSTOMFIELD_FILTER_LOGIC_CHOICES = ( - (0, 'disabled'), - (1, 'integer'), - (2, 'exact'), -) - -OBJECTCHANGE_ACTION_CHOICES = ( - (1, 'create'), - (2, 'update'), - (3, 'delete'), -) - -EXPORTTEMPLATE_LANGUAGE_CHOICES = ( - (10, 'django'), - (20, 'jinja2'), -) - -WEBHOOK_CONTENTTYPE_CHOICES = ( - (1, 'application/json'), - (2, 'application/x-www-form-urlencoded'), -) - -GRAPH_TYPE_CHOICES = ( - (100, 'dcim', 'interface'), - (150, 'dcim', 'device'), - (200, 'circuits', 'provider'), - (300, 'dcim', 'site'), -) - - -def customfield_type_to_slug(apps, schema_editor): - CustomField = apps.get_model('extras', 'CustomField') - for id, slug in CUSTOMFIELD_TYPE_CHOICES: - CustomField.objects.filter(type=str(id)).update(type=slug) - - -def customfield_filter_logic_to_slug(apps, schema_editor): - CustomField = apps.get_model('extras', 'CustomField') - for id, slug in CUSTOMFIELD_FILTER_LOGIC_CHOICES: - CustomField.objects.filter(filter_logic=str(id)).update(filter_logic=slug) - - -def objectchange_action_to_slug(apps, schema_editor): - ObjectChange = apps.get_model('extras', 'ObjectChange') - for id, slug in OBJECTCHANGE_ACTION_CHOICES: - ObjectChange.objects.filter(action=str(id)).update(action=slug) - - -def exporttemplate_language_to_slug(apps, schema_editor): - ExportTemplate = apps.get_model('extras', 'ExportTemplate') - for id, slug in EXPORTTEMPLATE_LANGUAGE_CHOICES: - ExportTemplate.objects.filter(template_language=str(id)).update(template_language=slug) - - -def webhook_contenttype_to_slug(apps, schema_editor): - Webhook = apps.get_model('extras', 'Webhook') - for id, slug in WEBHOOK_CONTENTTYPE_CHOICES: - Webhook.objects.filter(http_content_type=str(id)).update(http_content_type=slug) - - -def graph_type_to_fk(apps, schema_editor): - Graph = apps.get_model('extras', 'Graph') - ContentType = apps.get_model('contenttypes', 'ContentType') - - # On a new installation (and during tests) content types might not yet exist. So, we only perform the bulk - # updates if a Graph has been created, which implies that we're working with a populated database. - if Graph.objects.exists(): - for id, app_label, model in GRAPH_TYPE_CHOICES: - content_type = ContentType.objects.get(app_label=app_label, model=model) - Graph.objects.filter(type=id).update(type=content_type.pk) - - -class Migration(migrations.Migration): - - replaces = [('extras', '0022_custom_links'), ('extras', '0023_fix_tag_sequences'), ('extras', '0024_scripts'), ('extras', '0025_objectchange_time_index'), ('extras', '0026_webhook_ca_file_path'), ('extras', '0027_webhook_additional_headers'), ('extras', '0028_remove_topology_maps'), ('extras', '0029_3569_customfield_fields'), ('extras', '0030_3569_objectchange_fields'), ('extras', '0031_3569_exporttemplate_fields'), ('extras', '0032_3569_webhook_fields'), ('extras', '0033_graph_type_template_language'), ('extras', '0034_configcontext_tags')] - - dependencies = [ - ('extras', '0021_add_color_comments_changelog_to_tag'), - ('contenttypes', '0002_remove_content_type_name'), - ] - - operations = [ - migrations.CreateModel( - name='CustomLink', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=100, unique=True)), - ('text', models.CharField(max_length=500)), - ('url', models.CharField(max_length=500)), - ('weight', models.PositiveSmallIntegerField(default=100)), - ('group_name', models.CharField(blank=True, max_length=50)), - ('button_class', models.CharField(default='default', max_length=30)), - ('new_window', models.BooleanField()), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), - ], - options={ - 'ordering': ['group_name', 'weight', 'name'], - }, - ), - migrations.AlterField( - model_name='customfield', - name='obj_type', - field=models.ManyToManyField(related_name='custom_fields', to='contenttypes.ContentType'), - ), - migrations.AlterField( - model_name='exporttemplate', - name='content_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'), - ), - migrations.AlterField( - model_name='webhook', - name='obj_type', - field=models.ManyToManyField(related_name='webhooks', to='contenttypes.ContentType'), - ), - migrations.RunSQL( - sql="SELECT setval('extras_tag_id_seq', (SELECT id FROM extras_tag ORDER BY id DESC LIMIT 1) + 1)", - ), - migrations.RunSQL( - sql="SELECT setval('extras_taggeditem_id_seq', (SELECT id FROM extras_taggeditem ORDER BY id DESC LIMIT 1) + 1)", - ), - migrations.CreateModel( - name='Script', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)), - ], - options={ - 'permissions': (('run_script', 'Can run script'),), - 'managed': False, - }, - ), - migrations.AlterField( - model_name='objectchange', - name='time', - field=models.DateTimeField(auto_now_add=True, db_index=True), - ), - migrations.AddField( - model_name='webhook', - name='ca_file_path', - field=models.CharField(blank=True, max_length=4096, null=True), - ), - migrations.AddField( - model_name='webhook', - name='additional_headers', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), - ), - migrations.DeleteModel( - name='TopologyMap', - ), - migrations.AlterField( - model_name='customfield', - name='type', - field=models.CharField(default='text', max_length=50), - ), - migrations.RunPython( - code=customfield_type_to_slug, - ), - migrations.AlterField( - model_name='customfieldchoice', - name='field', - field=models.ForeignKey(limit_choices_to={'type': 'select'}, on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='extras.CustomField'), - ), - migrations.AlterField( - model_name='customfield', - name='filter_logic', - field=models.CharField(default='loose', max_length=50), - ), - migrations.RunPython( - code=customfield_filter_logic_to_slug, - ), - migrations.AlterField( - model_name='objectchange', - name='action', - field=models.CharField(max_length=50), - ), - migrations.RunPython( - code=objectchange_action_to_slug, - ), - migrations.AlterField( - model_name='exporttemplate', - name='template_language', - field=models.CharField(default='jinja2', max_length=50), - ), - migrations.RunPython( - code=exporttemplate_language_to_slug, - ), - migrations.AlterField( - model_name='webhook', - name='http_content_type', - field=models.CharField(default='application/json', max_length=50), - ), - migrations.RunPython( - code=webhook_contenttype_to_slug, - ), - migrations.RunPython( - code=graph_type_to_fk, - ), - migrations.AlterField( - model_name='graph', - name='type', - field=models.ForeignKey(limit_choices_to={'model__in': ['provider', 'device', 'interface', 'site']}, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'), - ), - migrations.AddField( - model_name='graph', - name='template_language', - field=models.CharField(default='jinja2', max_length=50), - ), - migrations.AddField( - model_name='configcontext', - name='tags', - field=models.ManyToManyField(blank=True, related_name='_configcontext_tags_+', to='extras.Tag'), - ), - ] diff --git a/netbox/ipam/migrations/0003_ipam_add_vlangroups_squashed_0011_rir_add_is_private.py b/netbox/ipam/migrations/0003_ipam_add_vlangroups_squashed_0011_rir_add_is_private.py deleted file mode 100644 index c3b86135c..000000000 --- a/netbox/ipam/migrations/0003_ipam_add_vlangroups_squashed_0011_rir_add_is_private.py +++ /dev/null @@ -1,100 +0,0 @@ -import django.db.models.deletion -from django.db import migrations, models - -import ipam.fields - - -class Migration(migrations.Migration): - - replaces = [('ipam', '0003_ipam_add_vlangroups'), ('ipam', '0004_ipam_vlangroup_uniqueness'), ('ipam', '0005_auto_20160725_1842'), ('ipam', '0006_vrf_vlan_add_tenant'), ('ipam', '0007_prefix_ipaddress_add_tenant'), ('ipam', '0008_prefix_change_order'), ('ipam', '0009_ipaddress_add_status'), ('ipam', '0010_ipaddress_help_texts'), ('ipam', '0011_rir_add_is_private')] - - dependencies = [ - ('tenancy', '0001_initial'), - ('dcim', '0010_devicebay_installed_device_set_null'), - ('ipam', '0002_vrf_add_enforce_unique'), - ] - - operations = [ - migrations.CreateModel( - name='VLANGroup', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50)), - ('slug', models.SlugField()), - ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vlan_groups', to='dcim.Site')), - ], - options={ - 'ordering': ['site', 'name'], - 'unique_together': {('site', 'name'), ('site', 'slug')}, - 'verbose_name': 'VLAN group', - 'verbose_name_plural': 'VLAN groups', - }, - ), - migrations.AddField( - model_name='vlan', - name='group', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='ipam.VLANGroup'), - ), - migrations.AlterModelOptions( - name='vlan', - options={'ordering': ['site', 'group', 'vid'], 'verbose_name': 'VLAN', 'verbose_name_plural': 'VLANs'}, - ), - migrations.AlterUniqueTogether( - name='vlan', - unique_together={('group', 'vid'), ('group', 'name')}, - ), - migrations.AddField( - model_name='vlan', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - migrations.AlterField( - model_name='vlan', - name='name', - field=models.CharField(max_length=64), - ), - migrations.AddField( - model_name='vlan', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='tenancy.Tenant'), - ), - migrations.AddField( - model_name='vrf', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vrfs', to='tenancy.Tenant'), - ), - migrations.AddField( - model_name='ipaddress', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='ip_addresses', to='tenancy.Tenant'), - ), - migrations.AddField( - model_name='prefix', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='prefixes', to='tenancy.Tenant'), - ), - migrations.AlterModelOptions( - name='prefix', - options={'ordering': ['vrf', 'family', 'prefix'], 'verbose_name_plural': 'prefixes'}, - ), - migrations.AddField( - model_name='ipaddress', - name='status', - field=models.PositiveSmallIntegerField(choices=[(1, b'Active'), (2, b'Reserved'), (5, b'DHCP')], default=1, verbose_name=b'Status'), - ), - migrations.AlterField( - model_name='ipaddress', - name='address', - field=ipam.fields.IPAddressField(help_text=b'IPv4 or IPv6 address (with mask)'), - ), - migrations.AlterField( - model_name='ipaddress', - name='nat_inside', - field=models.OneToOneField(blank=True, help_text=b'The IP for which this address is the "outside" IP', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='nat_outside', to='ipam.IPAddress', verbose_name=b'NAT (Inside)'), - ), - migrations.AddField( - model_name='rir', - name='is_private', - field=models.BooleanField(default=False, help_text=b'IP space managed by this RIR is considered private', verbose_name=b'Private'), - ), - ] diff --git a/netbox/ipam/migrations/0012_services_squashed_0018_remove_service_uniqueness_constraint.py b/netbox/ipam/migrations/0012_services_squashed_0018_remove_service_uniqueness_constraint.py deleted file mode 100644 index 6bc5020d4..000000000 --- a/netbox/ipam/migrations/0012_services_squashed_0018_remove_service_uniqueness_constraint.py +++ /dev/null @@ -1,171 +0,0 @@ -import django.core.validators -import django.db.models.deletion -from django.db import migrations, models - -import ipam.fields - - -class Migration(migrations.Migration): - - replaces = [('ipam', '0012_services'), ('ipam', '0013_prefix_add_is_pool'), ('ipam', '0014_ipaddress_status_add_deprecated'), ('ipam', '0015_global_vlans'), ('ipam', '0016_unicode_literals'), ('ipam', '0017_ipaddress_roles'), ('ipam', '0018_remove_service_uniqueness_constraint')] - - dependencies = [ - ('dcim', '0022_color_names_to_rgb'), - ('ipam', '0011_rir_add_is_private'), - ] - - operations = [ - migrations.AlterField( - model_name='prefix', - name='prefix', - field=ipam.fields.IPNetworkField(help_text=b'IPv4 or IPv6 network with mask'), - ), - migrations.AlterField( - model_name='prefix', - name='role', - field=models.ForeignKey(blank=True, help_text=b'The primary function of this prefix', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prefixes', to='ipam.Role'), - ), - migrations.AlterField( - model_name='prefix', - name='status', - field=models.PositiveSmallIntegerField(choices=[(0, b'Container'), (1, b'Active'), (2, b'Reserved'), (3, b'Deprecated')], default=1, help_text=b'Operational status of this prefix', verbose_name=b'Status'), - ), - migrations.AlterField( - model_name='ipaddress', - name='status', - field=models.PositiveSmallIntegerField(choices=[(1, b'Active'), (2, b'Reserved'), (3, b'Deprecated'), (5, b'DHCP')], default=1, verbose_name=b'Status'), - ), - migrations.AlterField( - model_name='vlan', - name='site', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='dcim.Site'), - ), - migrations.AlterField( - model_name='vlangroup', - name='site', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlan_groups', to='dcim.Site'), - ), - migrations.AlterField( - model_name='aggregate', - name='family', - field=models.PositiveSmallIntegerField(choices=[(4, 'IPv4'), (6, 'IPv6')]), - ), - migrations.AlterField( - model_name='aggregate', - name='rir', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='aggregates', to='ipam.RIR', verbose_name='RIR'), - ), - migrations.AlterField( - model_name='ipaddress', - name='address', - field=ipam.fields.IPAddressField(help_text='IPv4 or IPv6 address (with mask)'), - ), - migrations.AlterField( - model_name='ipaddress', - name='family', - field=models.PositiveSmallIntegerField(choices=[(4, 'IPv4'), (6, 'IPv6')], editable=False), - ), - migrations.AlterField( - model_name='ipaddress', - name='nat_inside', - field=models.OneToOneField(blank=True, help_text='The IP for which this address is the "outside" IP', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='nat_outside', to='ipam.IPAddress', verbose_name='NAT (Inside)'), - ), - migrations.AlterField( - model_name='ipaddress', - name='status', - field=models.PositiveSmallIntegerField(choices=[(1, 'Active'), (2, 'Reserved'), (3, 'Deprecated'), (5, 'DHCP')], default=1, verbose_name='Status'), - ), - migrations.AlterField( - model_name='ipaddress', - name='vrf', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='ip_addresses', to='ipam.VRF', verbose_name='VRF'), - ), - migrations.AlterField( - model_name='prefix', - name='family', - field=models.PositiveSmallIntegerField(choices=[(4, 'IPv4'), (6, 'IPv6')], editable=False), - ), - migrations.AddField( - model_name='prefix', - name='is_pool', - field=models.BooleanField(default=False, help_text='All IP addresses within this prefix are considered usable', verbose_name='Is a pool'), - ), - migrations.AlterField( - model_name='prefix', - name='prefix', - field=ipam.fields.IPNetworkField(help_text='IPv4 or IPv6 network with mask'), - ), - migrations.AlterField( - model_name='prefix', - name='role', - field=models.ForeignKey(blank=True, help_text='The primary function of this prefix', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prefixes', to='ipam.Role'), - ), - migrations.AlterField( - model_name='prefix', - name='status', - field=models.PositiveSmallIntegerField(choices=[(0, 'Container'), (1, 'Active'), (2, 'Reserved'), (3, 'Deprecated')], default=1, help_text='Operational status of this prefix', verbose_name='Status'), - ), - migrations.AlterField( - model_name='prefix', - name='vlan', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='prefixes', to='ipam.VLAN', verbose_name='VLAN'), - ), - migrations.AlterField( - model_name='prefix', - name='vrf', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='prefixes', to='ipam.VRF', verbose_name='VRF'), - ), - migrations.AlterField( - model_name='rir', - name='is_private', - field=models.BooleanField(default=False, help_text='IP space managed by this RIR is considered private', verbose_name='Private'), - ), - migrations.AlterField( - model_name='vlan', - name='status', - field=models.PositiveSmallIntegerField(choices=[(1, 'Active'), (2, 'Reserved'), (3, 'Deprecated')], default=1, verbose_name='Status'), - ), - migrations.AlterField( - model_name='vlan', - name='vid', - field=models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)], verbose_name='ID'), - ), - migrations.AlterField( - model_name='vrf', - name='enforce_unique', - field=models.BooleanField(default=True, help_text='Prevent duplicate prefixes/IP addresses within this VRF', verbose_name='Enforce unique space'), - ), - migrations.AlterField( - model_name='vrf', - name='rd', - field=models.CharField(max_length=21, unique=True, verbose_name='Route distinguisher'), - ), - migrations.AddField( - model_name='ipaddress', - name='role', - field=models.PositiveSmallIntegerField(blank=True, choices=[(10, 'Loopback'), (20, 'Secondary'), (30, 'Anycast'), (40, 'VIP'), (41, 'VRRP'), (42, 'HSRP'), (43, 'GLBP')], help_text='The functional role of this IP', null=True, verbose_name='Role'), - ), - migrations.AlterField( - model_name='ipaddress', - name='status', - field=models.PositiveSmallIntegerField(choices=[(1, 'Active'), (2, 'Reserved'), (3, 'Deprecated'), (5, 'DHCP')], default=1, help_text='The operational status of this IP', verbose_name='Status'), - ), - migrations.CreateModel( - name='Service', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True)), - ('last_updated', models.DateTimeField(auto_now=True)), - ('name', models.CharField(max_length=30)), - ('protocol', models.PositiveSmallIntegerField(choices=[(6, 'TCP'), (17, 'UDP')])), - ('port', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(65535)], verbose_name='Port number')), - ('description', models.CharField(blank=True, max_length=100)), - ('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='services', to='dcim.Device', verbose_name='device')), - ('ipaddresses', models.ManyToManyField(blank=True, related_name='services', to='ipam.IPAddress', verbose_name='IP addresses')), - ], - options={ - 'ordering': ['device', 'protocol', 'port'], - 'unique_together': set(), - }, - ), - ] diff --git a/netbox/ipam/migrations/0019_virtualization_squashed_0020_ipaddress_add_role_carp.py b/netbox/ipam/migrations/0019_virtualization_squashed_0020_ipaddress_add_role_carp.py deleted file mode 100644 index c0b67464f..000000000 --- a/netbox/ipam/migrations/0019_virtualization_squashed_0020_ipaddress_add_role_carp.py +++ /dev/null @@ -1,34 +0,0 @@ -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('ipam', '0019_virtualization'), ('ipam', '0020_ipaddress_add_role_carp')] - - dependencies = [ - ('ipam', '0018_remove_service_uniqueness_constraint'), - ('virtualization', '0001_virtualization'), - ] - - operations = [ - migrations.AlterModelOptions( - name='service', - options={'ordering': ['protocol', 'port']}, - ), - migrations.AddField( - model_name='service', - name='virtual_machine', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='services', to='virtualization.VirtualMachine'), - ), - migrations.AlterField( - model_name='service', - name='device', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='services', to='dcim.Device', verbose_name='device'), - ), - migrations.AlterField( - model_name='ipaddress', - name='role', - field=models.PositiveSmallIntegerField(blank=True, choices=[(10, 'Loopback'), (20, 'Secondary'), (30, 'Anycast'), (40, 'VIP'), (41, 'VRRP'), (42, 'HSRP'), (43, 'GLBP'), (44, 'CARP')], help_text='The functional role of this IP', null=True, verbose_name='Role'), - ), - ] diff --git a/netbox/ipam/migrations/0021_vrf_ordering_squashed_0025_custom_tag_models.py b/netbox/ipam/migrations/0021_vrf_ordering_squashed_0025_custom_tag_models.py deleted file mode 100644 index f101f0dd0..000000000 --- a/netbox/ipam/migrations/0021_vrf_ordering_squashed_0025_custom_tag_models.py +++ /dev/null @@ -1,145 +0,0 @@ -import taggit.managers -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('ipam', '0021_vrf_ordering'), ('ipam', '0022_tags'), ('ipam', '0023_change_logging'), ('ipam', '0024_vrf_allow_null_rd'), ('ipam', '0025_custom_tag_models')] - - dependencies = [ - ('ipam', '0020_ipaddress_add_role_carp'), - ('taggit', '0002_auto_20150616_2121'), - ('extras', '0019_tag_taggeditem'), - ] - - operations = [ - migrations.AlterModelOptions( - name='vrf', - options={'ordering': ['name', 'rd'], 'verbose_name': 'VRF', 'verbose_name_plural': 'VRFs'}, - ), - migrations.AddField( - model_name='rir', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='rir', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='role', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='role', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='vlangroup', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='vlangroup', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='aggregate', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='aggregate', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='ipaddress', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='ipaddress', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='prefix', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='prefix', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='service', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='service', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='vlan', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='vlan', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='vrf', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='vrf', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='vrf', - name='rd', - field=models.CharField(blank=True, max_length=21, null=True, unique=True), - ), - migrations.AddField( - model_name='aggregate', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='ipaddress', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='prefix', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='service', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='vlan', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='vrf', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - ] diff --git a/netbox/ipam/migrations/0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description.py b/netbox/ipam/migrations/0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description.py deleted file mode 100644 index d5116039d..000000000 --- a/netbox/ipam/migrations/0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description.py +++ /dev/null @@ -1,140 +0,0 @@ -import django.core.validators -from django.db import migrations, models -import django.db.models.expressions - -PREFIX_STATUS_CHOICES = ( - (0, 'container'), - (1, 'active'), - (2, 'reserved'), - (3, 'deprecated'), -) - -IPADDRESS_STATUS_CHOICES = ( - (0, 'container'), - (1, 'active'), - (2, 'reserved'), - (3, 'deprecated'), -) - -IPADDRESS_ROLE_CHOICES = ( - (10, 'loopback'), - (20, 'secondary'), - (30, 'anycast'), - (40, 'vip'), - (41, 'vrrp'), - (42, 'hsrp'), - (43, 'glbp'), - (44, 'carp'), -) - -VLAN_STATUS_CHOICES = ( - (1, 'active'), - (2, 'reserved'), - (3, 'deprecated'), -) - -SERVICE_PROTOCOL_CHOICES = ( - (6, 'tcp'), - (17, 'udp'), -) - - -def prefix_status_to_slug(apps, schema_editor): - Prefix = apps.get_model('ipam', 'Prefix') - for id, slug in PREFIX_STATUS_CHOICES: - Prefix.objects.filter(status=str(id)).update(status=slug) - - -def ipaddress_status_to_slug(apps, schema_editor): - IPAddress = apps.get_model('ipam', 'IPAddress') - for id, slug in IPADDRESS_STATUS_CHOICES: - IPAddress.objects.filter(status=str(id)).update(status=slug) - - -def ipaddress_role_to_slug(apps, schema_editor): - IPAddress = apps.get_model('ipam', 'IPAddress') - for id, slug in IPADDRESS_ROLE_CHOICES: - IPAddress.objects.filter(role=str(id)).update(role=slug) - - -def vlan_status_to_slug(apps, schema_editor): - VLAN = apps.get_model('ipam', 'VLAN') - for id, slug in VLAN_STATUS_CHOICES: - VLAN.objects.filter(status=str(id)).update(status=slug) - - -def service_protocol_to_slug(apps, schema_editor): - Service = apps.get_model('ipam', 'Service') - for id, slug in SERVICE_PROTOCOL_CHOICES: - Service.objects.filter(protocol=str(id)).update(protocol=slug) - - -class Migration(migrations.Migration): - - replaces = [('ipam', '0026_prefix_ordering_vrf_nulls_first'), ('ipam', '0027_ipaddress_add_dns_name'), ('ipam', '0028_3569_prefix_fields'), ('ipam', '0029_3569_ipaddress_fields'), ('ipam', '0030_3569_vlan_fields'), ('ipam', '0031_3569_service_fields'), ('ipam', '0032_role_description')] - - dependencies = [ - ('ipam', '0025_custom_tag_models'), - ] - - operations = [ - migrations.AlterModelOptions( - name='prefix', - options={'ordering': [django.db.models.expressions.OrderBy(django.db.models.expressions.F('vrf'), nulls_first=True), 'family', 'prefix'], 'verbose_name_plural': 'prefixes'}, - ), - migrations.AddField( - model_name='ipaddress', - name='dns_name', - field=models.CharField(blank=True, max_length=255, validators=[django.core.validators.RegexValidator(code='invalid', message='Only alphanumeric characters, hyphens, periods, and underscores are allowed in DNS names', regex='^[0-9A-Za-z._-]+$')]), - ), - migrations.AlterField( - model_name='prefix', - name='status', - field=models.CharField(default='active', max_length=50), - ), - migrations.RunPython( - code=prefix_status_to_slug, - ), - migrations.AlterField( - model_name='ipaddress', - name='status', - field=models.CharField(default='active', max_length=50), - ), - migrations.RunPython( - code=ipaddress_status_to_slug, - ), - migrations.AlterField( - model_name='ipaddress', - name='role', - field=models.CharField(blank=True, default='', max_length=50), - ), - migrations.RunPython( - code=ipaddress_role_to_slug, - ), - migrations.AlterField( - model_name='ipaddress', - name='role', - field=models.CharField(blank=True, max_length=50), - ), - migrations.AlterField( - model_name='vlan', - name='status', - field=models.CharField(default='active', max_length=50), - ), - migrations.RunPython( - code=vlan_status_to_slug, - ), - migrations.AlterField( - model_name='service', - name='protocol', - field=models.CharField(max_length=50), - ), - migrations.RunPython( - code=service_protocol_to_slug, - ), - migrations.AddField( - model_name='role', - name='description', - field=models.CharField(blank=True, max_length=100), - ), - ] diff --git a/netbox/secrets/migrations/0001_initial_squashed_0006_custom_tag_models.py b/netbox/secrets/migrations/0001_initial_squashed_0006_custom_tag_models.py deleted file mode 100644 index 2a5f2b740..000000000 --- a/netbox/secrets/migrations/0001_initial_squashed_0006_custom_tag_models.py +++ /dev/null @@ -1,81 +0,0 @@ -import django.db.models.deletion -import taggit.managers -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('secrets', '0001_initial'), ('secrets', '0002_userkey_add_session_key'), ('secrets', '0003_unicode_literals'), ('secrets', '0004_tags'), ('secrets', '0005_change_logging'), ('secrets', '0006_custom_tag_models')] - - dependencies = [ - ('dcim', '0002_auto_20160622_1821'), - ('extras', '0019_tag_taggeditem'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('taggit', '0002_auto_20150616_2121'), - ('auth', '0007_alter_validators_add_error_messages'), - ] - - operations = [ - migrations.CreateModel( - name='SecretRole', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('groups', models.ManyToManyField(blank=True, related_name='secretroles', to='auth.Group')), - ('users', models.ManyToManyField(blank=True, related_name='secretroles', to=settings.AUTH_USER_MODEL)), - ('created', models.DateField(auto_now_add=True, null=True)), - ('last_updated', models.DateTimeField(auto_now=True, null=True)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='UserKey', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True)), - ('last_updated', models.DateTimeField(auto_now=True)), - ('public_key', models.TextField(verbose_name='RSA public key')), - ('master_key_cipher', models.BinaryField(blank=True, max_length=512, null=True)), - ('user', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='user_key', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['user__username'], - 'permissions': (('activate_userkey', 'Can activate user keys for decryption'),), - }, - ), - migrations.CreateModel( - name='SessionKey', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('cipher', models.BinaryField(max_length=512)), - ('hash', models.CharField(editable=False, max_length=128)), - ('created', models.DateTimeField(auto_now_add=True)), - ('userkey', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='session_key', to='secrets.UserKey')), - ], - options={ - 'ordering': ['userkey__user__username'], - }, - ), - migrations.CreateModel( - name='Secret', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True, null=True)), - ('last_updated', models.DateTimeField(auto_now=True, null=True)), - ('name', models.CharField(blank=True, max_length=100)), - ('ciphertext', models.BinaryField(max_length=65568)), - ('hash', models.CharField(editable=False, max_length=128)), - ('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='secrets', to='dcim.Device')), - ('role', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='secrets', to='secrets.SecretRole')), - ('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags')), - ], - options={ - 'ordering': ['device', 'role', 'name'], - 'unique_together': {('device', 'role', 'name')}, - }, - ), - ] diff --git a/netbox/tenancy/migrations/0001_initial_squashed_0005_change_logging.py b/netbox/tenancy/migrations/0001_initial_squashed_0005_change_logging.py deleted file mode 100644 index 664ea5d1b..000000000 --- a/netbox/tenancy/migrations/0001_initial_squashed_0005_change_logging.py +++ /dev/null @@ -1,45 +0,0 @@ -import django.db.models.deletion -import taggit.managers -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('tenancy', '0001_initial'), ('tenancy', '0002_tenant_group_optional'), ('tenancy', '0003_unicode_literals'), ('tenancy', '0004_tags'), ('tenancy', '0005_change_logging')] - - dependencies = [ - ('taggit', '0002_auto_20150616_2121'), - ] - - operations = [ - migrations.CreateModel( - name='TenantGroup', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), - ('slug', models.SlugField(unique=True)), - ('created', models.DateField(auto_now_add=True, null=True)), - ('last_updated', models.DateTimeField(auto_now=True, null=True)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.CreateModel( - name='Tenant', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateField(auto_now_add=True, null=True)), - ('last_updated', models.DateTimeField(auto_now=True, null=True)), - ('name', models.CharField(max_length=30, unique=True)), - ('slug', models.SlugField(unique=True)), - ('description', models.CharField(blank=True, help_text='Long-form name (optional)', max_length=100)), - ('comments', models.TextField(blank=True)), - ('group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tenants', to='tenancy.TenantGroup')), - ('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')), - ], - options={ - 'ordering': ['group', 'name'], - }, - ), - ] diff --git a/netbox/users/migrations/0001_api_tokens_squashed_0003_token_permissions.py b/netbox/users/migrations/0001_api_tokens_squashed_0003_token_permissions.py deleted file mode 100644 index 1053dcd7a..000000000 --- a/netbox/users/migrations/0001_api_tokens_squashed_0003_token_permissions.py +++ /dev/null @@ -1,35 +0,0 @@ -import django.core.validators -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('users', '0001_api_tokens'), ('users', '0002_unicode_literals'), ('users', '0003_token_permissions')] - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Token', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(auto_now_add=True)), - ('expires', models.DateTimeField(blank=True, null=True)), - ('key', models.CharField(max_length=40, unique=True, validators=[django.core.validators.MinLengthValidator(40)])), - ('write_enabled', models.BooleanField(default=True, help_text='Permit create/update/delete operations using this key')), - ('description', models.CharField(blank=True, max_length=100)), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tokens', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'default_permissions': [], - }, - ), - migrations.AlterModelOptions( - name='token', - options={}, - ), - ] diff --git a/netbox/users/migrations/0002_standardize_description.py b/netbox/users/migrations/0004_standardize_description.py similarity index 83% rename from netbox/users/migrations/0002_standardize_description.py rename to netbox/users/migrations/0004_standardize_description.py index 8916edcbd..b1f45666f 100644 --- a/netbox/users/migrations/0002_standardize_description.py +++ b/netbox/users/migrations/0004_standardize_description.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('users', '0001_api_tokens_squashed_0003_token_permissions'), + ('users', '0003_token_permissions'), ] operations = [ diff --git a/netbox/users/migrations/0004_userconfig.py b/netbox/users/migrations/0005_userconfig.py similarity index 94% rename from netbox/users/migrations/0004_userconfig.py rename to netbox/users/migrations/0005_userconfig.py index ba8438741..f8dc64fc3 100644 --- a/netbox/users/migrations/0004_userconfig.py +++ b/netbox/users/migrations/0005_userconfig.py @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('users', '0002_standardize_description'), + ('users', '0004_standardize_description'), ] operations = [ diff --git a/netbox/users/migrations/0005_create_userconfigs.py b/netbox/users/migrations/0006_create_userconfigs.py similarity index 94% rename from netbox/users/migrations/0005_create_userconfigs.py rename to netbox/users/migrations/0006_create_userconfigs.py index 39ce174f6..397bfdb24 100644 --- a/netbox/users/migrations/0005_create_userconfigs.py +++ b/netbox/users/migrations/0006_create_userconfigs.py @@ -16,7 +16,7 @@ def create_userconfigs(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('users', '0004_userconfig'), + ('users', '0005_userconfig'), ] operations = [ diff --git a/netbox/virtualization/migrations/0002_virtualmachine_add_status_squashed_0009_custom_tag_models.py b/netbox/virtualization/migrations/0002_virtualmachine_add_status_squashed_0009_custom_tag_models.py deleted file mode 100644 index 4a8fa4ea5..000000000 --- a/netbox/virtualization/migrations/0002_virtualmachine_add_status_squashed_0009_custom_tag_models.py +++ /dev/null @@ -1,89 +0,0 @@ -import django.contrib.postgres.fields.jsonb -import django.db.models.deletion -import taggit.managers -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [('virtualization', '0002_virtualmachine_add_status'), ('virtualization', '0003_cluster_add_site'), ('virtualization', '0004_virtualmachine_add_role'), ('virtualization', '0005_django2'), ('virtualization', '0006_tags'), ('virtualization', '0007_change_logging'), ('virtualization', '0008_virtualmachine_local_context_data'), ('virtualization', '0009_custom_tag_models')] - - dependencies = [ - ('dcim', '0044_virtualization'), - ('virtualization', '0001_virtualization'), - ('extras', '0019_tag_taggeditem'), - ('taggit', '0002_auto_20150616_2121'), - ] - - operations = [ - migrations.AddField( - model_name='virtualmachine', - name='status', - field=models.PositiveSmallIntegerField(choices=[[1, 'Active'], [0, 'Offline'], [3, 'Staged']], default=1, verbose_name='Status'), - ), - migrations.AddField( - model_name='cluster', - name='site', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='clusters', to='dcim.Site'), - ), - migrations.AddField( - model_name='virtualmachine', - name='role', - field=models.ForeignKey(blank=True, limit_choices_to={'vm_role': True}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='virtual_machines', to='dcim.DeviceRole'), - ), - migrations.AddField( - model_name='clustergroup', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='clustergroup', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='clustertype', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AddField( - model_name='clustertype', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='cluster', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='cluster', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name='virtualmachine', - name='created', - field=models.DateField(auto_now_add=True, null=True), - ), - migrations.AlterField( - model_name='virtualmachine', - name='last_updated', - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AddField( - model_name='virtualmachine', - name='local_context_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), - ), - migrations.AddField( - model_name='cluster', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - migrations.AddField( - model_name='virtualmachine', - name='tags', - field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='extras.TaggedItem', to='extras.Tag', verbose_name='Tags'), - ), - ] diff --git a/netbox/virtualization/migrations/0010_cluster_add_tenant_squashed_0012_vm_name_nonunique.py b/netbox/virtualization/migrations/0010_cluster_add_tenant_squashed_0012_vm_name_nonunique.py deleted file mode 100644 index eb7abd362..000000000 --- a/netbox/virtualization/migrations/0010_cluster_add_tenant_squashed_0012_vm_name_nonunique.py +++ /dev/null @@ -1,50 +0,0 @@ -from django.db import migrations, models -import django.db.models.deletion - -VIRTUALMACHINE_STATUS_CHOICES = ( - (0, 'offline'), - (1, 'active'), - (3, 'staged'), -) - - -def virtualmachine_status_to_slug(apps, schema_editor): - VirtualMachine = apps.get_model('virtualization', 'VirtualMachine') - for id, slug in VIRTUALMACHINE_STATUS_CHOICES: - VirtualMachine.objects.filter(status=str(id)).update(status=slug) - - -class Migration(migrations.Migration): - - replaces = [('virtualization', '0010_cluster_add_tenant'), ('virtualization', '0011_3569_virtualmachine_fields'), ('virtualization', '0012_vm_name_nonunique')] - - dependencies = [ - ('tenancy', '0001_initial'), - ('tenancy', '0006_custom_tag_models'), - ('virtualization', '0009_custom_tag_models'), - ] - - operations = [ - migrations.AddField( - model_name='cluster', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='clusters', to='tenancy.Tenant'), - ), - migrations.AlterField( - model_name='virtualmachine', - name='name', - field=models.CharField(max_length=64), - ), - migrations.AlterUniqueTogether( - name='virtualmachine', - unique_together={('cluster', 'tenant', 'name')}, - ), - migrations.AlterField( - model_name='virtualmachine', - name='status', - field=models.CharField(default='active', max_length=50), - ), - migrations.RunPython( - code=virtualmachine_status_to_slug, - ), - ] From f535ef4924091a3908fa8998ed152d03185731c6 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 09:44:41 -0400 Subject: [PATCH 30/74] Update development docs to remove squashing instructions --- docs/development/release-checklist.md | 4 - docs/development/squashing-migrations.md | 168 ------------------ mkdocs.yml | 1 - .../migrations/0092_fix_rack_outer_unit.py | 3 +- .../0034_fix_ipaddress_status_dhcp.py | 3 +- 5 files changed, 2 insertions(+), 177 deletions(-) delete mode 100644 docs/development/squashing-migrations.md diff --git a/docs/development/release-checklist.md b/docs/development/release-checklist.md index f5244bff5..8303cc44b 100644 --- a/docs/development/release-checklist.md +++ b/docs/development/release-checklist.md @@ -35,10 +35,6 @@ Update the following static libraries to their most recent stable release: * jQuery * jQuery UI -### Squash Schema Migrations - -Database schema migrations should be squashed for each new minor release. See the [squashing guide](squashing-migrations.md) for the detailed process. - ### Create a new Release Notes Page Create a file at `/docs/release-notes/X.Y.md` to establish the release notes for the new release. Add the file to the table of contents within `mkdocs.yml`. diff --git a/docs/development/squashing-migrations.md b/docs/development/squashing-migrations.md deleted file mode 100644 index bc0c0548f..000000000 --- a/docs/development/squashing-migrations.md +++ /dev/null @@ -1,168 +0,0 @@ -# Squashing Database Schema Migrations - -## What are Squashed Migrations? - -The Django framework on which NetBox is built utilizes [migration files](https://docs.djangoproject.com/en/stable/topics/migrations/) to keep track of changes to the PostgreSQL database schema. Each time a model is altered, the resulting schema change is captured in a migration file, which can then be applied to effect the new schema. - -As changes are made over time, more and more migration files are created. Although not necessarily problematic, it can be beneficial to merge and compress these files occasionally to reduce the total number of migrations that need to be applied upon installation of NetBox. This merging process is called _squashing_ in Django vernacular, and results in two parallel migration paths: individual and squashed. - -Below is an example showing both individual and squashed migration files within an app: - -| Individual | Squashed | -|------------|----------| -| 0001_initial | 0001_initial_squashed_0004_add_field | -| 0002_alter_field | . | -| 0003_remove_field | . | -| 0004_add_field | . | -| 0005_another_field | 0005_another_field | - -In the example above, a new installation can leverage the squashed migrations to apply only two migrations: - -* `0001_initial_squashed_0004_add_field` -* `0005_another_field` - -This is because the squash file contains all of the operations performed by files `0001` through `0004`. - -However, an existing installation that has already applied some of the individual migrations contained within the squash file must continue applying individual migrations. For instance, an installation which currently has up to `0002_alter_field` applied must apply the following migrations to become current: - -* `0003_remove_field` -* `0004_add_field` -* `0005_another_field` - -Squashed migrations are opportunistic: They are used only if applicable to the current environment. Django will fall back to using individual migrations if the squashed migrations do not agree with the current database schema at any point. - -## Squashing Migrations - -During every minor (i.e. 2.x) release, migrations should be squashed to help simplify the migration process for new installations. The process below describes how to squash migrations efficiently and with minimal room for error. - -### 1. Create a New Branch - -Create a new branch off of the `develop-2.x` branch. (Migrations should be squashed _only_ in preparation for a new minor release.) - -``` -git checkout -B squash-migrations -``` - -### 2. Delete Existing Squash Files - -Delete the most recent squash file within each NetBox app. This allows us to extend squash files where the opportunity exists. For example, we might be able to replace `0005_to_0008` with `0005_to_0011`. - -### 3. Generate the Current Migration Plan - -Use Django's `showmigrations` utility to display the order in which all migrations would be applied for a new installation. - -``` -manage.py showmigrations --plan -``` - -From the resulting output, delete all lines which reference an external migration. Any migrations imposed by Django itself on an external package are not relevant. - -### 4. Create Squash Files - -Begin iterating through the migration plan, looking for successive sets of migrations within an app. These are candidates for squashing. For example: - -``` -[X] extras.0014_configcontexts -[X] extras.0015_remove_useraction -[X] extras.0016_exporttemplate_add_cable -[X] extras.0017_exporttemplate_mime_type_length -[ ] extras.0018_exporttemplate_add_jinja2 -[ ] extras.0019_tag_taggeditem -[X] dcim.0062_interface_mtu -[X] dcim.0063_device_local_context_data -[X] dcim.0064_remove_platform_rpc_client -[ ] dcim.0065_front_rear_ports -[X] circuits.0001_initial_squashed_0010_circuit_status -[ ] dcim.0066_cables -... -``` - -Migrations `0014` through `0019` in `extras` can be squashed, as can migrations `0062` through `0065` in `dcim`. Migration `0066` cannot be included in the same squash file, because the `circuits` migration must be applied before it. (Note that whether or not each migration is currently applied to the database does not matter.) - -Squash files are created using Django's `squashmigrations` utility: - -``` -manage.py squashmigrations -``` - -For example, our first step in the example would be to run `manage.py squashmigrations extras 0014 0019`. - -!!! note - Specifying a migration file's numeric index is enough to uniquely identify it within an app. There is no need to specify the full filename. - -This will create a new squash file within the app's `migrations` directory, named as a concatenation of its beginning and ending migration. Some manual editing is necessary for each new squash file for housekeeping purposes: - -* Remove the "automatically generated" comment at top (to indicate that a human has reviewed the file). -* Reorder `import` statements as necessary per PEP8. -* It may be necessary to copy over custom functions from the original migration files (this will be indicated by a comment near the top of the squash file). It is safe to remove any functions that exist solely to accomodate reverse migrations (which we no longer support). - -Repeat this process for each candidate set of migrations until you reach the end of the migration plan. - -### 5. Check for Missing Migrations - -If everything went well, at this point we should have a completed squashed path. Perform a dry run to check for any missing migrations: - -``` -manage.py migrate --dry-run -``` - -### 5. Run Migrations - -Next, we'll apply the entire migration path to an empty database. Begin by dropping and creating your development database. - -!!! warning - Obviously, first back up any data you don't want to lose. - -``` -sudo -u postgres psql -c 'drop database netbox' -sudo -u postgres psql -c 'create database netbox' -``` - -Apply the migrations with the `migrate` management command. It is not necessary to specify a particular migration path; Django will detect and use the squashed migrations automatically. You can verify the exact migrations being applied by enabling verboes output with `-v 2`. - -``` -manage.py migrate -v 2 -``` - -### 6. Commit the New Migrations - -If everything is successful to this point, commit your changes to the `squash-migrations` branch. - -### 7. Validate Resulting Schema - -To ensure our new squashed migrations do not result in a deviation from the original schema, we'll compare the two. With the new migration file safely commit, check out the `develop-2.x` branch, which still contains only the individual migrations. - -``` -git checkout develop-2.x -``` - -Temporarily install the [django-extensions](https://django-extensions.readthedocs.io/) package, which provides the `sqldiff utility`: - -``` -pip install django-extensions -``` - -Also add `django_extensions` to `INSTALLED_APPS` in `netbox/netbox/settings.py`. - -At this point, our database schema has been defined by using the squashed migrations. We can run `sqldiff` to see if it differs any from what the current (non-squashed) migrations would generate. `sqldiff` accepts a list of apps against which to run: - -``` -manage.py sqldiff circuits dcim extras ipam secrets tenancy users virtualization -``` - -It is safe to ignore errors indicating an "unknown database type" for the following fields: - -* `dcim_interface.mac_address` -* `ipam_aggregate.prefix` -* `ipam_prefix.prefix` - -It is also safe to ignore the message "Table missing: extras_script". - -Resolve any differences by correcting migration files in the `squash-migrations` branch. - -!!! warning - Don't forget to remove `django_extension` from `INSTALLED_APPS` before committing your changes. - -### 8. Merge the Squashed Migrations - -Once all squashed migrations have been validated and all tests run successfully, merge the `squash-migrations` branch into `develop-2.x`. This completes the squashing process. diff --git a/mkdocs.yml b/mkdocs.yml index bed73eb9c..b8633ea8f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -74,7 +74,6 @@ nav: - Application Registry: 'development/application-registry.md' - User Preferences: 'development/user-preferences.md' - Release Checklist: 'development/release-checklist.md' - - Squashing Migrations: 'development/squashing-migrations.md' - Release Notes: - Version 2.8: 'release-notes/version-2.8.md' - Version 2.7: 'release-notes/version-2.7.md' diff --git a/netbox/dcim/migrations/0092_fix_rack_outer_unit.py b/netbox/dcim/migrations/0092_fix_rack_outer_unit.py index 2a8cbf4e5..3d63f1cb3 100644 --- a/netbox/dcim/migrations/0092_fix_rack_outer_unit.py +++ b/netbox/dcim/migrations/0092_fix_rack_outer_unit.py @@ -19,8 +19,7 @@ class Migration(migrations.Migration): ] operations = [ - # Fixes a missed field migration from #3569; see bug #4056. The original migration has also been fixed, - # so this can be omitted when squashing in the future. + # Fixes a missed field migration from #3569; see bug #4056. The original migration has also been fixed. migrations.RunPython( code=rack_outer_unit_to_slug ), diff --git a/netbox/ipam/migrations/0034_fix_ipaddress_status_dhcp.py b/netbox/ipam/migrations/0034_fix_ipaddress_status_dhcp.py index 9e496153e..8d068df35 100644 --- a/netbox/ipam/migrations/0034_fix_ipaddress_status_dhcp.py +++ b/netbox/ipam/migrations/0034_fix_ipaddress_status_dhcp.py @@ -13,8 +13,7 @@ class Migration(migrations.Migration): ] operations = [ - # Fixes a missed integer substitution from #3569; see bug #4027. The original migration has also been fixed, - # so this can be omitted when squashing in the future. + # Fixes a missed integer substitution from #3569; see bug #4027. The original migration has also been fixed. migrations.RunPython( code=ipaddress_status_dhcp_to_slug ), From f98a236a5bf0f08597ff08ce4fbbff94e97ca1e7 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 09:46:24 -0400 Subject: [PATCH 31/74] Changelog for #4545 --- docs/release-notes/version-2.8.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index 8f95141ca..b6501d1cb 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -11,6 +11,7 @@ ### Bug Fixes * [#4527](https://github.com/netbox-community/netbox/issues/4527) - Fix assignment of certain tags to config contexts +* [#4545](https://github.com/netbox-community/netbox/issues/4545) - Removed all squashed schema migrations to allow direct upgrades from very old releases * [#4549](https://github.com/netbox-community/netbox/issues/4549) - Fix encoding unicode webhook body data --- From 88687608e7b1a07e61e68a28134998d2dd759150 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 10:17:52 -0400 Subject: [PATCH 32/74] Always include the 'actions' column, if present --- netbox/utilities/tables.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 57adb4256..d59e4b647 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -28,6 +28,7 @@ class BaseTable(tables.Table): # Apply custom column ordering if columns is not None: pk = self.base_columns.pop('pk', None) + actions = self.base_columns.pop('actions', None) for name, column in self.base_columns.items(): if name in columns: @@ -36,10 +37,13 @@ class BaseTable(tables.Table): self.columns.hide(name) self.sequence = columns - # Always include PK column, if defined on the table + # Always include PK and actions column, if defined on the table if pk: self.base_columns['pk'] = pk self.sequence.insert(0, 'pk') + if actions: + self.base_columns['actions'] = actions + self.sequence.append('actions') @property def configurable_columns(self): From e3cfc9ad807bf7e634756e04ff2ab2ef80a7982c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 10:58:08 -0400 Subject: [PATCH 33/74] #492: Extend DCIM tables --- netbox/dcim/tables.py | 162 ++++++++++++++++++++++++++++++++--------- netbox/dcim/views.py | 2 +- netbox/netbox/views.py | 4 +- 3 files changed, 129 insertions(+), 39 deletions(-) diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 75b319ff5..2e310530c 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -723,8 +723,10 @@ class DeviceRoleTable(BaseTable): orderable=False, verbose_name='VMs' ) - color = tables.TemplateColumn(COLOR_LABEL, verbose_name='Label') - slug = tables.Column(verbose_name='Slug') + color = tables.TemplateColumn( + template_code=COLOR_LABEL, + verbose_name='Label' + ) actions = tables.TemplateColumn( template_code=DEVICEROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -734,6 +736,7 @@ class DeviceRoleTable(BaseTable): class Meta(BaseTable.Meta): model = DeviceRole fields = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'actions') + default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'actions') # @@ -763,7 +766,11 @@ class PlatformTable(BaseTable): class Meta(BaseTable.Meta): model = Platform fields = ( - 'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'description', 'actions', + 'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'napalm_driver', 'napalm_args', + 'description', 'actions', + ) + default_columns = ( + 'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description', 'actions', ) @@ -777,40 +784,96 @@ class DeviceTable(BaseTable): order_by=('_name',), template_code=DEVICE_LINK ) - status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status') - tenant = tables.TemplateColumn(template_code=COL_TENANT) - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - rack = tables.LinkColumn('dcim:rack', args=[Accessor('rack.pk')]) - device_role = tables.TemplateColumn(DEVICE_ROLE, verbose_name='Role') + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + rack = tables.LinkColumn( + viewname='dcim:rack', + args=[Accessor('rack.pk')] + ) + device_role = tables.TemplateColumn( + template_code=DEVICE_ROLE, + verbose_name='Role' + ) device_type = tables.LinkColumn( - 'dcim:devicetype', args=[Accessor('device_type.pk')], verbose_name='Type', + viewname='dcim:devicetype', + args=[Accessor('device_type.pk')], + verbose_name='Type', text=lambda record: record.device_type.display_name ) + primary_ip = tables.TemplateColumn( + template_code=DEVICE_PRIMARY_IP, + orderable=False, + verbose_name='IP Address' + ) + primary_ip4 = tables.LinkColumn( + viewname='ipam:ipaddress', + args=[Accessor('primary_ip4.pk')], + verbose_name='IPv4 Address' + ) + primary_ip6 = tables.LinkColumn( + viewname='ipam:ipaddress', + args=[Accessor('primary_ip6.pk')], + verbose_name='IPv6 Address' + ) + cluster = tables.LinkColumn( + viewname='virtualization:cluster', + args=[Accessor('cluster.pk')] + ) + virtual_chassis = tables.LinkColumn( + viewname='dcim:virtualchassis', + args=[Accessor('virtual_chassis.pk')] + ) + vc_position = tables.Column( + verbose_name='VC Position' + ) + vc_priority = tables.Column( + verbose_name='VC Priority' + ) class Meta(BaseTable.Meta): model = Device - fields = ('pk', 'name', 'status', 'tenant', 'site', 'rack', 'device_role', 'device_type') - - -class DeviceDetailTable(DeviceTable): - primary_ip = tables.TemplateColumn( - orderable=False, verbose_name='IP Address', template_code=DEVICE_PRIMARY_IP - ) - - class Meta(DeviceTable.Meta): - model = Device - fields = ('pk', 'name', 'status', 'tenant', 'site', 'rack', 'device_role', 'device_type', 'primary_ip') + fields = ( + 'pk', 'name', 'status', 'tenant', 'device_role', 'device_type', 'platform', 'serial', 'asset_tag', 'site', + 'rack', 'position', 'face', 'primary_ip', 'primary_ip4', 'primary_ip6', 'cluster', 'virtual_chassis', + 'vc_position', 'vc_priority', + ) + default_columns = ( + 'pk', 'name', 'status', 'tenant', 'site', 'rack', 'device_role', 'device_type', 'primary_ip', + ) class DeviceImportTable(BaseTable): - name = tables.TemplateColumn(template_code=DEVICE_LINK, verbose_name='Name') - status = tables.TemplateColumn(template_code=STATUS_LABEL, verbose_name='Status') - tenant = tables.TemplateColumn(template_code=COL_TENANT) - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')], verbose_name='Site') - rack = tables.LinkColumn('dcim:rack', args=[Accessor('rack.pk')], verbose_name='Rack') - position = tables.Column(verbose_name='Position') - device_role = tables.Column(verbose_name='Role') - device_type = tables.Column(verbose_name='Type') + name = tables.TemplateColumn( + template_code=DEVICE_LINK + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + rack = tables.LinkColumn( + viewname='dcim:rack', + args=[Accessor('rack.pk')] + ) + device_role = tables.Column( + verbose_name='Role' + ) + device_type = tables.Column( + verbose_name='Type' + ) class Meta(BaseTable.Meta): model = Device @@ -986,23 +1049,23 @@ class CableTable(BaseTable): template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_a'), orderable=False, - verbose_name='Termination A' + verbose_name='Side A' ) termination_a = tables.LinkColumn( accessor=Accessor('termination_a'), orderable=False, - verbose_name='' + verbose_name='Termination A' ) termination_b_parent = tables.TemplateColumn( template_code=CABLE_TERMINATION_PARENT, accessor=Accessor('termination_b'), orderable=False, - verbose_name='Termination B' + verbose_name='Side B' ) termination_b = tables.LinkColumn( accessor=Accessor('termination_b'), orderable=False, - verbose_name='' + verbose_name='Termination B' ) status = tables.TemplateColumn( template_code=STATUS_LABEL @@ -1019,6 +1082,10 @@ class CableTable(BaseTable): 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', 'status', 'type', 'color', 'length', ) + default_columns = ( + 'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b', + 'status', 'type', + ) # @@ -1120,12 +1187,21 @@ class InterfaceConnectionTable(BaseTable): class InventoryItemTable(BaseTable): pk = ToggleColumn() - device = tables.LinkColumn('dcim:device_inventory', args=[Accessor('device.pk')]) - manufacturer = tables.Column(accessor=Accessor('manufacturer.name'), verbose_name='Manufacturer') + device = tables.LinkColumn( + viewname='dcim:device_inventory', + args=[Accessor('device.pk')] + ) + manufacturer = tables.Column( + accessor=Accessor('manufacturer.name') + ) + discovered = BooleanColumn() class Meta(BaseTable.Meta): model = InventoryItem - fields = ('pk', 'device', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description') + fields = ( + 'pk', 'device', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'description', 'discovered' + ) + default_columns = ('pk', 'device', 'name', 'manufacturer', 'part_id', 'serial', 'asset_tag') # @@ -1145,6 +1221,7 @@ class VirtualChassisTable(BaseTable): class Meta(BaseTable.Meta): model = VirtualChassis fields = ('pk', 'name', 'domain', 'member_count') + default_columns = ('pk', 'name', 'domain', 'member_count') # @@ -1166,6 +1243,7 @@ class PowerPanelTable(BaseTable): class Meta(BaseTable.Meta): model = PowerPanel fields = ('pk', 'name', 'site', 'rack_group', 'powerfeed_count') + default_columns = ('pk', 'name', 'site', 'rack_group', 'powerfeed_count') # @@ -1189,7 +1267,19 @@ class PowerFeedTable(BaseTable): type = tables.TemplateColumn( template_code=TYPE_LABEL ) + max_utilization = tables.TemplateColumn( + template_code="{{ value }}%" + ) + available_power = tables.Column( + verbose_name='Available power (VA)' + ) class Meta(BaseTable.Meta): model = PowerFeed - fields = ('pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase') + fields = ( + 'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', + 'max_utilization', 'available_power', + ) + default_columns = ( + 'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', + ) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 66b59add4..ce3a3d068 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1095,7 +1095,7 @@ class DeviceListView(PermissionRequiredMixin, ObjectListView): ) filterset = filters.DeviceFilterSet filterset_form = forms.DeviceFilterForm - table = tables.DeviceDetailTable + table = tables.DeviceTable template_name = 'dcim/device_list.html' diff --git a/netbox/netbox/views.py b/netbox/netbox/views.py index 98272a50a..37a516409 100644 --- a/netbox/netbox/views.py +++ b/netbox/netbox/views.py @@ -20,7 +20,7 @@ from dcim.models import ( Cable, ConsolePort, Device, DeviceType, Interface, PowerPanel, PowerFeed, PowerPort, Rack, RackGroup, Site, VirtualChassis ) from dcim.tables import ( - CableTable, DeviceDetailTable, DeviceTypeTable, PowerFeedTable, RackTable, RackGroupTable, SiteTable, + CableTable, DeviceTable, DeviceTypeTable, PowerFeedTable, RackTable, RackGroupTable, SiteTable, VirtualChassisTable, ) from extras.models import ObjectChange, ReportResult @@ -93,7 +93,7 @@ SEARCH_TYPES = OrderedDict(( 'device_type__manufacturer', 'device_role', 'tenant', 'site', 'rack', 'primary_ip4', 'primary_ip6', ), 'filterset': DeviceFilterSet, - 'table': DeviceDetailTable, + 'table': DeviceTable, 'url': 'dcim:device_list', }), ('virtualchassis', { From 7ad27a2b652db4c820a4b84924e3ee8a5822f62a Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 11:03:49 -0400 Subject: [PATCH 34/74] #492: Extend extras tables --- netbox/extras/tables.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/extras/tables.py b/netbox/extras/tables.py index b145824c6..7a78d4b19 100644 --- a/netbox/extras/tables.py +++ b/netbox/extras/tables.py @@ -104,7 +104,11 @@ class ConfigContextTable(BaseTable): class Meta(BaseTable.Meta): model = ConfigContext - fields = ('pk', 'name', 'weight', 'is_active', 'description') + fields = ( + 'pk', 'name', 'weight', 'is_active', 'description', 'regions', 'sites', 'roles', 'platforms', + 'cluster_groups', 'clusters', 'tenant_groups', 'tenants', + ) + default_columns = ('pk', 'name', 'weight', 'is_active', 'description') class ObjectChangeTable(BaseTable): From 6e9e6af2f08cc7f35a8c0a4c8f1571ee7480c8c7 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 11:29:30 -0400 Subject: [PATCH 35/74] #492: Extend IPAM tables --- netbox/ipam/tables.py | 283 ++++++++++++++++++++++++++++++++---------- 1 file changed, 220 insertions(+), 63 deletions(-) diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 19735b81c..56729f9db 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -190,12 +190,20 @@ TENANT_LINK = """ class VRFTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - rd = tables.Column(verbose_name='RD') - tenant = tables.TemplateColumn(template_code=COL_TENANT) + rd = tables.Column( + verbose_name='RD' + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + enforce_unique = BooleanColumn( + verbose_name='Unique' + ) class Meta(BaseTable.Meta): model = VRF - fields = ('pk', 'name', 'rd', 'tenant', 'description') + fields = ('pk', 'name', 'rd', 'tenant', 'enforce_unique', 'description') + default_columns = ('pk', 'name', 'rd', 'tenant', 'description') # @@ -204,14 +212,23 @@ class VRFTable(BaseTable): class RIRTable(BaseTable): pk = ToggleColumn() - name = tables.LinkColumn(verbose_name='Name') - is_private = BooleanColumn(verbose_name='Private') - aggregate_count = tables.Column(verbose_name='Aggregates') - actions = tables.TemplateColumn(template_code=RIR_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name='') + name = tables.LinkColumn() + is_private = BooleanColumn( + verbose_name='Private' + ) + aggregate_count = tables.Column( + verbose_name='Aggregates' + ) + actions = tables.TemplateColumn( + template_code=RIR_ACTIONS, + attrs={'td': {'class': 'text-right noprint'}}, + verbose_name='' + ) class Meta(BaseTable.Meta): model = RIR - fields = ('pk', 'name', 'is_private', 'aggregate_count', 'description', 'actions') + fields = ('pk', 'name', 'slug', 'is_private', 'aggregate_count', 'description', 'actions') + default_columns = ('pk', 'name', 'is_private', 'aggregate_count', 'description', 'actions') class RIRDetailTable(RIRTable): @@ -247,6 +264,10 @@ class RIRDetailTable(RIRTable): class Meta(RIRTable.Meta): fields = ( + 'pk', 'name', 'slug', 'is_private', 'aggregate_count', 'stats_total', 'stats_active', 'stats_reserved', + 'stats_deprecated', 'stats_available', 'utilization', 'actions', + ) + default_columns = ( 'pk', 'name', 'is_private', 'aggregate_count', 'stats_total', 'stats_active', 'stats_reserved', 'stats_deprecated', 'stats_available', 'utilization', 'actions', ) @@ -258,8 +279,13 @@ class RIRDetailTable(RIRTable): class AggregateTable(BaseTable): pk = ToggleColumn() - prefix = tables.LinkColumn(verbose_name='Aggregate') - date_added = tables.DateColumn(format="Y-m-d", verbose_name='Added') + prefix = tables.LinkColumn( + verbose_name='Aggregate' + ) + date_added = tables.DateColumn( + format="Y-m-d", + verbose_name='Added' + ) class Meta(BaseTable.Meta): model = Aggregate @@ -267,8 +293,13 @@ class AggregateTable(BaseTable): class AggregateDetailTable(AggregateTable): - child_count = tables.Column(verbose_name='Prefixes') - utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False, verbose_name='Utilization') + child_count = tables.Column( + verbose_name='Prefixes' + ) + utilization = tables.TemplateColumn( + template_code=UTILIZATION_GRAPH, + orderable=False + ) class Meta(AggregateTable.Meta): fields = ('pk', 'prefix', 'rir', 'child_count', 'utilization', 'date_added', 'description') @@ -300,7 +331,8 @@ class RoleTable(BaseTable): class Meta(BaseTable.Meta): model = Role - fields = ('pk', 'name', 'prefix_count', 'vlan_count', 'description', 'slug', 'weight', 'actions') + fields = ('pk', 'name', 'slug', 'prefix_count', 'vlan_count', 'description', 'weight', 'actions') + default_columns = ('pk', 'name', 'prefix_count', 'vlan_count', 'description', 'actions') # @@ -309,28 +341,61 @@ class RoleTable(BaseTable): class PrefixTable(BaseTable): pk = ToggleColumn() - prefix = tables.TemplateColumn(PREFIX_LINK, attrs={'th': {'style': 'padding-left: 17px'}}) - status = tables.TemplateColumn(STATUS_LABEL) - vrf = tables.TemplateColumn(VRF_LINK, verbose_name='VRF') - tenant = tables.TemplateColumn(template_code=TENANT_LINK) - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - vlan = tables.LinkColumn('ipam:vlan', args=[Accessor('vlan.pk')], verbose_name='VLAN') - role = tables.TemplateColumn(PREFIX_ROLE_LINK) + prefix = tables.TemplateColumn( + template_code=PREFIX_LINK, + attrs={'th': {'style': 'padding-left: 17px'}} + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + vrf = tables.TemplateColumn( + template_code=VRF_LINK, + verbose_name='VRF' + ) + tenant = tables.TemplateColumn( + template_code=TENANT_LINK + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + vlan = tables.LinkColumn( + viewname='ipam:vlan', + args=[Accessor('vlan.pk')], + verbose_name='VLAN' + ) + role = tables.TemplateColumn( + template_code=PREFIX_ROLE_LINK + ) + is_pool = BooleanColumn( + verbose_name='Pool' + ) class Meta(BaseTable.Meta): model = Prefix - fields = ('pk', 'prefix', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'description') + fields = ('pk', 'prefix', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'is_pool', 'description') + default_columns = ('pk', 'prefix', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'description') row_attrs = { 'class': lambda record: 'success' if not record.pk else '', } class PrefixDetailTable(PrefixTable): - utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False) - tenant = tables.TemplateColumn(template_code=COL_TENANT) + utilization = tables.TemplateColumn( + template_code=UTILIZATION_GRAPH, + orderable=False + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) class Meta(PrefixTable.Meta): - fields = ('pk', 'prefix', 'status', 'vrf', 'utilization', 'tenant', 'site', 'vlan', 'role', 'description') + fields = ( + 'pk', 'prefix', 'status', 'vrf', 'utilization', 'tenant', 'site', 'vlan', 'role', 'is_pool', 'description', + ) + default_columns = ( + 'pk', 'prefix', 'status', 'vrf', 'utilization', 'tenant', 'site', 'vlan', 'role', 'description', + ) # @@ -339,12 +404,27 @@ class PrefixDetailTable(PrefixTable): class IPAddressTable(BaseTable): pk = ToggleColumn() - address = tables.TemplateColumn(IPADDRESS_LINK, verbose_name='IP Address') - vrf = tables.TemplateColumn(VRF_LINK, verbose_name='VRF') - status = tables.TemplateColumn(STATUS_LABEL) - tenant = tables.TemplateColumn(template_code=TENANT_LINK) - parent = tables.TemplateColumn(IPADDRESS_PARENT, orderable=False) - interface = tables.Column(orderable=False) + address = tables.TemplateColumn( + template_code=IPADDRESS_LINK, + verbose_name='IP Address' + ) + vrf = tables.TemplateColumn( + template_code=VRF_LINK, + verbose_name='VRF' + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + tenant = tables.TemplateColumn( + template_code=TENANT_LINK + ) + parent = tables.TemplateColumn( + template_code=IPADDRESS_PARENT, + orderable=False + ) + interface = tables.Column( + orderable=False + ) class Meta(BaseTable.Meta): model = IPAddress @@ -358,22 +438,40 @@ class IPAddressTable(BaseTable): class IPAddressDetailTable(IPAddressTable): nat_inside = tables.LinkColumn( - 'ipam:ipaddress', args=[Accessor('nat_inside.pk')], orderable=False, verbose_name='NAT (Inside)' + viewname='ipam:ipaddress', + args=[Accessor('nat_inside.pk')], + orderable=False, + verbose_name='NAT (Inside)' + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT ) - tenant = tables.TemplateColumn(template_code=COL_TENANT) class Meta(IPAddressTable.Meta): fields = ( 'pk', 'address', 'vrf', 'status', 'role', 'tenant', 'nat_inside', 'parent', 'interface', 'dns_name', 'description', ) + default_columns = ( + 'pk', 'address', 'vrf', 'status', 'role', 'tenant', 'parent', 'interface', 'dns_name', 'description', + ) class IPAddressAssignTable(BaseTable): - address = tables.TemplateColumn(IPADDRESS_ASSIGN_LINK, verbose_name='IP Address') - status = tables.TemplateColumn(STATUS_LABEL) - parent = tables.TemplateColumn(IPADDRESS_PARENT, orderable=False) - interface = tables.Column(orderable=False) + address = tables.TemplateColumn( + template_code=IPADDRESS_ASSIGN_LINK, + verbose_name='IP Address' + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + parent = tables.TemplateColumn( + template_code=IPADDRESS_PARENT, + orderable=False + ) + interface = tables.Column( + orderable=False + ) class Meta(BaseTable.Meta): model = IPAddress @@ -385,10 +483,19 @@ class InterfaceIPAddressTable(BaseTable): """ List IP addresses assigned to a specific Interface. """ - address = tables.LinkColumn(verbose_name='IP Address') - vrf = tables.TemplateColumn(VRF_LINK, verbose_name='VRF') - status = tables.TemplateColumn(STATUS_LABEL) - tenant = tables.TemplateColumn(template_code=TENANT_LINK) + address = tables.LinkColumn( + verbose_name='IP Address' + ) + vrf = tables.TemplateColumn( + template_code=VRF_LINK, + verbose_name='VRF' + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + tenant = tables.TemplateColumn( + template_code=TENANT_LINK + ) class Meta(BaseTable.Meta): model = IPAddress @@ -401,16 +508,24 @@ class InterfaceIPAddressTable(BaseTable): class VLANGroupTable(BaseTable): pk = ToggleColumn() - name = tables.LinkColumn(verbose_name='Name') - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')], verbose_name='Site') - vlan_count = tables.Column(verbose_name='VLANs') - slug = tables.Column(verbose_name='Slug') - actions = tables.TemplateColumn(template_code=VLANGROUP_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, - verbose_name='') + name = tables.LinkColumn() + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + vlan_count = tables.Column( + verbose_name='VLANs' + ) + actions = tables.TemplateColumn( + template_code=VLANGROUP_ACTIONS, + attrs={'td': {'class': 'text-right noprint'}}, + verbose_name='' + ) class Meta(BaseTable.Meta): model = VLANGroup fields = ('pk', 'name', 'site', 'vlan_count', 'slug', 'description', 'actions') + default_columns = ('pk', 'name', 'site', 'vlan_count', 'description', 'actions') # @@ -419,12 +534,27 @@ class VLANGroupTable(BaseTable): class VLANTable(BaseTable): pk = ToggleColumn() - vid = tables.TemplateColumn(VLAN_LINK, verbose_name='ID') - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - group = tables.LinkColumn('ipam:vlangroup_vlans', args=[Accessor('group.pk')], verbose_name='Group') - tenant = tables.TemplateColumn(template_code=COL_TENANT) - status = tables.TemplateColumn(STATUS_LABEL) - role = tables.TemplateColumn(VLAN_ROLE_LINK) + vid = tables.TemplateColumn( + template_code=VLAN_LINK, + verbose_name='ID' + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + group = tables.LinkColumn( + viewname='ipam:vlangroup_vlans', + args=[Accessor('group.pk')] + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + role = tables.TemplateColumn( + template_code=VLAN_ROLE_LINK + ) class Meta(BaseTable.Meta): model = VLAN @@ -435,16 +565,26 @@ class VLANTable(BaseTable): class VLANDetailTable(VLANTable): - prefixes = tables.TemplateColumn(VLAN_PREFIXES, orderable=False, verbose_name='Prefixes') - tenant = tables.TemplateColumn(template_code=COL_TENANT) + prefixes = tables.TemplateColumn( + template_code=VLAN_PREFIXES, + orderable=False, + verbose_name='Prefixes' + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) class Meta(VLANTable.Meta): fields = ('pk', 'vid', 'site', 'group', 'name', 'prefixes', 'tenant', 'status', 'role', 'description') class VLANMemberTable(BaseTable): - parent = tables.LinkColumn(order_by=['device', 'virtual_machine']) - name = tables.LinkColumn(verbose_name='Interface') + parent = tables.LinkColumn( + order_by=['device', 'virtual_machine'] + ) + name = tables.LinkColumn( + verbose_name='Interface' + ) untagged = tables.TemplateColumn( template_code=VLAN_MEMBER_UNTAGGED, orderable=False @@ -464,13 +604,29 @@ class InterfaceVLANTable(BaseTable): """ List VLANs assigned to a specific Interface. """ - vid = tables.LinkColumn('ipam:vlan', args=[Accessor('pk')], verbose_name='ID') + vid = tables.LinkColumn( + viewname='ipam:vlan', + args=[Accessor('pk')], + verbose_name='ID' + ) tagged = BooleanColumn() - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - group = tables.Column(accessor=Accessor('group.name'), verbose_name='Group') - tenant = tables.TemplateColumn(template_code=COL_TENANT) - status = tables.TemplateColumn(STATUS_LABEL) - role = tables.TemplateColumn(VLAN_ROLE_LINK) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + group = tables.Column( + accessor=Accessor('group.name'), + verbose_name='Group' + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) + role = tables.TemplateColumn( + template_code=VLAN_ROLE_LINK + ) class Meta(BaseTable.Meta): model = VLAN @@ -494,4 +650,5 @@ class ServiceTable(BaseTable): class Meta(BaseTable.Meta): model = Service - fields = ('pk', 'name', 'parent', 'protocol', 'port', 'description') + fields = ('pk', 'name', 'parent', 'protocol', 'port', 'ipaddresses', 'description') + default_columns = ('pk', 'name', 'parent', 'protocol', 'port', 'description') From cd0ee4cd69378ca6d796ea4d8f10e62b68380a85 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 11:32:53 -0400 Subject: [PATCH 36/74] #492: Extend secrets tables --- netbox/secrets/tables.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/netbox/secrets/tables.py b/netbox/secrets/tables.py index 1e8a4e669..11646f5de 100644 --- a/netbox/secrets/tables.py +++ b/netbox/secrets/tables.py @@ -20,14 +20,19 @@ SECRETROLE_ACTIONS = """ class SecretRoleTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - secret_count = tables.Column(verbose_name='Secrets') + secret_count = tables.Column( + verbose_name='Secrets' + ) actions = tables.TemplateColumn( - template_code=SECRETROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name='' + template_code=SECRETROLE_ACTIONS, + attrs={'td': {'class': 'text-right noprint'}}, + verbose_name='' ) class Meta(BaseTable.Meta): model = SecretRole - fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'actions') + fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'users', 'groups', 'actions') + default_columns = ('pk', 'name', 'secret_count', 'description', 'actions') # @@ -40,4 +45,5 @@ class SecretTable(BaseTable): class Meta(BaseTable.Meta): model = Secret - fields = ('pk', 'device', 'role', 'name', 'last_updated') + fields = ('pk', 'device', 'role', 'name', 'last_updated', 'hash') + default_columns = ('pk', 'device', 'role', 'name', 'last_updated') From 33c44c2dd952b5771d357d3c056e75bfb2455563 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 11:34:51 -0400 Subject: [PATCH 37/74] #492: Extend tenancy tables --- netbox/tenancy/tables.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netbox/tenancy/tables.py b/netbox/tenancy/tables.py index 0eca7de71..72fb98e80 100644 --- a/netbox/tenancy/tables.py +++ b/netbox/tenancy/tables.py @@ -44,7 +44,6 @@ class TenantGroupTable(BaseTable): tenant_count = tables.Column( verbose_name='Tenants' ) - slug = tables.Column() actions = tables.TemplateColumn( template_code=TENANTGROUP_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -54,6 +53,7 @@ class TenantGroupTable(BaseTable): class Meta(BaseTable.Meta): model = TenantGroup fields = ('pk', 'name', 'tenant_count', 'description', 'slug', 'actions') + default_columns = ('pk', 'name', 'tenant_count', 'description', 'actions') # @@ -66,4 +66,5 @@ class TenantTable(BaseTable): class Meta(BaseTable.Meta): model = Tenant - fields = ('pk', 'name', 'group', 'description') + fields = ('pk', 'name', 'slug', 'group', 'description') + default_columns = ('pk', 'name', 'group', 'description') From c096232cb1fb36f981c6ea986a2d96018596a174 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 11:42:44 -0400 Subject: [PATCH 38/74] #492: Extend virtualization tables --- netbox/virtualization/tables.py | 75 +++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/netbox/virtualization/tables.py b/netbox/virtualization/tables.py index 09c22ab8a..ddc5b8ff7 100644 --- a/netbox/virtualization/tables.py +++ b/netbox/virtualization/tables.py @@ -46,7 +46,9 @@ VIRTUALMACHINE_PRIMARY_IP = """ class ClusterTypeTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - cluster_count = tables.Column(verbose_name='Clusters') + cluster_count = tables.Column( + verbose_name='Clusters' + ) actions = tables.TemplateColumn( template_code=CLUSTERTYPE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -55,7 +57,8 @@ class ClusterTypeTable(BaseTable): class Meta(BaseTable.Meta): model = ClusterType - fields = ('pk', 'name', 'cluster_count', 'description', 'actions') + fields = ('pk', 'name', 'slug', 'cluster_count', 'description', 'actions') + default_columns = ('pk', 'name', 'cluster_count', 'description', 'actions') # @@ -65,7 +68,9 @@ class ClusterTypeTable(BaseTable): class ClusterGroupTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - cluster_count = tables.Column(verbose_name='Clusters') + cluster_count = tables.Column( + verbose_name='Clusters' + ) actions = tables.TemplateColumn( template_code=CLUSTERGROUP_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, @@ -74,7 +79,8 @@ class ClusterGroupTable(BaseTable): class Meta(BaseTable.Meta): model = ClusterGroup - fields = ('pk', 'name', 'cluster_count', 'description', 'actions') + fields = ('pk', 'name', 'slug', 'cluster_count', 'description', 'actions') + default_columns = ('pk', 'name', 'cluster_count', 'description', 'actions') # @@ -84,10 +90,24 @@ class ClusterGroupTable(BaseTable): class ClusterTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - tenant = tables.LinkColumn('tenancy:tenant', args=[Accessor('tenant.slug')], verbose_name='Tenant') - site = tables.LinkColumn('dcim:site', args=[Accessor('site.slug')]) - device_count = tables.Column(accessor=Accessor('devices.count'), orderable=False, verbose_name='Devices') - vm_count = tables.Column(accessor=Accessor('virtual_machines.count'), orderable=False, verbose_name='VMs') + tenant = tables.LinkColumn( + viewname='tenancy:tenant', + args=[Accessor('tenant.slug')] + ) + site = tables.LinkColumn( + viewname='dcim:site', + args=[Accessor('site.slug')] + ) + device_count = tables.Column( + accessor=Accessor('devices.count'), + orderable=False, + verbose_name='Devices' + ) + vm_count = tables.Column( + accessor=Accessor('virtual_machines.count'), + orderable=False, + verbose_name='VMs' + ) class Meta(BaseTable.Meta): model = Cluster @@ -101,10 +121,19 @@ class ClusterTable(BaseTable): class VirtualMachineTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - status = tables.TemplateColumn(template_code=VIRTUALMACHINE_STATUS) - cluster = tables.LinkColumn('virtualization:cluster', args=[Accessor('cluster.pk')]) - role = tables.TemplateColumn(VIRTUALMACHINE_ROLE) - tenant = tables.TemplateColumn(template_code=COL_TENANT) + status = tables.TemplateColumn( + template_code=VIRTUALMACHINE_STATUS + ) + cluster = tables.LinkColumn( + viewname='virtualization:cluster', + args=[Accessor('cluster.pk')] + ) + role = tables.TemplateColumn( + template_code=VIRTUALMACHINE_ROLE + ) + tenant = tables.TemplateColumn( + template_code=COL_TENANT + ) class Meta(BaseTable.Meta): model = VirtualMachine @@ -112,13 +141,31 @@ class VirtualMachineTable(BaseTable): class VirtualMachineDetailTable(VirtualMachineTable): + primary_ip4 = tables.LinkColumn( + viewname='ipam:ipaddress', + args=[Accessor('primary_ip4.pk')], + verbose_name='IPv4 Address' + ) + primary_ip6 = tables.LinkColumn( + viewname='ipam:ipaddress', + args=[Accessor('primary_ip6.pk')], + verbose_name='IPv6 Address' + ) primary_ip = tables.TemplateColumn( - orderable=False, verbose_name='IP Address', template_code=VIRTUALMACHINE_PRIMARY_IP + orderable=False, + verbose_name='IP Address', + template_code=VIRTUALMACHINE_PRIMARY_IP ) class Meta(BaseTable.Meta): model = VirtualMachine - fields = ('pk', 'name', 'status', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip') + fields = ( + 'pk', 'name', 'status', 'cluster', 'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'primary_ip4', + 'primary_ip6', 'primary_ip', + ) + default_columns = ( + 'pk', 'name', 'status', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip', + ) # From 3b6d9dc5529cca6cb45addf6d4547b6d19be04ce Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 14:56:22 -0400 Subject: [PATCH 39/74] Add button to select all columns --- netbox/project-static/js/forms.js | 4 ++++ netbox/templates/inc/table_config_form.html | 1 + 2 files changed, 5 insertions(+) diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 59e1d8ff3..06d4a742a 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -472,5 +472,9 @@ $(document).ready(function() { } }); }); + $('#select-all-options').bind('click', function() { + var select_id = '#' + $(this).attr('data-target'); + $(select_id + ' option').prop('selected',true); + }); }); diff --git a/netbox/templates/inc/table_config_form.html b/netbox/templates/inc/table_config_form.html index 9cce92a8f..66844c7ca 100644 --- a/netbox/templates/inc/table_config_form.html +++ b/netbox/templates/inc/table_config_form.html @@ -14,6 +14,7 @@
From f8060ce112102924b0865c38057f935c715e045e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 15:05:29 -0400 Subject: [PATCH 40/74] Ignore clearing of invalid user config keys --- netbox/users/models.py | 8 +++++--- netbox/users/tests/__init__.py | 0 netbox/users/tests/test_models.py | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 netbox/users/tests/__init__.py diff --git a/netbox/users/models.py b/netbox/users/models.py index 02356696f..ea5762232 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -108,7 +108,7 @@ class UserConfig(models.Model): userconfig.clear('foo.bar.baz') - A KeyError is raised in the event any key along the path does not exist. + Invalid keys will be ignored silently. :param path: Dotted path to the configuration key. For example, 'foo.bar' deletes self.data['foo']['bar']. :param commit: If true, the UserConfig instance will be saved once the new value has been applied. @@ -117,11 +117,13 @@ class UserConfig(models.Model): keys = path.split('.') for key in keys[:-1]: - if key in d and type(d[key]) is dict: + if key not in d: + break + if type(d[key]) is dict: d = d[key] key = keys[-1] - del(d[key]) + d.pop(key, None) # Avoid a KeyError on invalid keys if commit: self.save() diff --git a/netbox/users/tests/__init__.py b/netbox/users/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/netbox/users/tests/test_models.py b/netbox/users/tests/test_models.py index 0157d8fdd..8047796c4 100644 --- a/netbox/users/tests/test_models.py +++ b/netbox/users/tests/test_models.py @@ -104,6 +104,5 @@ class UserConfigTest(TestCase): self.assertTrue('foo' not in userconfig.data['b']) self.assertEqual(userconfig.data['b']['bar'], 102) - # Clear an invalid value - with self.assertRaises(KeyError): - userconfig.clear('invalid') + # Clear a non-existing value; should fail silently + userconfig.clear('invalid') From 81ffa0811e65d285bb77c503a90b95f6d9c67dd4 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 29 Apr 2020 15:50:16 -0400 Subject: [PATCH 41/74] Closes #4556: Update form for adding devices to clusters --- docs/release-notes/version-2.8.md | 1 + netbox/templates/virtualization/cluster.html | 2 +- .../virtualization/cluster_add_devices.html | 21 +------------------ netbox/virtualization/views.py | 2 +- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index b6501d1cb..cbf8358bf 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -13,6 +13,7 @@ * [#4527](https://github.com/netbox-community/netbox/issues/4527) - Fix assignment of certain tags to config contexts * [#4545](https://github.com/netbox-community/netbox/issues/4545) - Removed all squashed schema migrations to allow direct upgrades from very old releases * [#4549](https://github.com/netbox-community/netbox/issues/4549) - Fix encoding unicode webhook body data +* [#4556](https://github.com/netbox-community/netbox/issues/4556) - Update form for adding devices to clusters --- diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index 7b250e5b1..0ff5e78f4 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -138,7 +138,7 @@ {% if perms.virtualization.change_cluster %}