modified: netbox_dns_bridge/navigation.py
new file: netbox_dns_bridge/templates/netbox_dns_bridge/catz_overview.html deleted: netbox_dns_bridge/templates/netbox_dns_bridge/info.html new file: netbox_dns_bridge/templates/netbox_dns_bridge/notify_overview.html modified: netbox_dns_bridge/urls.py modified: netbox_dns_bridge/views.py Extend views
This commit is contained in:
1 parent
60bc60ccc4
commit
9f71ff7332
6 files changed
+157
-112
No files matched your search
@@ -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",
|
||||
)
|
||||
@@ -0,0 +1,68 @@
|
||||
{% extends 'base/layout.html' %}
|
||||
|
||||
{% block title %}Catalog Zone Info{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Catalog Zone SOA Serial Number</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if soa_serial is not None %}
|
||||
<tr>
|
||||
<td>{{ soa_serial }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td class="text-muted">Not yet initialized.</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for view_name, rows in zones_grouped.items %}
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Zone Identifiers | {{ view_name }}</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zone</th>
|
||||
<th>Active</th>
|
||||
<th>Catalog Zone Identifier</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for z in rows %}
|
||||
<tr>
|
||||
<td>{{ z.name }}</td>
|
||||
<td>{{ z.active|yesno:"Yes,No" }}</td>
|
||||
<td>{{ z.catz_identifier|default:"—" }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan="3" class="text-muted">No zones in this view.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Zone Identifiers</h5>
|
||||
<div class="card-body">
|
||||
<p class="text-muted">No zones found.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,89 +0,0 @@
|
||||
{% 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 & 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 %}
|
||||
@@ -0,0 +1,37 @@
|
||||
{% extends 'base/layout.html' %}
|
||||
|
||||
{% block title %}DNS Bridge Notify{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<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>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -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"),
|
||||
]
|
||||
+37
-17
@@ -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)
|
||||
Reference in new issue
Block a user