feat: wireless links in topology, own top-level navigation menu

Interfaces with a WirelessLink are now traced like cables; wireless-only
connections are drawn blue and dotted with a "Funk" label, also in the
location overviews (counted as "1× Funk"). The plugin gets its own
"Kunden-Export" menu with icon in the main navigation instead of the
Plugins dropdown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-16 13:14:16 +01:00
1 parent d7c86289b1
commit 174a41e838
7 files changed
+71 -25

No files matched your search

+4 -3
View File
@@ -39,7 +39,7 @@ All queries respect NetBox permissions (`.restrict(user, "view")`) — a
technician only exports what they are allowed to see.
Open it via the **Customer Docs** button on site, location, tenant and tenant
group pages, or via **Plugins → Customer Documentation**. Output formats:
group pages, or via **Customer Export → Customer Documentation** in the main navigation. Output formats:
**PDF**, **Word** and **HTML preview** (opens in a new tab).
## Compatibility
@@ -182,7 +182,7 @@ sudo systemctl restart netbox netbox-rq
### Branding in NetBox (recommended)
Under **Plugins → Branding profiles**, admins create design profiles directly in NetBox:
Under **Customer Export → Branding Profiles**, admins create design profiles directly in NetBox:
- name, company name, footer and **logo upload** (PNG/JPG)
- colours via colour picker: primary, accent, table header text, labels, zebra stripes
@@ -262,10 +262,11 @@ style of Cisco Packet Tracer:
- The **cross-site location overview** puts all locations of all sites in scope into **one diagram**; each node shows its site (and parent location), so you can see how buildings and their locations are connected to each other.
- Each topology gets its **own landscape page** (PDF and Word) and is scaled as large as possible.
- Provider circuits appear as a cloud, devices of other sites dashed (can be disabled).
- **Wireless links** (NetBox *Wireless links*, e.g. point-to-point radio bridges) appear as blue dotted lines labelled "Wireless", in the network view as well as in the location overviews.
- Selectable labels: management IP, model, ports on links.
- Device names longer than 15 characters are wrapped, preferably at `-`, `_`, `.` or spaces.
**Symbols** (menu **Plugins → Topology symbols**, or the "Topology symbol"
**Symbols** (menu **Customer Export → Topology Symbols**, or the "Topology symbol"
button on device type and device role pages):
1. per **device type**: choose a built-in symbol or **upload a custom icon** (PNG/JPG, ideally transparent)
+1 -1
View File
@@ -6,7 +6,7 @@ class CustomerExportConfig(PluginConfig):
name = "netbox_customer_export"
verbose_name = _("Customer Export")
description = _("Export customer documentation as PDF or Word")
version = "0.18.0"
version = "0.19.0"
author = "Claude"
base_url = "customer-export"
min_version = "4.6.8"
@@ -1534,10 +1534,20 @@ msgstr[0] "%(n)d Rack"
msgstr[1] "%(n)d Racks"
msgid "Cross-site location overview (all locations in one diagram)"
msgstr "Lokationsübersicht standortübergreifend (alle Lokationen in einem Diagramm)"
msgstr ""
"Lokationsübersicht standortübergreifend (alle Lokationen in einem Diagramm)"
msgid "Cross-site location overview"
msgstr "Standortübergreifende Lokationsübersicht"
msgid "All sites"
msgstr "Alle Standorte"
msgid "Wireless"
msgstr "Funk"
msgid "Export"
msgstr "Export"
msgid "Settings"
msgstr "Einstellungen"
+12 -2
View File
@@ -1,7 +1,7 @@
from django.utils.translation import gettext_lazy as _
from netbox.plugins import PluginMenuButton, PluginMenuItem
from netbox.plugins import PluginMenu, PluginMenuButton, PluginMenuItem
menu_items = (
_items = (
PluginMenuItem(
link="plugins:netbox_customer_export:select",
link_text=_("Customer Documentation"),
@@ -34,3 +34,13 @@ menu_items = (
),
),
)
# Eigener Eintrag im obersten Navigationsmenü statt unter „Plugins“
menu = PluginMenu(
label=_("Customer Export"),
groups=(
(_("Export"), _items[:1]),
(_("Settings"), _items[1:]),
),
icon_class="mdi mdi-file-document-multiple-outline",
)
+42 -17
View File
@@ -32,6 +32,7 @@ class Edge:
b: str
labels: list = field(default_factory=list)
summary: str = "" # feste Beschriftung statt Port-Namen (z.B. Lokationsübersicht)
wireless: bool = False # nur Funkstrecken (WirelessLink) – blau gepunktet
@dataclass
@@ -90,7 +91,7 @@ def build_graphs(scope, opts, per="site"):
cache = getattr(scope, "_topology_cache", None)
if cache is None:
cache = scope._topology_cache = _collect(scope, opts)
by_pk, drawn, links, external = cache
by_pk, drawn, links, external, wireless = cache
groups = OrderedDict()
for pk in drawn:
@@ -130,7 +131,7 @@ def build_graphs(scope, opts, per="site"):
kind, icon = drawn[d.pk]
other = Node(nid, d.name or str(d), kind, icon, context(d), external=True)
nodes[nid] = Node(**{**other.__dict__})
edges.append(Edge(a, b, labels))
edges.append(Edge(a, b, labels, wireless=(a, b) in wireless))
if not opts.get("topo_isolated"):
linked = {n for e in edges for n in (e.a, e.b)}
nodes = OrderedDict((k, v) for k, v in nodes.items() if k in linked)
@@ -148,6 +149,7 @@ def build_graphs(scope, opts, per="site"):
def _collect(scope, opts):
"""Geräte, Symbole und Verbindungen (Kabelpfade) des Scopes einmalig einlesen."""
from dcim.models import Interface
from django.db.models import Q
resolver = SymbolResolver()
devices = list(
@@ -162,11 +164,12 @@ def _collect(scope, opts):
drawn[d.pk] = (kind, icon)
by_pk = {d.pk: d for d in devices}
# Verbindungen: vollständige Kabelpfade (auch über Patchpanels) zwischen Interfaces
# Verbindungen: vollständige Kabelpfade (auch über Patchpanels) und Funkstrecken zwischen Interfaces
links = defaultdict(list) # (a, b) -> ["Gi1/0/1 – eth0", …]
kinds = defaultdict(set) # (a, b) -> {"cable", "wireless"}
external = {} # node_id -> Node-Vorlage
ifaces = scope.restrict(
Interface.objects.filter(device_id__in=list(drawn), cable__isnull=False)
Interface.objects.filter(Q(cable__isnull=False) | Q(wireless_link__isnull=False), device_id__in=list(drawn))
).select_related("device")
for iface in ifaces:
try:
@@ -207,8 +210,10 @@ def _collect(scope, opts):
label = " – ".join(reversed(label.split(" – ")))
if label not in links[key]:
links[key].append(label)
kinds[key].add("cable" if iface.cable_id else "wireless")
return by_pk, drawn, links, external
wireless = {k for k, v in kinds.items() if v == {"wireless"}}
return by_pk, drawn, links, external, wireless
def build_location_graphs(scope, opts, combined=False):
@@ -222,6 +227,7 @@ def build_location_graphs(scope, opts, combined=False):
Firewall/Router/Core stehen oben, die Ebenen darunter folgen der Verkabelung.
"""
from dcim.models import FrontPort, Interface, RearPort
from django.db.models import Q
resolver = SymbolResolver()
devices = list(
@@ -244,12 +250,17 @@ def build_location_graphs(scope, opts, combined=False):
if d.rack_id:
racks[d.location_id].add(d.rack_id)
cables = {} # cable.pk -> (Knoten a, Knoten b, Kabel)
cables = {} # ("c"|"w", pk) -> (Knoten a, Knoten b, Kabel oder WirelessLink)
outside = {} # node_id -> Node (andere Standorte / Provider)
for model in (Interface, FrontPort, RearPort):
ports = scope.restrict(model.objects.filter(device_id__in=list(by_pk), cable__isnull=False)).select_related("cable")
cond = Q(cable__isnull=False)
if model is Interface:
cond |= Q(wireless_link__isnull=False)
ports = scope.restrict(model.objects.filter(cond, device_id__in=list(by_pk))).select_related("cable")
for port in ports:
if port.cable_id in cables:
link = port.cable if port.cable_id else port.wireless_link
link_key = ("c", port.cable_id) if port.cable_id else ("w", port.wireless_link_id)
if link_key in cables:
continue
try:
peers = port.link_peers or []
@@ -277,7 +288,7 @@ def build_location_graphs(scope, opts, combined=False):
else:
continue
if a != b:
cables[port.cable_id] = (a, b, port.cable)
cables[link_key] = (a, b, link)
break
links = defaultdict(list)
@@ -316,7 +327,10 @@ def build_location_graphs(scope, opts, combined=False):
loc = all_locs[nid]
tpl = Node(nid, loc.name, "location", builtin_icon("location"), [str(loc.site)], external=True)
nodes[nid] = Node(**{**tpl.__dict__})
edges.append(Edge(a, b, [str(c) for c in lst], summary=_cable_summary(lst)))
edges.append(Edge(
a, b, [str(c) for c in lst], summary=_cable_summary(lst),
wireless=all(c._meta.model_name == "wirelesslink" for c in lst),
))
if not opts.get("topo_isolated"):
linked = {n for e in edges for n in (e.a, e.b)}
nodes = OrderedDict((k, v) for k, v in nodes.items() if k in linked)
@@ -328,10 +342,13 @@ def build_location_graphs(scope, opts, combined=False):
def _cable_summary(cables):
"""„2× SMF, 4× CAT6a“ – Kabel ohne Typ zählen als „Kabel“."""
"""„2× SMF, 4× CAT6a, 1× Funk“ – Kabel ohne Typ zählen als „Kabel“, Funkstrecken als „Funk“."""
types = defaultdict(int)
for c in cables:
types[c.get_type_display() if c.type else _("Cable")] += 1
if c._meta.model_name == "wirelesslink":
types[_("Wireless")] += 1
else:
types[c.get_type_display() if c.type else _("Cable")] += 1
return ", ".join(f"{n}× {t}" for t, n in sorted(types.items(), key=lambda x: -x[1]))
@@ -434,8 +451,12 @@ def _edge_text(graph, e, show_ports):
return e.summary
if show_ports:
labels = _oriented(graph, e)
return labels[0] + (f" (+{len(labels) - 1})" if len(labels) > 1 else "")
return f"{len(e.labels)}×" if len(e.labels) > 1 else None
text = labels[0] + (f" (+{len(labels) - 1})" if len(labels) > 1 else "")
return f"{_('Wireless')}: {text}" if e.wireless else text
count = f"{len(e.labels)}×" if len(e.labels) > 1 else ""
if e.wireless:
return f"{count} {_('Wireless')}".strip()
return count or None
# --- PNG ----------------------------------------------------------------------
@@ -445,6 +466,7 @@ PALETTE = [
(23, 150, 170), (140, 86, 75), (188, 150, 20), (200, 80, 160), (90, 90, 90),
]
EXTERNAL = (160, 160, 160)
WIRELESS = (30, 136, 229) # Funkstrecken: blau, gepunktet
def _font(size, bold=False):
@@ -587,7 +609,8 @@ def render_png(graph, show_ports=False, scale=2):
line([(min(xs), ly), (max(xs), ly)], col, dashed=u.external)
for c, e, ex, stack_pos in entries:
dashed = u.external or c.external
line([(ex, ly), (ex, c.y - 2)], EXTERNAL if dashed else col, w=3 if len(e.labels) > 1 else 2, dashed=dashed)
drop_col = WIRELESS if e.wireless else EXTERNAL if dashed else col
line([(ex, ly), (ex, c.y - 2)], drop_col, w=3 if len(e.labels) > 1 else 2, dashed=dashed or e.wireless)
if min(xs) < ex < max(xs): # Abzweig auf der Schiene markieren
d.ellipse([(ex - 2.5) * S, (ly - 2.5) * S, (ex + 2.5) * S, (ly + 2.5) * S], fill=col)
text = _edge_text(graph, e, show_ports)
@@ -600,7 +623,8 @@ def render_png(graph, show_ports=False, scale=2):
a, b = nodes[e.a], nodes[e.b]
ly = gap["top"] + gap["lane_of"][("s", i)] * LANE
dashed = a.external or b.external
line([(a.x, a.y - 2), (a.x, ly), (b.x, ly), (b.x, b.y - 2)], EXTERNAL if dashed else (70, 70, 70), dashed=dashed)
col = WIRELESS if e.wireless else EXTERNAL if dashed else (70, 70, 70)
line([(a.x, a.y - 2), (a.x, ly), (b.x, ly), (b.x, b.y - 2)], col, dashed=dashed or e.wireless)
text = _edge_text(graph, e, show_ports)
if text:
labels.append((text, (a.x + b.x) / 2, ly, "mm"))
@@ -612,7 +636,8 @@ def render_png(graph, show_ports=False, scale=2):
left, right = (a, b) if a.x < b.x else (b, a)
line(
[(left.x + ICON / 2 + 4, cy), (right.x - ICON / 2 - 4, cy)],
EXTERNAL if dashed else (70, 70, 70), w=3 if len(e.labels) > 1 else 2, dashed=dashed,
WIRELESS if e.wireless else EXTERNAL if dashed else (70, 70, 70),
w=3 if len(e.labels) > 1 else 2, dashed=dashed or e.wireless,
)
text = _edge_text(graph, e, show_ports)
if text:
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "netbox-customer-export"
version = "0.18.0"
version = "0.19.0"
description = "NetBox plugin: customer documentation (PDF/Word) for sites, locations, tenants and tenant groups"
readme = "README.md"
requires-python = ">=3.10"