Skip to content

Commit cbb1bcf

Browse files
authored
Updates for NetBox v4.0 (#34)
1 parent 072ce79 commit cbb1bcf

File tree

9 files changed

+122
-125
lines changed

9 files changed

+122
-125
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.2.0 (2024-05-06)
4+
5+
* For NetBox 4.0
6+
37
## 0.1.9 (2024-04-29)
48

59
* Fix js in distro

netbox_napalm_plugin/__init__.py

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

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

77

8-
from extras.plugins import PluginConfig
8+
from netbox.plugins import PluginConfig
99

1010

1111
class NapalmPlatformConfig(PluginConfig):
@@ -21,8 +21,8 @@ class NapalmPlatformConfig(PluginConfig):
2121
'NAPALM_TIMEOUT': 30,
2222
'NAPALM_ARGS': {},
2323
}
24-
min_version = '3.5.0-dev'
25-
max_version = '3.7.99'
24+
min_version = '4.0-beta1'
25+
max_version = '4.0.99'
2626

2727

2828
config = NapalmPlatformConfig

netbox_napalm_plugin/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dcim.models import Device
22
from django.shortcuts import get_object_or_404, redirect, render
3-
from extras.plugins.utils import get_plugin_config
3+
from netbox.plugins.utils import get_plugin_config
44
from netbox.api.exceptions import ServiceUnavailable
55
from netbox.api.pagination import StripCountAnnotationsPaginator
66
from netbox.api.viewsets import NetBoxModelViewSet

netbox_napalm_plugin/navigation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from extras.plugins import PluginMenuButton, PluginMenuItem
2-
from utilities.choices import ButtonColorChoices
1+
from netbox.plugins import PluginMenuButton, PluginMenuItem
32

43
plugin_buttons = [
54
PluginMenuButton(
65
link="plugins:netbox_napalm_plugin:napalmplatformconfig_add",
76
title="Add",
87
icon_class="mdi mdi-plus-thick",
9-
color=ButtonColorChoices.GREEN,
108
)
119
]
1210

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netbox_napalm_plugin",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "Napalm Plugin for NetBox",
55
"main": "index.js",
66
"author": "Arthur Hanson",
@@ -9,9 +9,13 @@
99
"build": "node build.mjs"
1010
},
1111
"dependencies": {
12-
"@popperjs/core": "^2.11.6",
13-
"bootstrap": "~5.0.2",
14-
"dayjs": "^1.11.5",
15-
"esbuild": "^0.17.8"
12+
"bootstrap": "~5.3.3",
13+
"dayjs": "^1.11.5"
14+
},
15+
"devDependencies": {
16+
"esbuild": "^0.13.15"
17+
},
18+
"resolutions": {
19+
"@types/bootstrap/**/@popperjs/core": "^2.11.6"
1620
}
1721
}

