diff --git a/netbox_dns_bridge/navigation.py b/netbox_dns_bridge/navigation.py
index 747a952..79a8ae4 100644
--- a/netbox_dns_bridge/navigation.py
+++ b/netbox_dns_bridge/navigation.py
@@ -1,16 +1,24 @@
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"),
+information_menu_item = PluginMenuItem(
+ link="plugins:netbox_dns_bridge:catz",
+ link_text=_("Catalog Zones"),
permissions=[],
+ staff_only=True,
+)
+
+notify_menu_item = PluginMenuItem(
+ link="plugins:netbox_dns_bridge:notify",
+ link_text=_("Notify"),
+ permissions=[],
+ staff_only=True,
)
menu = PluginMenu(
label=_("DNS Bridge"),
groups=(
- (_("Information"), (info_menu_item,)),
+ (_("Information"), (information_menu_item, notify_menu_item)),
),
icon_class="mdi mdi-bridge",
)
diff --git a/netbox_dns_bridge/templates/netbox_dns_bridge/catz_overview.html b/netbox_dns_bridge/templates/netbox_dns_bridge/catz_overview.html
new file mode 100644
index 0000000..fe2554b
--- /dev/null
+++ b/netbox_dns_bridge/templates/netbox_dns_bridge/catz_overview.html
@@ -0,0 +1,68 @@
+{% extends 'base/layout.html' %}
+
+{% block title %}Catalog Zone Info{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+ | Value |
+
+
+
+ {% if soa_serial is not None %}
+
+ | {{ soa_serial }} |
+
+ {% else %}
+ | Not yet initialized. |
+ {% endif %}
+
+
+
+
+
+ {% for view_name, rows in zones_grouped.items %}
+
+
+
+
+
+
+ | Zone |
+ Active |
+ Catalog Zone Identifier |
+
+
+
+ {% for z in rows %}
+
+ | {{ z.name }} |
+ {{ z.active|yesno:"Yes,No" }} |
+ {{ z.catz_identifier|default:"—" }} |
+
+ {% empty %}
+ | No zones in this view. |
+ {% endfor %}
+
+
+
+
+ {% empty %}
+
+ {% endfor %}
+
+
+
+{% endblock %}
diff --git a/netbox_dns_bridge/templates/netbox_dns_bridge/info.html b/netbox_dns_bridge/templates/netbox_dns_bridge/info.html
deleted file mode 100644
index 515d469..0000000
--- a/netbox_dns_bridge/templates/netbox_dns_bridge/info.html
+++ /dev/null
@@ -1,89 +0,0 @@
-{% extends 'base/layout.html' %}
-
-{% block title %}DNS Bridge Info{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
- | Key |
- Value |
-
-
-
- {% for s in settings_rows %}
-
- | {{ s.key }} |
- {{ s.value }} |
-
- {% empty %}
- | No settings found. |
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
- | Source IP |
- View |
- Last Seen |
-
-
-
- {% for c in seen_clients %}
-
- | {{ c.source_ip }} |
- {{ c.view.name }} |
- {{ c.last_seen|date:"Y-m-d H:i:s" }} |
-
- {% empty %}
- | No seen transfer clients. |
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
- | Zone |
- View |
- Active |
- Catalog Zone Identifier |
-
-
-
- {% for z in zones %}
-
- | {{ z.name }} |
- {{ z.view|default:"—" }} |
- {{ z.active|yesno:"Yes,No" }} |
- {{ z.catz_identifier|default:"—" }} |
-
- {% empty %}
- | No zones found. |
- {% endfor %}
-
-
-
-
-
-
-
-{% endblock %}
diff --git a/netbox_dns_bridge/templates/netbox_dns_bridge/notify_overview.html b/netbox_dns_bridge/templates/netbox_dns_bridge/notify_overview.html
new file mode 100644
index 0000000..78c6a44
--- /dev/null
+++ b/netbox_dns_bridge/templates/netbox_dns_bridge/notify_overview.html
@@ -0,0 +1,37 @@
+{% extends 'base/layout.html' %}
+
+{% block title %}DNS Bridge Notify{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+ | Source IP |
+ View |
+ Last Seen |
+
+
+
+ {% for c in seen_clients %}
+
+ | {{ c.source_ip }} |
+ {{ c.view.name }} |
+ {{ c.last_seen|date:"Y-m-d H:i:s" }} |
+
+ {% empty %}
+ | No seen transfer clients. |
+ {% endfor %}
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/netbox_dns_bridge/urls.py b/netbox_dns_bridge/urls.py
index 96b293c..207211c 100644
--- a/netbox_dns_bridge/urls.py
+++ b/netbox_dns_bridge/urls.py
@@ -1,7 +1,8 @@
from django.urls import path
-from .views import InfoView
+from .views import CatzOverviewView, NotifyOverviewView
urlpatterns = [
- path("info/", InfoView.as_view(), name="info"),
+ path("catz/", CatzOverviewView.as_view(), name="catz"),
+ path("notify/", NotifyOverviewView.as_view(), name="notify"),
]
diff --git a/netbox_dns_bridge/views.py b/netbox_dns_bridge/views.py
index 830da2c..95834eb 100644
--- a/netbox_dns_bridge/views.py
+++ b/netbox_dns_bridge/views.py
@@ -1,43 +1,63 @@
-from django.views import View
+from collections import OrderedDict
+
+from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render
+from django.utils.decorators import method_decorator
+from django.views import View
from .models import IntegerKeyValueSetting, SeenTransferClients
-class InfoView(View):
- template_name = "netbox_dns_bridge/info.html"
+@method_decorator(
+ user_passes_test(lambda u: u.is_superuser), name="dispatch"
+)
+class CatzOverviewView(View):
+ template_name = "netbox_dns_bridge/catz_overview.html"
def get(self, request):
import netbox_dns.models
- settings_rows = IntegerKeyValueSetting.objects.all().order_by("key")
+ soa_serial_obj = IntegerKeyValueSetting.objects.filter(
+ key="catalog-zone-soa-serial"
+ ).first()
+ soa_serial = soa_serial_obj.value if soa_serial_obj else None
- seen_clients = (
- SeenTransferClients.objects.select_related("view")
- .all()
- .order_by("source_ip")
- )
-
- zones = []
+ zones_grouped = OrderedDict()
for z in netbox_dns.models.Zone.objects.select_related(
"view", "catz_identifier"
- ).order_by("name"):
+ ).order_by("view__name", "name"):
+ view_name = z.view.name if z.view else ""
+ view_display = view_name[0].upper() + view_name[1:] if view_name else ""
try:
catz_identifier = z.catz_identifier.name
except netbox_dns.models.Zone.catz_identifier.RelatedObjectDoesNotExist:
catz_identifier = None
- zones.append(
+ zones_grouped.setdefault(view_display, []).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,
+ "soa_serial": soa_serial,
+ "zones_grouped": zones_grouped,
}
return render(request, self.template_name, context)
+
+
+@method_decorator(
+ user_passes_test(lambda u: u.is_superuser), name="dispatch"
+)
+class NotifyOverviewView(View):
+ template_name = "netbox_dns_bridge/notify_overview.html"
+
+ def get(self, request):
+ seen_clients = (
+ SeenTransferClients.objects.select_related("view")
+ .all()
+ .order_by("source_ip")
+ )
+ context = {"seen_clients": seen_clients}
+ return render(request, self.template_name, context)