Skip to content

Commit

Permalink
Merge pull request #95 from peteeckel/fix/compatibility-netbox-35
Browse files Browse the repository at this point in the history
Restored compatibility with NetBox < 3.5.8
  • Loading branch information
peteeckel authored Nov 10, 2023
2 parents 702d061 + aff15f0 commit d6c597f
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NetBox DNS is using the standardized NetBox plugin interface, so it also takes a

## Requirements

* NetBox 3.5.8 or higher
* NetBox 3.5.0 or higher
* Python 3.8 or higher

## Installation & Configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/using_netbox_dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The installation of plugins in general is described in the [NetBox documentation
### Requirements
The installation of NetBox DNS requires a Python interpreter and a working NetBox deployment. Supported versions are currently:

* NetBox 3.5.8 or higher
* NetBox 3.5.0 or higher
* Python 3.8 or higher

### Installation of NetBox DNS
Expand Down
10 changes: 8 additions & 2 deletions netbox_dns/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import sys

from extras.plugins import PluginConfig
from extras.plugins.utils import get_plugin_config

try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config

__version__ = "0.20.2"

Expand All @@ -10,7 +16,7 @@ class DNSConfig(PluginConfig):
name = "netbox_dns"
verbose_name = "NetBox DNS"
description = "NetBox plugin for DNS data"
min_version = "3.5.8"
min_version = "3.5.0"
version = __version__
author = "Peter Eckel"
author_email = "[email protected]"
Expand Down
8 changes: 7 additions & 1 deletion netbox_dns/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

from ipam.models import IPAddress
from ipam.choices import IPAddressStatusChoices
from extras.plugins.utils import get_plugin_config

try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config
from netbox.signals import post_clean
from utilities.permissions import resolve_permission

Expand Down
8 changes: 7 additions & 1 deletion netbox_dns/models/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
from netbox.search import SearchIndex, register_search
from utilities.querysets import RestrictedQuerySet
from utilities.choices import ChoiceSet
from extras.plugins.utils import get_plugin_config

try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config

from netbox_dns.fields import AddressField
from netbox_dns.utilities import (
Expand Down
8 changes: 7 additions & 1 deletion netbox_dns/models/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
from netbox.search import SearchIndex, register_search
from utilities.querysets import RestrictedQuerySet
from utilities.choices import ChoiceSet
from extras.plugins.utils import get_plugin_config
from ipam.models import IPAddress

try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config

from netbox_dns.fields import NetworkField
from netbox_dns.utilities import (
arpa_to_prefix,
Expand Down
7 changes: 6 additions & 1 deletion netbox_dns/template_content.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from extras.plugins.utils import get_plugin_config
try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config
from extras.plugins import PluginTemplateExtension

from netbox_dns.models import Record, Zone, View, NameServer
Expand Down
7 changes: 6 additions & 1 deletion netbox_dns/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from dns.exception import DNSException
from netaddr import IPNetwork, AddrFormatError

from extras.plugins.utils import get_plugin_config
try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config


class NameFormatError(Exception):
Expand Down
7 changes: 6 additions & 1 deletion netbox_dns/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from django.core.exceptions import ValidationError

from extras.plugins.utils import get_plugin_config
try:
# NetBox 3.5.0 - 3.5.7, 3.5.9+
from extras.plugins import get_plugin_config
except ImportError:
# NetBox 3.5.8
from extras.plugins.utils import get_plugin_config

LABEL = r"[a-z0-9][a-z0-9-]*(?<!-)"
UNDERSCORE_LABEL = r"[a-z0-9][a-z0-9-_]*(?<![-_])"
Expand Down

0 comments on commit d6c597f

Please sign in to comment.