Skip to content

Commit

Permalink
Updates for NetBox v4.0 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson committed May 6, 2024
1 parent 072ce79 commit cbb1bcf
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 125 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.2.0 (2024-05-06)

* For NetBox 4.0

## 0.1.9 (2024-04-29)

* Fix js in distro
Expand Down
8 changes: 4 additions & 4 deletions netbox_napalm_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

__author__ = """Arthur Hanson"""
__email__ = "[email protected]"
__version__ = "0.1.9"
__version__ = "0.2.0"


from extras.plugins import PluginConfig
from netbox.plugins import PluginConfig


class NapalmPlatformConfig(PluginConfig):
Expand All @@ -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
2 changes: 1 addition & 1 deletion netbox_napalm_plugin/api/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions netbox_napalm_plugin/navigation.py
Original file line number Diff line number Diff line change
@@ -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,
)
]

Expand Down
14 changes: 9 additions & 5 deletions 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.9",
"version": "0.2.0",
"description": "Napalm Plugin for NetBox",
"main": "index.js",
"author": "Arthur Hanson",
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,45 @@
<div class="card-header">
<h5 class="d-inline">LLDP Neighbors</h5>
</div>
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>Interface</th>
<th>Configured Device</th>
<th>Configured Interface</th>
<th>LLDP Device</th>
<th>LLDP Interface</th>
</tr>
</thead>
<tbody>
{% for iface in interfaces %}
<tr id="{{ iface.name }}">
<td>{{ iface }}</td>
{% with peer=iface.connected_endpoints.0 %}
{% if peer.device %}
<td class="configured_device" data="{{ peer.device.name }}" data-chassis="{{ peer.device.virtual_chassis.name }}">
<a href="{% url 'dcim:device' pk=peer.device.pk %}">{{ peer.device }}</a>
</td>
<td class="configured_interface" data="{{ peer.name }}">
<span title="{{ peer.get_type_display }}">{{ peer }}</span>
<table class="table table-hover">
<thead>
<tr>
<th>Interface</th>
<th>Configured Device</th>
<th>Configured Interface</th>
<th>LLDP Device</th>
<th>LLDP Interface</th>
</tr>
</thead>
<tbody>
{% for iface in interfaces %}
<tr id="{{ iface.name }}">
<td>{{ iface }}</td>
{% with peer=iface.connected_endpoints.0 %}
{% if peer.device %}
<td class="configured_device" data="{{ peer.device.name }}" data-chassis="{{ peer.device.virtual_chassis.name }}">
<a href="{% url 'dcim:device' pk=peer.device.pk %}">{{ peer.device }}</a>
</td>
<td class="configured_interface" data="{{ peer.name }}">
<span title="{{ peer.get_type_display }}">{{ peer }}</span>
</td>
{% elif peer.circuit %}
{% with circuit=peer.circuit %}
<td colspan="2">
<i class="mdi mdi-lightning-bolt" title="Circuit"></i>
<a href="{{ circuit.get_absolute_url }}">{{ circuit.provider }} {{ circuit }}</a>
</td>
{% elif peer.circuit %}
{% with circuit=peer.circuit %}
<td colspan="2">
<i class="mdi mdi-lightning-bolt" title="Circuit"></i>
<a href="{{ circuit.get_absolute_url }}">{{ circuit.provider }} {{ circuit }}</a>
</td>
{% endwith %}
{% else %}
<td class="text-muted" colspan="2">None</td>
{% endif %}
{% endwith %}
<td class="device"></td>
<td class="interface"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endwith %}
{% else %}
<td class="text-muted" colspan="2">None</td>
{% endif %}
{% endwith %}
<td class="device"></td>
<td class="interface"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@

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

