Make compatible with NetBox 2.10

This commit is contained in:
Sander Steffann 2020-12-26 19:52:03 +01:00
parent ad9194559f
commit 75f00bd6bb
3 changed files with 17 additions and 6 deletions

View File

@ -11,10 +11,11 @@ For now all configuration is done in the NetBox admin back-end. A later version
## Compatibility
This plugin in compatible with [NetBox](https://netbox.readthedocs.org/) 2.8 and later. NetBox 2.10 introduced breaking
changes that make it unusable for my own use cases, so I will not be providing support for it. There is work being done
to create a fork of NetBox that is friendlier to both network operators and contributors. My future work will be in
support of that.
This plugin in compatible with [NetBox](https://netbox.readthedocs.org/) 2.8, 2.9 and 2.10.
NetBox 2.10 introduced breaking changes that make it unusable for my own use cases. There is work being done to create
a fork of NetBox that is friendlier to both network operators and contributors. My future work will be in support of
that.
## Installation

View File

@ -1,4 +1,4 @@
VERSION = '1.0.8'
VERSION = '1.1.0'
try:
from extras.plugins import PluginConfig
@ -12,6 +12,8 @@ class NetBoxDDNSConfig(PluginConfig):
name = 'netbox_ddns'
verbose_name = 'Dynamic DNS'
version = VERSION
min_version = '2.8'
max_version = '2.10'
author = 'Sander Steffann'
author_email = 'sander@steffann.nl'
description = 'Dynamic DNS Connector for NetBox'

View File

@ -12,9 +12,16 @@ from netbox_ddns.background_tasks import dns_create
from netbox_ddns.forms import ExtraDNSNameEditForm
from netbox_ddns.models import DNSStatus, ExtraDNSName
from netbox_ddns.utils import normalize_fqdn
from utilities.views import ObjectDeleteView, ObjectEditView
try:
# NetBox <= 2.9
from utilities.views import ObjectDeleteView, ObjectEditView
except ImportError:
# NetBox >= 2.10
from netbox.views.generic import ObjectDeleteView, ObjectEditView
# noinspection PyMethodMayBeStatic
class ExtraDNSNameObjectMixin:
def get_object(self, kwargs):
if 'ipaddress_pk' not in kwargs:
@ -60,6 +67,7 @@ class ExtraDNSNameDeleteView(PermissionRequiredMixin, ExtraDNSNameObjectMixin, O
class IPAddressDNSNameRecreateView(PermissionRequiredMixin, View):
permission_required = 'ipam.change_ipaddress'
# noinspection PyMethodMayBeStatic
def post(self, request, ipaddress_pk):
ip_address = get_object_or_404(IPAddress, pk=ipaddress_pk)