From cbb1bcffd732c664f7df5ec446e416b32e027322 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Mon, 6 May 2024 12:34:04 -0700 Subject: [PATCH] Updates for NetBox v4.0 (#34) --- CHANGELOG.md | 4 + netbox_napalm_plugin/__init__.py | 8 +- netbox_napalm_plugin/api/views.py | 2 +- netbox_napalm_plugin/navigation.py | 4 +- .../project-static/package.json | 14 ++- .../netbox_napalm_plugin/lldp_neighbors.html | 78 ++++++------- .../napalmplatformconfig.html | 22 ++-- .../netbox_napalm_plugin/status.html | 108 +++++++++--------- pyproject.toml | 7 +- 9 files changed, 122 insertions(+), 125 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c0179c..a113d63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.2.0 (2024-05-06) + +* For NetBox 4.0 + ## 0.1.9 (2024-04-29) * Fix js in distro diff --git a/netbox_napalm_plugin/__init__.py b/netbox_napalm_plugin/__init__.py index 5f0c91b..71d870a 100644 --- a/netbox_napalm_plugin/__init__.py +++ b/netbox_napalm_plugin/__init__.py @@ -2,10 +2,10 @@ __author__ = """Arthur Hanson""" __email__ = "ahanson@netboxlabs.com" -__version__ = "0.1.9" +__version__ = "0.2.0" -from extras.plugins import PluginConfig +from netbox.plugins import PluginConfig class NapalmPlatformConfig(PluginConfig): @@ -21,8 +21,8 @@ class NapalmPlatformConfig(PluginConfig): 'NAPALM_TIMEOUT': 30, 'NAPALM_ARGS': {}, } - min_version = '3.5.0-dev' - max_version = '3.7.99' + min_version = '4.0-beta1' + max_version = '4.0.99' config = NapalmPlatformConfig diff --git a/netbox_napalm_plugin/api/views.py b/netbox_napalm_plugin/api/views.py index 5c13f0a..35cc09b 100644 --- a/netbox_napalm_plugin/api/views.py +++ b/netbox_napalm_plugin/api/views.py @@ -1,6 +1,6 @@ from dcim.models import Device from django.shortcuts import get_object_or_404, redirect, render -from extras.plugins.utils import get_plugin_config +from netbox.plugins.utils import get_plugin_config from netbox.api.exceptions import ServiceUnavailable from netbox.api.pagination import StripCountAnnotationsPaginator from netbox.api.viewsets import NetBoxModelViewSet diff --git a/netbox_napalm_plugin/navigation.py b/netbox_napalm_plugin/navigation.py index 53de5a8..4c3f230 100644 --- a/netbox_napalm_plugin/navigation.py +++ b/netbox_napalm_plugin/navigation.py @@ -1,12 +1,10 @@ -from extras.plugins import PluginMenuButton, PluginMenuItem -from utilities.choices import ButtonColorChoices +from netbox.plugins import PluginMenuButton, PluginMenuItem plugin_buttons = [ PluginMenuButton( link="plugins:netbox_napalm_plugin:napalmplatformconfig_add", title="Add", icon_class="mdi mdi-plus-thick", - color=ButtonColorChoices.GREEN, ) ] diff --git a/netbox_napalm_plugin/project-static/package.json b/netbox_napalm_plugin/project-static/package.json index 639fa6b..c5073b3 100644 --- a/netbox_napalm_plugin/project-static/package.json +++ b/netbox_napalm_plugin/project-static/package.json @@ -1,6 +1,6 @@ { "name": "netbox_napalm_plugin", - "version": "0.1.9", + "version": "0.2.0", "description": "Napalm Plugin for NetBox", "main": "index.js", "author": "Arthur Hanson", @@ -9,9 +9,13 @@ "build": "node build.mjs" }, "dependencies": { - "@popperjs/core": "^2.11.6", - "bootstrap": "~5.0.2", - "dayjs": "^1.11.5", - "esbuild": "^0.17.8" + "bootstrap": "~5.3.3", + "dayjs": "^1.11.5" + }, + "devDependencies": { + "esbuild": "^0.13.15" + }, + "resolutions": { + "@types/bootstrap/**/@popperjs/core": "^2.11.6" } } diff --git a/netbox_napalm_plugin/templates/netbox_napalm_plugin/lldp_neighbors.html b/netbox_napalm_plugin/templates/netbox_napalm_plugin/lldp_neighbors.html index 6f661e4..d03efd9 100644 --- a/netbox_napalm_plugin/templates/netbox_napalm_plugin/lldp_neighbors.html +++ b/netbox_napalm_plugin/templates/netbox_napalm_plugin/lldp_neighbors.html @@ -17,47 +17,45 @@
LLDP Neighbors
-
- - - - - - - - - - - - {% for iface in interfaces %} - - - {% with peer=iface.connected_endpoints.0 %} - {% if peer.device %} - - + {% endif %} + {% endwith %} + + + + {% endfor %} + +
InterfaceConfigured DeviceConfigured InterfaceLLDP DeviceLLDP Interface
{{ iface }} - {{ peer.device }} - - {{ peer }} + + + + + + + + + + + + {% for iface in interfaces %} + + + {% with peer=iface.connected_endpoints.0 %} + {% if peer.device %} + + + {% elif peer.circuit %} + {% with circuit=peer.circuit %} + - {% elif peer.circuit %} - {% with circuit=peer.circuit %} - - {% endwith %} - {% else %} - - {% endif %} - {% endwith %} - - - - {% endfor %} - -
InterfaceConfigured DeviceConfigured InterfaceLLDP DeviceLLDP Interface
{{ iface }} + {{ peer.device }} + + {{ peer }} + + + {{ circuit.provider }} {{ circuit }} - - {{ circuit.provider }} {{ circuit }} - None
- + {% endwith %} + {% else %} +
None
{% endblock %} diff --git a/netbox_napalm_plugin/templates/netbox_napalm_plugin/napalmplatformconfig.html b/netbox_napalm_plugin/templates/netbox_napalm_plugin/napalmplatformconfig.html index c0c257c..b10c1d6 100644 --- a/netbox_napalm_plugin/templates/netbox_napalm_plugin/napalmplatformconfig.html +++ b/netbox_napalm_plugin/templates/netbox_napalm_plugin/napalmplatformconfig.html @@ -9,18 +9,16 @@
NetBox Napalm Plugin
-
- - - - - - - - - -
Platform{{ object.platform|linkify|placeholder }}
NAPALM Driver{{ object.napalm_driver|placeholder }}
-
+ + + + + + + + + +
Platform{{ object.platform|linkify|placeholder }}
NAPALM Driver{{ object.napalm_driver|placeholder }}
{% include 'inc/panels/tags.html' %} {% include 'inc/panels/custom_fields.html' %} diff --git a/netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html b/netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html index 16c2b43..0f4cd12 100644 --- a/netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html +++ b/netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html @@ -17,41 +17,39 @@
Device Facts
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Hostname
FQDN
Vendor
Model
Serial Number
OS Version
Uptime -
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Hostname
FQDN
Vendor
Model
Serial Number
OS Version
Uptime +
+
+
@@ -62,27 +60,25 @@
Device Facts
Environment
-
- - - - - - - - - - - - - - - - - - -
CPU
Memory
Temperature
Fans
Power
-
+ + + + + + + + + + + + + + + + + + +
CPU
Memory
Temperature
Fans
Power
diff --git a/pyproject.toml b/pyproject.toml index 454ca22..0fd688c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-napalm-plugin" -version = "0.1.9" +version = "0.2.0" authors = [ {name = "Arthur Hanson", email = "ahanson@netboxlabs.com"}, ] @@ -19,13 +19,12 @@ classifiers=[ 'Intended Audience :: Developers', 'Natural Language :: English', "Programming Language :: Python :: 3 :: Only", - 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', ] -requires-python = ">=3.8.1" +requires-python = ">=3.10.0" dependencies = [ 'napalm<5.0' ] @@ -47,7 +46,7 @@ Tracker = "https://github.com/netbox-community/netbox-napalm-plugin/issues" [tool.black] line-length = 120 -target_version = ['py39', 'py310', 'py311', 'py312'] +target_version = ['py310', 'py311', 'py312'] [tool.setuptools.package-data] netbox_napalm_plugin = ["templates/**"]