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
This commit is contained in:
Sven Luethi authored and Sven Luthi committed 2026-08-11 18:30:00 +02:00
1 parent 512dc6b247
commit 0ac23ff3a0
5 files changed
+156

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ class DNSBridgeConfig(PluginConfig):
base_url = "dns-bridge" base_url = "dns-bridge"
def ready(self): def ready(self):
super().ready()
self.settings = settings.PLUGINS_CONFIG.get(self.name, None) self.settings = settings.PLUGINS_CONFIG.get(self.name, None)
if not self.settings: if not self.settings:
raise RuntimeError( raise RuntimeError(
+16
View File
@@ -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",
)
@@ -0,0 +1,89 @@
{% extends 'base/layout.html' %}
{% block title %}DNS Bridge Info{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="card mb-3">
<h5 class="card-header">Integer Key-Value Settings</h5>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for s in settings_rows %}
<tr>
<td>{{ s.key }}</td>
<td>{{ s.value }}</td>
</tr>
{% empty %}
<tr><td colspan="2" class="text-muted">No settings found.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card mb-3">
<h5 class="card-header">Seen Transfer Clients</h5>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Source IP</th>
<th>View</th>
<th>Last Seen</th>
</tr>
</thead>
<tbody>
{% for c in seen_clients %}
<tr>
<td>{{ c.source_ip }}</td>
<td>{{ c.view.name }}</td>
<td>{{ c.last_seen|date:"Y-m-d H:i:s" }}</td>
</tr>
{% empty %}
<tr><td colspan="3" class="text-muted">No seen transfer clients.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card mb-3">
<h5 class="card-header">Zones &amp; Catalog Zone Identifiers</h5>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Zone</th>
<th>View</th>
<th>Active</th>
<th>Catalog Zone Identifier</th>
</tr>
</thead>
<tbody>
{% for z in zones %}
<tr>
<td>{{ z.name }}</td>
<td>{{ z.view|default:"—" }}</td>
<td>{{ z.active|yesno:"Yes,No" }}</td>
<td>{{ z.catz_identifier|default:"—" }}</td>
</tr>
{% empty %}
<tr><td colspan="4" class="text-muted">No zones found.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
+7
View File
@@ -0,0 +1,7 @@
from django.urls import path
from .views import InfoView
urlpatterns = [
path("info/", InfoView.as_view(), name="info"),
]
+43
View File
@@ -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)