Skip to content

Commit

Permalink
NetBox 2.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mzbroch committed Aug 8, 2021
1 parent 2eca893 commit b316e90
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
6 changes: 3 additions & 3 deletions development/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NETBOX_RELEASE_CURRENT = version.parse(VERSION)
NETBOX_RELEASE_28 = version.parse("2.8")
NETBOX_RELEASE_29 = version.parse("2.9")
NETBOX_RELEASE_211 = version.parse("2.11")
NETBOX_RELEASE_212 = version.parse("2.12")

# Enforce required configuration parameters
for key in [
Expand Down Expand Up @@ -104,7 +104,7 @@ def is_truthy(arg):
# NetBox 2.8.x Specific Settings
REDIS["caching"]["DEFAULT_TIMEOUT"] = 300
REDIS["tasks"]["DEFAULT_TIMEOUT"] = 300
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_211:
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_212:
RQ_DEFAULT_TIMEOUT = 300
else:
raise ImproperlyConfigured(f"Version {NETBOX_RELEASE_CURRENT} of NetBox is unsupported at this time.")
Expand Down Expand Up @@ -248,7 +248,7 @@ def is_truthy(arg):
# NetBox 2.8.x Specific Settings
REMOTE_AUTH_BACKEND = "utilities.auth_backends.RemoteUserBackend"
REMOTE_AUTH_DEFAULT_PERMISSIONS = []
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_211:
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_212:
REMOTE_AUTH_BACKEND = "netbox.authentication.RemoteUserBackend"
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
else:
Expand Down
2 changes: 1 addition & 1 deletion netbox_onboarding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OnboardingConfig(PluginConfig):
base_url = "onboarding"
required_settings = []
min_version = "2.8.1"
max_version = "2.10.99"
max_version = "2.11.99"
default_settings = {
"create_platform_if_missing": True,
"create_manufacturer_if_missing": True,
Expand Down
18 changes: 16 additions & 2 deletions netbox_onboarding/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@
from django.db.models import Q

from dcim.models import Site, DeviceRole, Platform
from utilities.filters import NameSlugSearchFilterSet

from .release import NETBOX_RELEASE_CURRENT, NETBOX_RELEASE_211
from .models import OnboardingTask


class OnboardingTaskFilter(NameSlugSearchFilterSet):
if NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_211:
from utilities.filters import NameSlugSearchFilterSet # pylint: disable=no-name-in-module, import-error

class FitersetMixin(NameSlugSearchFilterSet):
"""FilterSet Mixin."""


else:
from netbox.filtersets import BaseFilterSet # pylint: disable=no-name-in-module, import-error

class FitersetMixin(BaseFilterSet):
"""FilterSet Mixin."""


class OnboardingTaskFilter(FitersetMixin):
"""Filter capabilities for OnboardingTask instances."""

q = django_filters.CharFilter(method="search", label="Search",)
Expand Down
9 changes: 6 additions & 3 deletions netbox_onboarding/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
from django.urls import reverse
from dcim.models import Device
from .choices import OnboardingStatusChoices, OnboardingFailChoices
from .release import NETBOX_RELEASE_CURRENT, NETBOX_RELEASE_29
from .release import NETBOX_RELEASE_CURRENT, NETBOX_RELEASE_29, NETBOX_RELEASE_211

# Support NetBox 2.8
if NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_29:
from utilities.models import ChangeLoggedModel # pylint: disable=no-name-in-module, import-error
# Support NetBox 2.9
else:
# Support NetBox 2.9, NetBox 2.10
elif NETBOX_RELEASE_CURRENT < NETBOX_RELEASE_211:
from extras.models import ChangeLoggedModel # pylint: disable=no-name-in-module, import-error
# Support NetBox 2.11
else:
from netbox.models import ChangeLoggedModel # pylint: disable=no-name-in-module, import-error


class OnboardingTask(ChangeLoggedModel):
Expand Down

0 comments on commit b316e90

Please sign in to comment.