Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb7d294

Browse files
committedDec 18, 2020
Update project for 2.10
1 parent f34817d commit bb7d294

File tree

10 files changed

+177
-98
lines changed

10 files changed

+177
-98
lines changed
 

‎.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ env:
88
# Each version of NetBox listed here must have a corresponding directory/configuration file
99
# under development/netbox_<NETBOX_VER>/configuration.py
1010
matrix:
11-
- NETBOX_VER=v2.8.3
12-
- NETBOX_VER=master
11+
- NETBOX_VER=v2.8.9
12+
- NETBOX_VER=v2.9.9
13+
- NETBOX_VER=v2.10.1
1314
# Encrypted value for PYPI_TOKEN, this secret has been generated with the following command
1415
# travis encrypt PYPI_TOKEN=<value> --add env.global --com
1516
# Might need to update it once the repo is publish (travis-ci.org vs travis-ci.com)

‎development/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
ARG python_ver=3.7
33
FROM python:${python_ver}
44

5-
ARG netbox_ver=master
65
ENV PYTHONUNBUFFERED 1
76

87
RUN mkdir -p /opt
@@ -15,6 +14,7 @@ RUN pip install --upgrade pip\
1514
# -------------------------------------------------------------------------------------
1615
# Remove redis==3.4.1 from the requirements.txt file as a workaround to #4910
1716
# https://github.com/netbox-community/netbox/issues/4910, required for version 2.8.8 and earlier
17+
ARG netbox_ver=master
1818
RUN git clone --single-branch --branch ${netbox_ver} https://github.com/netbox-community/netbox.git /opt/netbox/ && \
1919
cd /opt/netbox/ && \
2020
sed -i '/^redis\=\=/d' /opt/netbox/requirements.txt && \

‎development/base_configuration.py ‎development/configuration.py

+110-49
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1-
"""NetBox configuration file."""
1+
"""NetBox configuration."""
22
import os
3+
from distutils.util import strtobool
4+
from django.core.exceptions import ImproperlyConfigured
5+
from .settings import VERSION # pylint: disable=relative-beyond-top-level
6+
7+
8+
# Enforce required configuration parameters
9+
for key in [
10+
"ALLOWED_HOSTS",
11+
"POSTGRES_DB",
12+
"POSTGRES_USER",
13+
"POSTGRES_HOST",
14+
"POSTGRES_PASSWORD",
15+
"REDIS_HOST",
16+
"REDIS_PASSWORD",
17+
"SECRET_KEY",
18+
]:
19+
if not os.environ.get(key):
20+
raise ImproperlyConfigured(f"Required environment variable {key} is missing.")
21+
22+
23+
def is_truthy(arg):
24+
"""Convert "truthy" strings into Booleans.
25+
26+
Examples:
27+
>>> is_truthy('yes')
28+
True
29+
Args:
30+
arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,
31+
f, false, off and 0. Raises ValueError if val is anything else.
32+
"""
33+
if isinstance(arg, bool):
34+
return arg
35+
return bool(strtobool(arg))
36+
337

438
# For reference see http://netbox.readthedocs.io/en/latest/configuration/mandatory-settings/
539
# Based on https://github.com/digitalocean/netbox/blob/develop/netbox/netbox/configuration.example.py
@@ -16,46 +50,52 @@
1650
# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
1751
#
1852
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
19-
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(" ")
53+
ALLOWED_HOSTS = os.environ["ALLOWED_HOSTS"].split(" ")
2054