netbox_napalm_plugin/templates/netbox_napalm_plugin/lldp_neighbors.html

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,45 @@
1717
<div class="card-header">
1818
<h5 class="d-inline">LLDP Neighbors</h5>
1919
</div>
20-
<div class="card-body">
21-
<table class="table table-hover">
22-
<thead>
23-
<tr>
24-
<th>Interface</th>
25-
<th>Configured Device</th>
26-
<th>Configured Interface</th>
27-
<th>LLDP Device</th>
28-
<th>LLDP Interface</th>
29-
</tr>
30-
</thead>
31-
<tbody>
32-
{% for iface in interfaces %}
33-
<tr id="{{ iface.name }}">
34-
<td>{{ iface }}</td>
35-
{% with peer=iface.connected_endpoints.0 %}
36-
{% if peer.device %}
37-
<td class="configured_device" data="{{ peer.device.name }}" data-chassis="{{ peer.device.virtual_chassis.name }}">
38-
<a href="{% url 'dcim:device' pk=peer.device.pk %}">{{ peer.device }}</a>
39-
</td>
40-
<td class="configured_interface" data="{{ peer.name }}">
41-
<span title="{{ peer.get_type_display }}">{{ peer }}</span>
20+
<table class="table table-hover">
21+
<thead>
22+
<tr>
23+
<th>Interface</th>
24+
<th>Configured Device</th>
25+
<th>Configured Interface</th>
26+
<th>LLDP Device</th>
27+
<th>LLDP Interface</th>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
{% for iface in interfaces %}
32+
<tr id="{{ iface.name }}">
33+
<td>{{ iface }}</td>
34+
{% with peer=iface.connected_endpoints.0 %}
35+
{% if peer.device %}
36+
<td class="configured_device" data="{{ peer.device.name }}" data-chassis="{{ peer.device.virtual_chassis.name }}">
37+
<a href="{% url 'dcim:device' pk=peer.device.pk %}">{{ peer.device }}</a>
38+
</td>
39+
<td class="configured_interface" data="{{ peer.name }}">
40+
<span title="{{ peer.get_type_display }}">{{ peer }}</span>
41+
</td>
42+
{% elif peer.circuit %}
43+
{% with circuit=peer.circuit %}
44+
<td colspan="2">
45+
<i class="mdi mdi-lightning-bolt" title="Circuit"></i>
46+
<a href="{{ circuit.get_absolute_url }}">{{ circuit.provider }} {{ circuit }}</a>
4247
</td>
43-
{% elif peer.circuit %}
44-
{% with circuit=peer.circuit %}
45-
<td colspan="2">
46-
<i class="mdi mdi-lightning-bolt" title="Circuit"></i>
47-
<a href="{{ circuit.get_absolute_url }}">{{ circuit.provider }} {{ circuit }}</a>
48-
</td>
49-
{% endwith %}
50-
{% else %}
51-
<td class="text-muted" colspan="2">None</td>
52-
{% endif %}
53-
{% endwith %}
54-
<td class="device"></td>
55-
<td class="interface"></td>
56-
</tr>
57-
{% endfor %}
58-
</tbody>
59-
</table>
60-
</div>
48+
{% endwith %}
49+
{% else %}
50+
<td class="text-muted" colspan="2">None</td>
51+
{% endif %}
52+
{% endwith %}
53+
<td class="device"></td>
54+
<td class="interface"></td>
55+
</tr>
56+
{% endfor %}
57+
</tbody>
58+
</table>
6159
</div>
6260
{% endblock %}
6361

netbox_napalm_plugin/templates/netbox_napalm_plugin/napalmplatformconfig.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@
99

1010
<h5 class="card-header">NetBox Napalm Plugin</h5>
1111

12-
<div class="card-body">
13-
<table class="table table-hover attr-table">
14-
<tr>
15-
<th scope="row">Platform</th>
16-
<td>{{ object.platform|linkify|placeholder }}</td>
17-
</tr>
18-
<tr>
19-
<th scope="row">NAPALM Driver</th>
20-
<td>{{ object.napalm_driver|placeholder }}</td>
21-
</tr>
22-
</table>
23-
</div>
12+
<table class="table table-hover attr-table">
13+
<tr>
14+
<th scope="row">Platform</th>
15+
<td>{{ object.platform|linkify|placeholder }}</td>
16+
</tr>
17+
<tr>
18+
<th scope="row">NAPALM Driver</th>
19+
<td>{{ object.napalm_driver|placeholder }}</td>
20+
</tr>
21+
</table>
2422
</div>
2523
{% include 'inc/panels/tags.html' %}
2624
{% include 'inc/panels/custom_fields.html' %}

netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,39 @@
1717
</div>
1818
</div>
1919
<h5 class="card-header">Device Facts</h5>
20-
<div class="card-body">
21-
<table class="table">
22-
<tr>
23-
<th scope="row">Hostname</th>
24-
<td id="hostname"></td>
25-
</tr>
26-
<tr>
27-
<th scope="row">FQDN</th>
28-
<td id="fqdn"></td>
29-
</tr>
30-
<tr>
31-
<th scope="row">Vendor</th>
32-
<td id="vendor"></td>
33-
</tr>
34-
<tr>
35-
<th scope="row">Model</th>
36-
<td id="model"></td>
37-
</tr>
38-
<tr>
39-
<th scope="row">Serial Number</th>
40-
<td id="serial_number" class="text-monospace"></td>
41-
</tr>
42-
<tr>
43-
<th scope="row">OS Version</th>
44-
<td id="os_version"></td>
45-
</tr>
46-
<tr class="align-middle">
47-
<th scope="row">Uptime</th>
48-
<td>
49-
<div id="uptime-duration"></div>
50-
<div id="uptime" class="small text-muted"></div>
51-
</td>
52-
</tr>
53-
</table>
54-
</div>
20+
<table class="table">
21+
<tr>
22+
<th scope="row">Hostname</th>
23+
<td id="hostname"></td>
24+
</tr>
25+
<tr>
26+
<th scope="row">FQDN</th>
27+
<td id="fqdn"></td>
28+
</tr>
29+
<tr>
30+
<th scope="row">Vendor</th>
31+
<td id="vendor"></td>
32+
</tr>
33+
<tr>
34+
<th scope="row">Model</th>
35+
<td id="model"></td>
36+
</tr>
37+
<tr>
38+
<th scope="row">Serial Number</th>
39+
<td id="serial_number" class="text-monospace"></td>
40+
</tr>
41+
<tr>
42+
<th scope="row">OS Version</th>
43+
<td id="os_version"></td>
44+
</tr>
45+
<tr class="align-middle">
46+
<th scope="row">Uptime</th>
47+
<td>
48+
<div id="uptime-duration"></div>
49+
<div id="uptime" class="small text-muted"></div>
50+
</td>
51+
</tr>
52+
</table>
5553
</div>
5654
</div>
5755
<div class="col col-md-6">
@@ -62,27 +60,25 @@ <h5 class="card-header">Device Facts</h5>
6260
</div>
6361
</div>
6462
<h5 class="card-header">Environment</h5>
65-
<div class="card-body">
66-
<table class="table">
67-
<tr id="status-cpu">
68-
<th colspan="2"><i class="mdi mdi-gauge"></i> CPU</th>
69-
</tr>
70-
<tr id="status-memory">
71-
<th colspan="2"><i class="mdi mdi-chip"></i> Memory</th>
72-
</tr>
73-
<tr id="status-temperature">
74-
<th colspan="2"><i class="mdi mdi-thermometer"></i> Temperature</th>
75-
</tr>
76-
<tr id="status-fans">
77-
<th colspan="2"><i class="mdi mdi-fan"></i> Fans</th>
78-
</tr>
79-
<tr id="status-power">
80-
<th colspan="2"><i class="mdi mdi-power"></i> Power</th>
81-
</tr>
82-
<tr class="napalm-table-placeholder d-none invisible">
83-
</tr>
84-
</table>
85-
</div>
63+
<table class="table">
64+
<tr id="status-cpu">
65+
<th colspan="2"><i class="mdi mdi-gauge"></i> CPU</th>
66+
</tr>
67+
<tr id="status-memory">
68+
<th colspan="2"><i class="mdi mdi-chip"></i> Memory</th>
69+
</tr>
70+
<tr id="status-temperature">
71+
<th colspan="2"><i class="mdi mdi-thermometer"></i> Temperature</th>
72+
</tr>
73+
<tr id="status-fans">
74+
<th colspan="2"><i class="mdi mdi-fan"></i> Fans</th>
75+
</tr>
76+
<tr id="status-power">
77+
<th colspan="2"><i class="mdi mdi-power"></i> Power</th>
78+
</tr>
79+
<tr class="napalm-table-placeholder d-none invisible">
80+
</tr>
81+
</table>
8682
</div>
8783
</div>
8884
</div>

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "netbox-napalm-plugin"
10-
version = "0.1.9"
10+
version = "0.2.0"
1111
authors = [
1212
{name = "Arthur Hanson", email = "[email protected]"},
1313
]
@@ -19,13 +19,12 @@ classifiers=[
1919
'Intended Audience :: Developers',
2020
'Natural Language :: English',
2121
"Programming Language :: Python :: 3 :: Only",
22-
'Programming Language :: Python :: 3.9',
2322
'Programming Language :: Python :: 3.10',
2423
'Programming Language :: Python :: 3.11',
2524
'Programming Language :: Python :: 3.12',
2625
]
2726

28-
requires-python = ">=3.8.1"
27+
requires-python = ">=3.10.0"
2928
dependencies = [
3029
'napalm<5.0'
3130
]
@@ -47,7 +46,7 @@ Tracker = "https://github.com/netbox-community/netbox-napalm-plugin/issues"
4746

4847
[tool.black]
4948
line-length = 120
50-
target_version = ['py39', 'py310', 'py311', 'py312']
49+
target_version = ['py310', 'py311', 'py312']
5150

5251
[tool.setuptools.package-data]
5352
netbox_napalm_plugin = ["templates/**"]

0 commit comments

Comments
 (0)