<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Platform</th>
<td>{{ object.platform|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">NAPALM Driver</th>
<td>{{ object.napalm_driver|placeholder }}</td>
</tr>
</table>
</div>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Platform</th>
<td>{{ object.platform|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">NAPALM Driver</th>
<td>{{ object.napalm_driver|placeholder }}</td>
</tr>
</table>
</div>
{% include 'inc/panels/tags.html' %}
{% include 'inc/panels/custom_fields.html' %}
Expand Down
108 changes: 52 additions & 56 deletions netbox_napalm_plugin/templates/netbox_napalm_plugin/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,39 @@
</div>
</div>
<h5 class="card-header">Device Facts</h5>
<div class="card-body">
<table class="table">
<tr>
<th scope="row">Hostname</th>
<td id="hostname"></td>
</tr>
<tr>
<th scope="row">FQDN</th>
<td id="fqdn"></td>
</tr>
<tr>
<th scope="row">Vendor</th>
<td id="vendor"></td>
</tr>
<tr>
<th scope="row">Model</th>
<td id="model"></td>
</tr>
<tr>
<th scope="row">Serial Number</th>
<td id="serial_number" class="text-monospace"></td>
</tr>
<tr>
<th scope="row">OS Version</th>
<td id="os_version"></td>
</tr>
<tr class="align-middle">
<th scope="row">Uptime</th>
<td>
<div id="uptime-duration"></div>
<div id="uptime" class="small text-muted"></div>
</td>
</tr>
</table>
</div>
<table class="table">
<tr>
<th scope="row">Hostname</th>
<td id="hostname"></td>
</tr>
<tr>
<th scope="row">FQDN</th>
<td id="fqdn"></td>
</tr>
<tr>
<th scope="row">Vendor</th>
<td id="vendor"></td>
</tr>
<tr>
<th scope="row">Model</th>
<td id="model"></td>
</tr>
<tr>
<th scope="row">Serial Number</th>
<td id="serial_number" class="text-monospace"></td>
</tr>
<tr>
<th scope="row">OS Version</th>
<td id="os_version"></td>
</tr>
<tr class="align-middle">
<th scope="row">Uptime</th>
<td>
<div id="uptime-duration"></div>
<div id="uptime" class="small text-muted"></div>
</td>
</tr>
</table>
</div>
</div>
<div class="col col-md-6">
Expand All @@ -62,27 +60,25 @@ <h5 class="card-header">Device Facts</h5>
</div>
</div>
<h5 class="card-header">Environment</h5>
<div class="card-body">
<table class="table">
<tr id="status-cpu">
<th colspan="2"><i class="mdi mdi-gauge"></i> CPU</th>
</tr>
<tr id="status-memory">
<th colspan="2"><i class="mdi mdi-chip"></i> Memory</th>
</tr>
<tr id="status-temperature">
<th colspan="2"><i class="mdi mdi-thermometer"></i> Temperature</th>
</tr>
<tr id="status-fans">
<th colspan="2"><i class="mdi mdi-fan"></i> Fans</th>
</tr>
<tr id="status-power">
<th colspan="2"><i class="mdi mdi-power"></i> Power</th>
</tr>
<tr class="napalm-table-placeholder d-none invisible">
</tr>
</table>
</div>
<table class="table">
<tr id="status-cpu">
<th colspan="2"><i class="mdi mdi-gauge"></i> CPU</th>
</tr>
<tr id="status-memory">
<th colspan="2"><i class="mdi mdi-chip"></i> Memory</th>
</tr>
<tr id="status-temperature">
<th colspan="2"><i class="mdi mdi-thermometer"></i> Temperature</th>
</tr>
<tr id="status-fans">
<th colspan="2"><i class="mdi mdi-fan"></i> Fans</th>
</tr>
<tr id="status-power">
<th colspan="2"><i class="mdi mdi-power"></i> Power</th>
</tr>
<tr class="napalm-table-placeholder d-none invisible">
</tr>
</table>
</div>
</div>
</div>
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"},
]
Expand All @@ -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'
]
Expand All @@ -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/**"]

0 comments on commit cbb1bcf

Please sign in to comment.