2155
# PostgreSQL database configuration.
2256
DATABASE = {
23-
"NAME": os.environ.get("DB_NAME", "netbox"), # Database name
24-
"USER": os.environ.get("DB_USER", ""), # PostgreSQL username
25-
"PASSWORD": os.environ.get("DB_PASSWORD", ""),
57+
"NAME": os.environ["POSTGRES_DB"], # Database name
58+
"USER": os.environ["POSTGRES_USER"], # PostgreSQL username
59+
"PASSWORD": os.environ["POSTGRES_PASSWORD"],
2660
# PostgreSQL password
27-
"HOST": os.environ.get("DB_HOST", "localhost"), # Database server
28-
"PORT": os.environ.get("DB_PORT", ""), # Database port (leave blank for default)
61+
"HOST": os.environ["POSTGRES_HOST"], # Database server
62+
"PORT": 5432 if not os.environ.get("POSTGRES_PORT", False) else int(os.environ["POSTGRES_PORT"]), # Database port
2963
}
3064

3165
# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
3266
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
3367
# symbols. NetBox will not run without this defined. For more information, see
3468
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SECRET_KEY
35-
SECRET_KEY = os.environ.get("SECRET_KEY", "")
69+
SECRET_KEY = os.environ["SECRET_KEY"]
3670

3771
# Redis database settings. The Redis database is used for caching and background processing such as webhooks
3872
# Seperate sections for webhooks and caching allow for connecting to seperate Redis instances/datbases if desired.
3973
# Full connection details are required in both sections, even if they are the same.
4074
REDIS = {
4175
"caching": {
42-
"HOST": os.environ.get("REDIS_HOST", "redis"),
76+
"HOST": os.environ["REDIS_HOST"],
4377
"PORT": int(os.environ.get("REDIS_PORT", 6379)),
44-
"PASSWORD": os.environ.get("REDIS_PASSWORD", ""),
78+
"PASSWORD": os.environ["REDIS_PASSWORD"],
4579
"DATABASE": 1,
46-
"SSL": bool(os.environ.get("REDIS_SSL", False)),
80+
"SSL": is_truthy(os.environ.get("REDIS_SSL", False)),
4781
},
4882
"tasks": {
49-
"HOST": os.environ.get("REDIS_HOST", "redis"),
83+
"HOST": os.environ["REDIS_HOST"],
5084
"PORT": int(os.environ.get("REDIS_PORT", 6379)),
51-
"PASSWORD": os.environ.get("REDIS_PASSWORD", ""),
85+
"PASSWORD": os.environ["REDIS_PASSWORD"],
5286
"DATABASE": 0,
53-
"SSL": bool(os.environ.get("REDIS_SSL", False)),
87+
"SSL": is_truthy(os.environ.get("REDIS_SSL", False)),
5488
},
5589
}
5690

57-
RQ_DEFAULT_TIMEOUT = 300
58-
91+
if VERSION.startswith("2.8."):
92+
# NetBox 2.8.x Specific Settings
93+
REDIS["caching"]["DEFAULT_TIMEOUT"] = 300
94+
REDIS["tasks"]["DEFAULT_TIMEOUT"] = 300
95+
elif VERSION.startswith("2.9.") or VERSION.startswith("2.10."):
96+
RQ_DEFAULT_TIMEOUT = 300
97+
else:
98+
raise ImproperlyConfigured(f"Version {VERSION} of NetBox is unsupported at this time.")
5999

60100
#########################
61101
# #
@@ -71,8 +111,8 @@
71111

72112
# Optionally display a persistent banner at the top and/or bottom of every page. HTML is allowed. To display the same
73113
# content in both banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
74-
BANNER_TOP = os.environ.get("BANNER_TOP", None)
75-
BANNER_BOTTOM = os.environ.get("BANNER_BOTTOM", None)
114+
BANNER_TOP = os.environ.get("BANNER_TOP", "")
115+
BANNER_BOTTOM = os.environ.get("BANNER_BOTTOM", "")
76116

