Skip to content

Commit

Permalink
Merge pull request #143 from networktocode/mzb-netbox211
Browse files Browse the repository at this point in the history
NetBox 2.11 support
  • Loading branch information
mzbroch authored Aug 9, 2021
2 parents 2eca893 + 1b59bd4 commit 499f828
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ env:
matrix:
- NETBOX_VER=v2.8.9
- NETBOX_VER=v2.9.11
- NETBOX_VER=v2.10.2
- NETBOX_VER=v2.10.10
- NETBOX_VER=v2.11.10
# Encrypted value for PYPI_TOKEN, this secret has been generated with the following command
# travis encrypt PYPI_TOKEN=<value> --add env.global --com
# Might need to update it once the repo is publish (travis-ci.org vs travis-ci.com)
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ systemctl restart netbox netbox-rq

### Compatibility Matrix

| | Netbox 2.8 | Netbox 2.9 | Netbox 2.10 |
|-----------------------|------------|------------|-------------|
| Onboarding Plugin 1.3 | X | | |
| Onboarding Plugin 2.0 | X | X | |
| Onboarding Plugin 2.1 | X | X | X |
| | Netbox 2.8 | Netbox 2.9 | Netbox 2.10 | Netbox 2.11 |
|-----------------------|------------|------------|-------------|-------------|
| Onboarding Plugin 1.3 | X | | | |
| Onboarding Plugin 2.0 | X | X | | |
| Onboarding Plugin 2.1 | X | X | X | |
| Onboarding Plugin 2.2 | X | X | X | X |

To ensure NetBox Onboarding plugin is automatically re-installed during future upgrades, create a file named `local_requirements.txt` (if not already existing) in the NetBox root directory (alongside `requirements.txt`) and list the `ntc-netbox-plugin-onboarding` package:

Expand Down
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
4 changes: 2 additions & 2 deletions netbox_onboarding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
limitations under the License.
"""

__version__ = "2.1.0"
__version__ = "2.2.0"

from extras.plugins import PluginConfig

Expand All @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ntc-netbox-plugin-onboarding"
version = "2.1.0"
version = "2.2.0"
description = "A plugin for NetBox to easily onboard new devices."
authors = ["Network to Code, LLC <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 499f828

Please sign in to comment.