From ea1103a35617d64eef61f231a37b3220a2768ddc Mon Sep 17 00:00:00 2001 From: Sven Luethi Date: Tue, 11 Aug 2026 14:47:37 +0200 Subject: [PATCH] modified: netbox_dns_bridge/__init__.py new file: netbox_dns_bridge/navigation.py new file: netbox_dns_bridge/templates/netbox_dns_bridge/info.html new file: netbox_dns_bridge/urls.py new file: netbox_dns_bridge/views.py Add information view --- netbox_dns_bridge/__init__.py | 1 + netbox_dns_bridge/navigation.py | 16 ++++ .../templates/netbox_dns_bridge/info.html | 89 +++++++++++++++++++ netbox_dns_bridge/urls.py | 7 ++ netbox_dns_bridge/views.py | 43 +++++++++ 5 files changed, 156 insertions(+) create mode 100644 netbox_dns_bridge/navigation.py create mode 100644 netbox_dns_bridge/templates/netbox_dns_bridge/info.html create mode 100644 netbox_dns_bridge/urls.py create mode 100644 netbox_dns_bridge/views.py diff --git a/netbox_dns_bridge/__init__.py b/netbox_dns_bridge/__init__.py index 4c9b09c..a229f08 100644 --- a/netbox_dns_bridge/__init__.py +++ b/netbox_dns_bridge/__init__.py @@ -17,6 +17,7 @@ class DNSBridgeConfig(PluginConfig): base_url = "dns-bridge" def ready(self): + super().ready() self.settings = settings.PLUGINS_CONFIG.get(self.name, None) if not self.settings: raise RuntimeError( diff --git a/netbox_dns_bridge/navigation.py b/netbox_dns_bridge/navigation.py new file mode 100644 index 0000000..747a952 --- /dev/null +++ b/netbox_dns_bridge/navigation.py @@ -0,0 +1,16 @@ +from django.utils.translation import gettext_lazy as _ +from netbox.plugins import PluginMenu, PluginMenuItem + +info_menu_item = PluginMenuItem( + link="plugins:netbox_dns_bridge:info", + link_text=_("Info"), + permissions=[], +) + +menu = PluginMenu( + label=_("DNS Bridge"), + groups=( + (_("Information"), (info_menu_item,)), + ), + icon_class="mdi mdi-bridge", +) diff --git a/netbox_dns_bridge/templates/netbox_dns_bridge/info.html b/netbox_dns_bridge/templates/netbox_dns_bridge/info.html new file mode 100644 index 0000000..515d469 --- /dev/null +++ b/netbox_dns_bridge/templates/netbox_dns_bridge/info.html @@ -0,0 +1,89 @@ +{% extends 'base/layout.html' %} + +{% block title %}DNS Bridge Info{% endblock %} + +{% block content %} +
+
+ +
+
Integer Key-Value Settings
+
+ + + + + + + + + {% for s in settings_rows %} + + + + + {% empty %} + + {% endfor %} + +
KeyValue
{{ s.key }}{{ s.value }}
No settings found.
+
+
+ +
+
Seen Transfer Clients
+
+ + + + + + + + + + {% for c in seen_clients %} + + + + + + {% empty %} + + {% endfor %} + +
Source IPViewLast Seen
{{ c.source_ip }}{{ c.view.name }}{{ c.last_seen|date:"Y-m-d H:i:s" }}
No seen transfer clients.
+
+
+ +
+
Zones & Catalog Zone Identifiers
+
+ + + + + + + + + + + {% for z in zones %} + + + + + + + {% empty %} + + {% endfor %} + +
ZoneViewActiveCatalog Zone Identifier
{{ z.name }}{{ z.view|default:"—" }}{{ z.active|yesno:"Yes,No" }}{{ z.catz_identifier|default:"—" }}
No zones found.
+
+
+ +
+
+{% endblock %} diff --git a/netbox_dns_bridge/urls.py b/netbox_dns_bridge/urls.py new file mode 100644 index 0000000..96b293c --- /dev/null +++ b/netbox_dns_bridge/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from .views import InfoView + +urlpatterns = [ + path("info/", InfoView.as_view(), name="info"), +] diff --git a/netbox_dns_bridge/views.py b/netbox_dns_bridge/views.py new file mode 100644 index 0000000..830da2c --- /dev/null +++ b/netbox_dns_bridge/views.py @@ -0,0 +1,43 @@ +from django.views import View +from django.shortcuts import render + +from .models import IntegerKeyValueSetting, SeenTransferClients + + +class InfoView(View): + template_name = "netbox_dns_bridge/info.html" + + def get(self, request): + import netbox_dns.models + + settings_rows = IntegerKeyValueSetting.objects.all().order_by("key") + + seen_clients = ( + SeenTransferClients.objects.select_related("view") + .all() + .order_by("source_ip") + ) + + zones = [] + for z in netbox_dns.models.Zone.objects.select_related( + "view", "catz_identifier" + ).order_by("name"): + try: + catz_identifier = z.catz_identifier.name + except netbox_dns.models.Zone.catz_identifier.RelatedObjectDoesNotExist: + catz_identifier = None + zones.append( + { + "name": z.name, + "view": z.view.name if z.view else None, + "active": z.active, + "catz_identifier": catz_identifier, + } + ) + + context = { + "settings_rows": settings_rows, + "seen_clients": seen_clients, + "zones": zones, + } + return render(request, self.template_name, context)