Skip to content

Commit

Permalink
Added support for Netbox 3.6 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlynch3 authored Sep 8, 2023
1 parent a9b6b96 commit ea4c4de
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.5 (2023-09-08)

* Fix for NetBox 3.6.0

## 0.1.4 (2023-08-18)

* Fix for NetBox 3.5.8
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The features the plugin provides should be listed here.
|----------------|----------------|
| 3.5 | 0.1.0 |
| 3.5.8 | 0.1.4 |

| 3.6.0 > | 0.1.5 |
## Installation

For adding to a NetBox Docker setup see
Expand Down
4 changes: 2 additions & 2 deletions netbox_napalm_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Arthur Hanson"""
__email__ = "[email protected]"
__version__ = "0.1.4"
__version__ = "0.1.5"


from extras.plugins import PluginConfig
Expand All @@ -22,7 +22,7 @@ class NapalmPlatformConfig(PluginConfig):
'NAPALM_ARGS': {},
}
min_version = '3.5.0-dev'
max_version = '3.5.99'
max_version = '3.6.99'


config = NapalmPlatformConfig
19 changes: 10 additions & 9 deletions netbox_napalm_plugin/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ def napalm(self, request, pk):
)
if device.platform is None:
raise ServiceUnavailable("No platform is configured for this device.")
if (
not hasattr(device.platform, "napalm")
or not device.platform.napalm.napalm_driver
):
# Checks to see if NapalmPlatform object exists
if not NapalmPlatformConfig.objects.filter(platform=device.platform).exists():
raise ServiceUnavailable(
f"No NAPALM Platform Mapping is configured for this device's platform: {device.platform}."
)
if NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver == "":
raise ServiceUnavailable(
f"No NAPALM driver is configured for this device's platform: {device.platform}."
)
Expand Down Expand Up @@ -75,11 +77,11 @@ def napalm(self, request, pk):

# Validate the configured driver
try:
driver = napalm.get_network_driver(device.platform.napalm_driver)
driver = napalm.get_network_driver(NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver)
except ModuleImportError:
raise ServiceUnavailable(
"NAPALM driver for platform {} not found: {}.".format(
device.platform, device.platform.napalm_driver
device.platform, NapalmPlatformConfig.objects.get(platform=device.platform).napalm_driver
)
)

Expand All @@ -94,9 +96,8 @@ def napalm(self, request, pk):
password = get_plugin_config('netbox_napalm_plugin', 'NAPALM_PASSWORD')
timeout = get_plugin_config('netbox_napalm_plugin', 'NAPALM_TIMEOUT')
optional_args = get_plugin_config('netbox_napalm_plugin', 'NAPALM_ARGS').copy()
if device.platform.napalm_args is not None:
optional_args.update(device.platform.napalm_args)

if NapalmPlatformConfig.objects.get(platform=device.platform).napalm_args is not None:
optional_args.update(NapalmPlatformConfig.objects.get(platform=device.platform).napalm_args)
# Update NAPALM parameters according to the request headers
for header in request.headers:
if header[:9].lower() != "x-napalm-":
Expand Down
2 changes: 1 addition & 1 deletion netbox_napalm_plugin/project-static/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netbox_napalm_plugin",
"version": "0.1.4",
"version": "0.1.5",
"description": "Napalm Plugin for NetBox",
"main": "index.js",
"author": "Arthur Hanson",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ python =
3.8: py38, format, lint, build

[bumpversion]
current_version = 0.1.4
current_version = 0.1.5
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
packages=find_packages(include=['netbox_napalm_plugin', 'netbox_napalm_plugin.*']),
test_suite='tests',
url='https://github.com/netbox-community/netbox-napalm',
version='0.1.4',
version='0.1.5',
zip_safe=False,
)

0 comments on commit ea4c4de

Please sign in to comment.