77117
# Text to include on the login page above the login form. HTML is allowed.
78118
BANNER_LOGIN = os.environ.get("BANNER_LOGIN", "")
@@ -87,58 +127,65 @@
87127
# API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to True, all origins will be
88128
# allowed. Otherwise, define a list of allowed origins using either CORS_ORIGIN_WHITELIST or
89129
# CORS_ORIGIN_REGEX_WHITELIST. For more information, see https://github.com/ottoyiu/django-cors-headers
90-
CORS_ORIGIN_ALLOW_ALL = True
130+
CORS_ORIGIN_ALLOW_ALL = is_truthy(os.environ.get("CORS_ORIGIN_ALLOW_ALL", False))
91131
CORS_ORIGIN_WHITELIST = []
92132
CORS_ORIGIN_REGEX_WHITELIST = []
93133

94134
# Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
95135
# sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging
96136
# on a production system.
97-
DEBUG = True
98-
DEVELOPER = True
137+
DEBUG = is_truthy(os.environ.get("DEBUG", False))
138+
DEVELOPER = is_truthy(os.environ.get("DEVELOPER", False))
99139

100140
# Email settings
101141
EMAIL = {
102-
"SERVER": "localhost",
103-
"PORT": 25,
104-
"USERNAME": "",
105-
"PASSWORD": "",
106-
"TIMEOUT": 10,
107-
"FROM_EMAIL": "",
142+
"SERVER": os.environ.get("EMAIL_SERVER", "localhost"),
143+
"PORT": int(os.environ.get("EMAIL_PORT", 25)),
144+
"USERNAME": os.environ.get("EMAIL_USERNAME", ""),
145+
"PASSWORD": os.environ.get("EMAIL_PASSWORD", ""),
146+
"TIMEOUT": int(os.environ.get("EMAIL_TIMEOUT", 10)), # seconds
147+
"FROM_EMAIL": os.environ.get("EMAIL_FROM", ""),
108148
}
109149

110150
# Enforcement of unique IP space can be toggled on a per-VRF basis.
111151
# To enforce unique IP space within the global table (all prefixes and IP addresses not assigned to a VRF),
112152
# set ENFORCE_GLOBAL_UNIQUE to True.
113-
ENFORCE_GLOBAL_UNIQUE = False
153+
ENFORCE_GLOBAL_UNIQUE = is_truthy(os.environ.get("ENFORCE_GLOBAL_UNIQUE", False))
154+
155+
# HTTP proxies NetBox should use when sending outbound HTTP requests (e.g. for webhooks).
156+
# HTTP_PROXIES = {
157+
# "http": "http://192.0.2.1:3128",
158+
# "https": "http://192.0.2.1:1080",
159+
# }
160+
161+
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
162+
# NetBox from an internal IP.
163+
INTERNAL_IPS = ("127.0.0.1", "::1")
164+
165+
LOG_LEVEL = os.environ.get("LOG_LEVEL", "DEBUG" if DEBUG else "INFO")
114166

