Skip to content

Commit ea4c4de

Browse files
authored
Added support for Netbox 3.6 (#19)
1 parent a9b6b96 commit ea4c4de

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.5 (2023-09-08)
4+
5+
* Fix for NetBox 3.6.0
6+
37
## 0.1.4 (2023-08-18)
48

59
* Fix for NetBox 3.5.8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The features the plugin provides should be listed here.
1919
|----------------|----------------|
2020
| 3.5 | 0.1.0 |
2121
| 3.5.8 | 0.1.4 |
22-
22+
| 3.6.0 > | 0.1.5 |
2323
## Installation
2424

2525
For adding to a NetBox Docker setup see

netbox_napalm_plugin/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Arthur Hanson"""
44
__email__ = "[email protected]"
5-
__version__ = "0.1.4"
5+
__version__ = "0.1.5"
66

77

88
from extras.plugins import PluginConfig
@@ -22,7 +22,7 @@ class NapalmPlatformConfig(PluginConfig):
2222
'NAPALM_ARGS': {},
2323
}
2424
min_version = '3.5.0-dev'
25-
max_version = '3.5.99'
25+
max_version = '3.6.99'
2626

2727

2828
config = NapalmPlatformConfig

netbox_napalm_plugin/api/views.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ def napalm(self, request, pk):
3535
)
3636
if device.platform is None:
3737
raise ServiceUnavailable("No platform is configured for this device.")
38-
if (
39-
not hasattr(device.platform, "napalm")
40-
or not device.platform.napalm.napalm_driver
41-
):
38+
# Checks to see if NapalmPlatform object exists
39+
if not NapalmPlatformConfig.objects.filter(platform=device.platform).exists():
40+
raise ServiceUnavailable(
41+
f"No NAPALM Platform Mapping is configured for this device's platform: {device.platform}."
42+
)
43+
if NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver == "":
4244
raise ServiceUnavailable(
4345
f"No NAPALM driver is configured for this device's platform: {device.platform}."
4446
)
@@ -75,11 +77,11 @@ def napalm(self, request, pk):
7577

7678
# Validate the configured driver
7779
try:
78-
driver = napalm.get_network_driver(device.platform.napalm_driver)
80+
driver = napalm.get_network_driver(NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver)
7981
except ModuleImportError:
8082
raise ServiceUnavailable(
8183
"NAPALM driver for platform {} not found: {}.".format(
82-
device.platform, device.platform.napalm_driver
84+
device.platform, NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver
8385
)
8486
)
8587

@@ -94,9 +96,8 @@ def napalm(self, request, pk):
9496
password = get_plugin_config('netbox_napalm_plugin', 'NAPALM_PASSWORD')
9597
timeout = get_plugin_config('netbox_napalm_plugin', 'NAPALM_TIMEOUT')
9698
optional_args = get_plugin_config('netbox_napalm_plugin', 'NAPALM_ARGS').copy()
97-
if device.platform.napalm_args is not None:
98-
optional_args.update(device.platform.napalm_args)
99-
99+
if NapalmPlatformConfig.objects.get(platform=device.platform).napalm_args is not None:
100+
optional_args.update(NapalmPlatformConfig.objects.get(platform=device.platform).napalm_args)
100101
# Update NAPALM parameters according to the request headers
101102
for header in request.headers:
102103
if header[:9].lower() != "x-napalm-":

netbox_napalm_plugin/project-static/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netbox_napalm_plugin",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Napalm Plugin for NetBox",
55
"main": "index.js",
66
"author": "Arthur Hanson",

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ python =
3030
3.8: py38, format, lint, build
3131

3232
[bumpversion]
33-
current_version = 0.1.4
33+
current_version = 0.1.5
3434
commit = True
3535
tag = True
3636

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
packages=find_packages(include=['netbox_napalm_plugin', 'netbox_napalm_plugin.*']),
3333
test_suite='tests',
3434
url='https://github.com/netbox-community/netbox-napalm',
35-
version='0.1.4',
35+
version='0.1.5',
3636
zip_safe=False,
3737
)

0 commit comments

Comments
 (0)