115167
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
116168
# https://docs.djangoproject.com/en/1.11/topics/logging/
117169
LOGGING = {
118170
"version": 1,
119171
"disable_existing_loggers": False,
120-
"formatters": {"rq_console": {"format": "%(asctime)s %(message)s", "datefmt": "%H:%M:%S",},},
121-
"handlers": {
122-
"rq_console": {
123-
"level": "DEBUG",
124-
"class": "rq.utils.ColorizingStreamHandler",
125-
"formatter": "rq_console",
126-
"exclude": ["%(asctime)s"],
172+
"formatters": {
173+
"verbose": {
174+
"format": "{asctime} {levelname} {message} - {name} - {module} - {pathname}:{lineno}",
175+
"datefmt": "%H:%M:%S",
176+
"style": "{",
127177
},
128178
},
129-
"loggers": {"rq.worker": {"handlers": ["rq_console"], "level": "DEBUG"},},
179+
"handlers": {"console": {"level": "DEBUG", "class": "rq.utils.ColorizingStreamHandler", "formatter": "verbose"}},
180+
"root": {"handlers": ["console"], "level": LOG_LEVEL},
130181
}
131182

132183
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
133184
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.
134-
LOGIN_REQUIRED = False
135-
136-
# Base URL path if accessing NetBox within a directory. For example, if installed at http://example.com/netbox/, set:
137-
# BASE_PATH = 'netbox/'
138-
BASE_PATH = os.environ.get("BASE_PATH", "")
185+
LOGIN_REQUIRED = is_truthy(os.environ.get("LOGIN_REQUIRED", False))
139186

140187
# Setting this to True will display a "maintenance mode" banner at the top of every page.
141-
MAINTENANCE_MODE = os.environ.get("MAINTENANCE_MODE", False)
188+
MAINTENANCE_MODE = is_truthy(os.environ.get("MAINTENANCE_MODE", False))
142189

143190
# An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
144191
# "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
@@ -149,11 +196,14 @@
149196
# the default value of this setting is derived from the installed location.
150197
MEDIA_ROOT = os.environ.get("MEDIA_ROOT", os.path.join(BASE_DIR, "media"))
151198

199+
# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics'
200+
METRICS_ENABLED = True
201+
152202
NAPALM_USERNAME = os.environ.get("NAPALM_USERNAME", "")
153203
NAPALM_PASSWORD = os.environ.get("NAPALM_PASSWORD", "")
154204

155205
# NAPALM timeout (in seconds). (Default: 30)
156-
NAPALM_TIMEOUT = os.environ.get("NAPALM_TIMEOUT", 30)
206+
NAPALM_TIMEOUT = int(os.environ.get("NAPALM_TIMEOUT", 30))
157207

158208
# NAPALM optional arguments (see http://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must
159209
# be provided as a dictionary.
@@ -163,27 +213,34 @@
163213
}
164214

165215
# Determine how many objects to display per page within a list. (Default: 50)
166-
PAGINATE_COUNT = os.environ.get("PAGINATE_COUNT", 50)
216+
PAGINATE_COUNT = int(os.environ.get("PAGINATE_COUNT", 50))
167217

168218
# Enable installed plugins. Add the name of each plugin to the list.
169219
PLUGINS = ["netbox_onboarding"]
170220

171-
PLUGINS_CONFIG = {"netbox_onboarding": {}}
172221
# Plugins configuration settings. These settings are used by various plugins that the user may have installed.
173222
# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings.
174-
# PLUGINS_CONFIG = {}
223+
PLUGINS_CONFIG = {}
175224

176225
# When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
177226
# prefer IPv4 instead.
178-
PREFER_IPV4 = os.environ.get("PREFER_IPV4", False)
227+
PREFER_IPV4 = is_truthy(os.environ.get("PREFER_IPV4", False))
179228

180229
# Remote authentication support
181230
REMOTE_AUTH_ENABLED = False
182-
REMOTE_AUTH_BACKEND = "netbox.authentication.RemoteUserBackend"
183231
REMOTE_AUTH_HEADER = "HTTP_REMOTE_USER"
184232
REMOTE_AUTH_AUTO_CREATE_USER = True
185233
REMOTE_AUTH_DEFAULT_GROUPS = []
186-
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
234+
235+
if VERSION.startswith("2.8."):
236+
# NetBox 2.8.x Specific Settings
237+
REMOTE_AUTH_BACKEND = "utilities.auth_backends.RemoteUserBackend"
238+
REMOTE_AUTH_DEFAULT_PERMISSIONS = []
239+
elif VERSION.startswith("2.9.") or VERSION.startswith("2.10."):
240+
REMOTE_AUTH_BACKEND = "netbox.authentication.RemoteUserBackend"
241+
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
242+
else:
243+
raise ImproperlyConfigured(f"Version {VERSION} of NetBox is unsupported at this time.")
187244

188245
# This determines how often the GitHub API is called to check the latest release of NetBox. Must be at least 1 hour.
189246
RELEASE_CHECK_TIMEOUT = 24 * 3600
@@ -199,6 +256,10 @@
199256
# this setting is derived from the installed location.
200257
REPORTS_ROOT = os.environ.get("REPORTS_ROOT", os.path.join(BASE_DIR, "reports"))
201258

259+
# The file path where custom scripts will be stored. A trailing slash is not needed. Note that the default value of
260+
# this setting is derived from the installed location.
261+
SCRIPTS_ROOT = os.environ.get("SCRIPTS_ROOT", os.path.join(BASE_DIR, "scripts"))
262+
202263
# Time zone (default: UTC)
203264
TIME_ZONE = os.environ.get("TIME_ZONE", "UTC")
204265

‎development/dev.env

+22-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
ALLOWED_HOSTS=*
2-
DB_NAME=netbox
3-
DB_USER=netbox
4-
DB_PASSWORD=decinablesprewad
5-
PGPASSWORD=decinablesprewad
6-
DB_HOST=postgres
7-
NAPALM_TIMEOUT=5
2+
BANNER_TOP="Onboarding plugin dev"
3+
CHANGELOG_RETENTION=0
4+
DEBUG=True
5+
DEVELOPER=True
6+
EMAIL_FROM=netbox@example.com
7+
EMAIL_PASSWORD=
8+
EMAIL_PORT=25
9+
EMAIL_SERVER=localhost
10+
EMAIL_TIMEOUT=5
11+
EMAIL_USERNAME=netbox
812
MAX_PAGE_SIZE=0
9-
SECRET_KEY=bqn8nn4qmjvx4hv2u5qr4pp46s3w9skbb63y
10-
POSTGRES_USER=netbox
11-
POSTGRES_PASSWORD=decinablesprewad
13+
METRICS_ENABLED=True
14+
NAPALM_TIMEOUT=5
1215
POSTGRES_DB=netbox
13-
CHANGELOG_RETENTION=0
16+
POSTGRES_HOST=postgres
17+
POSTGRES_PASSWORD=notverysecurepwd
18+
POSTGRES_USER=netbox
1419
REDIS_HOST=redis
20+
REDIS_PASSWORD=notverysecurepwd
1521
REDIS_PORT=6379
16-
# Uncomment REDIS_SSL if using SSL
1722
# REDIS_SSL=True
18-
REDIS_PASSWORD=decinablesprewad
19-
23+
# Uncomment REDIS_SSL if using SSL
24+
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
25+
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
26+
SUPERUSER_EMAIL=admin@example.com
27+
SUPERUSER_NAME=admin
28+
SUPERUSER_PASSWORD=admin

‎development/docker-compose.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ services:
1717
env_file:
1818
- ./dev.env
1919
volumes:
20-
- ./base_configuration.py:/opt/netbox/netbox/netbox/base_configuration.py
21-
- ./netbox_${NETBOX_VER}/configuration.py:/opt/netbox/netbox/netbox/configuration.py
20+
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py
2221
- ../:/source
2322
tty: true
2423
worker:
@@ -32,8 +31,7 @@ services:
3231
env_file:
3332
- ./dev.env
3433
volumes:
35-
- ./base_configuration.py:/opt/netbox/netbox/netbox/base_configuration.py
36-
- ./netbox_${NETBOX_VER}/configuration.py:/opt/netbox/netbox/netbox/configuration.py
34+
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py
3735
- ../netbox_onboarding:/source/netbox_onboarding
3836
tty: true
3937
postgres:

‎development/netbox_master/configuration.py

-4
This file was deleted.

‎development/netbox_v2.8.3/configuration.py

-8
This file was deleted.

‎netbox_onboarding/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class OnboardingConfig(PluginConfig):
2828
base_url = "onboarding"
2929
required_settings = []
3030
min_version = "2.8.1"
31+
max_version = "2.10.99"
3132
default_settings = {
3233
"create_platform_if_missing": True,
3334
"create_manufacturer_if_missing": True,

‎netbox_onboarding/release.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
NETBOX_RELEASE_CURRENT = version.parse(settings.VERSION)
1919
NETBOX_RELEASE_28 = version.parse("2.8")
2020
NETBOX_RELEASE_29 = version.parse("2.9")
21+
NETBOX_RELEASE_210 = version.parse("2.10")

‎netbox_onboarding/views.py

+37-17
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from django.shortcuts import get_object_or_404, render
1717
from django.views.generic import View
1818

19-
from utilities.views import BulkDeleteView, BulkImportView, ObjectEditView, ObjectListView
20-
21-
from .release import NETBOX_RELEASE_CURRENT, NETBOX_RELEASE_29
19+
from .release import NETBOX_RELEASE_CURRENT, NETBOX_RELEASE_29, NETBOX_RELEASE_210
2220

2321
from .filters import OnboardingTaskFilter
2422
from .forms import OnboardingTaskForm, OnboardingTaskFilterForm, OnboardingTaskFeedCSVForm
@@ -27,52 +25,74 @@
2725

2826
logger = logging.getLogger("rq.worker")
2927

28+
# pylint: disable=ungrouped-imports
3029

3130
if NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_29:
32-
from django.contrib.auth.mixins import PermissionRequiredMixin # pylint: disable=ungrouped-imports
31+
from django.contrib.auth.mixins import PermissionRequiredMixin
32+
from utilities.views import BulkDeleteView, BulkImportView, ObjectEditView, ObjectListView
3333

3434
class ReleaseMixinOnboardingTaskView(PermissionRequiredMixin, View):
3535
"""Release Mixin View for presenting a single OnboardingTask."""
3636

3737
permission_required = "netbox_onboarding.view_onboardingtask"
3838

39-
class ReleaseMixinOnboardingTaskListView(PermissionRequiredMixin):
39+
class ReleaseMixinOnboardingTaskListView(PermissionRequiredMixin, ObjectListView):
4040
"""Release Mixin View for listing all extant OnboardingTasks."""
4141

4242
permission_required = "netbox_onboarding.view_onboardingtask"
4343

44-
class ReleaseMixinOnboardingTaskCreateView(PermissionRequiredMixin):
44+
class ReleaseMixinOnboardingTaskCreateView(PermissionRequiredMixin, ObjectEditView):
4545
"""Release Mixin View for creating a new OnboardingTask."""
4646

4747
permission_required = "netbox_onboarding.add_onboardingtask"
4848

49-
class ReleaseMixinOnboardingTaskBulkDeleteView(PermissionRequiredMixin):
49+
class ReleaseMixinOnboardingTaskBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
5050
"""Release Mixin View for deleting one or more OnboardingTasks."""
5151

5252
permission_required = "netbox_onboarding.delete_onboardingtask"
5353

54-
class ReleaseMixinOnboardingTaskFeedBulkImportView(PermissionRequiredMixin):
54+
class ReleaseMixinOnboardingTaskFeedBulkImportView(PermissionRequiredMixin, BulkImportView):
5555
"""Release Mixin View for bulk-importing a CSV file to create OnboardingTasks."""
5656

5757
permission_required = "netbox_onboarding.add_onboardingtask"
5858

5959

60+
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_29 and NETBOX_RELEASE_CURRENT > NETBOX_RELEASE_210:
61+
from utilities.views import ObjectView # pylint: disable=no-name-in-module
62+
from utilities.views import BulkDeleteView, BulkImportView, ObjectEditView, ObjectListView
63+
64+
class ReleaseMixinOnboardingTaskView(ObjectView):
65+
"""Release Mixin View for presenting a single OnboardingTask."""
66+
67+
class ReleaseMixinOnboardingTaskListView(ObjectListView):
68+
"""Release Mixin View for listing all extant OnboardingTasks."""
69+
70+
class ReleaseMixinOnboardingTaskCreateView(ObjectEditView):
71+
"""Release Mixin View for creating a new OnboardingTask."""
72+
73+
class ReleaseMixinOnboardingTaskBulkDeleteView(BulkDeleteView):
74+
"""Release Mixin View for deleting one or more OnboardingTasks."""
75+
76+
class ReleaseMixinOnboardingTaskFeedBulkImportView(BulkImportView):
77+
"""Release Mixin View for bulk-importing a CSV file to create OnboardingTasks."""
78+
79+
6080
else:
61-
from utilities.views import ObjectView # pylint: disable=ungrouped-imports, no-name-in-module
81+
from netbox.views.generic import ObjectView, BulkDeleteView, BulkImportView, ObjectEditView, ObjectListView
6282

6383
class ReleaseMixinOnboardingTaskView(ObjectView):
6484
"""Release Mixin View for presenting a single OnboardingTask."""
6585

66-
class ReleaseMixinOnboardingTaskListView:
86+
class ReleaseMixinOnboardingTaskListView(ObjectListView):
6787
"""Release Mixin View for listing all extant OnboardingTasks."""
6888

69-
class ReleaseMixinOnboardingTaskCreateView:
89+
class ReleaseMixinOnboardingTaskCreateView(ObjectEditView):
7090
"""Release Mixin View for creating a new OnboardingTask."""
7191

72-
class ReleaseMixinOnboardingTaskBulkDeleteView:
92+
class ReleaseMixinOnboardingTaskBulkDeleteView(BulkDeleteView):
7393
"""Release Mixin View for deleting one or more OnboardingTasks."""
7494

75-
class ReleaseMixinOnboardingTaskFeedBulkImportView:
95+
class ReleaseMixinOnboardingTaskFeedBulkImportView(BulkImportView):
7696
"""Release Mixin View for bulk-importing a CSV file to create OnboardingTasks."""
7797

7898

@@ -88,7 +108,7 @@ def get(self, request, pk): # pylint: disable=invalid-name, missing-function-do
88108
return render(request, "netbox_onboarding/onboardingtask.html", {"onboardingtask": onboardingtask,})
89109

90110

91-
class OnboardingTaskListView(ReleaseMixinOnboardingTaskListView, ObjectListView):
111+
class OnboardingTaskListView(ReleaseMixinOnboardingTaskListView):
92112
"""View for listing all extant OnboardingTasks."""
93113

94114
queryset = OnboardingTask.objects.all().order_by("-id")
@@ -98,7 +118,7 @@ class OnboardingTaskListView(ReleaseMixinOnboardingTaskListView, ObjectListView)
98118
template_name = "netbox_onboarding/onboarding_tasks_list.html"
99119

100120

101-
class OnboardingTaskCreateView(ReleaseMixinOnboardingTaskCreateView, ObjectEditView):
121+
class OnboardingTaskCreateView(ReleaseMixinOnboardingTaskCreateView):
102122
"""View for creating a new OnboardingTask."""
103123

104124
model = OnboardingTask
@@ -108,15 +128,15 @@ class OnboardingTaskCreateView(ReleaseMixinOnboardingTaskCreateView, ObjectEditV
108128
default_return_url = "plugins:netbox_onboarding:onboardingtask_list"
109129

110130

111-
class OnboardingTaskBulkDeleteView(ReleaseMixinOnboardingTaskBulkDeleteView, BulkDeleteView):
131+
class OnboardingTaskBulkDeleteView(ReleaseMixinOnboardingTaskBulkDeleteView):
112132
"""View for deleting one or more OnboardingTasks."""
113133

114134
queryset = OnboardingTask.objects.filter() # TODO: can we exclude currently-running tasks?
115135
table = OnboardingTaskTable
116136
default_return_url = "plugins:netbox_onboarding:onboardingtask_list"
117137

118138

119-
class OnboardingTaskFeedBulkImportView(ReleaseMixinOnboardingTaskFeedBulkImportView, BulkImportView):
139+
class OnboardingTaskFeedBulkImportView(ReleaseMixinOnboardingTaskFeedBulkImportView):
120140
"""View for bulk-importing a CSV file to create OnboardingTasks."""
121141

122142
queryset = OnboardingTask.objects.all()

0 commit comments

Comments
 (0)
Please sign in to comment.