Compare commits

...
4 Commits
Author SHA1 Message Date
MrBlakeandClaude Opus 5.5 27673ee68f fix: location overview includes devices without a location
Devices with only a site (e.g. radio bridge APs) were dropped from the
location overview, so their cables and wireless links disappeared.
They are now grouped in a per-site node "ohne Lokation".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 13:18:48 +01:00
MrBlakeandClaude Opus 5.5 174a41e838 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]>
2026-11-16 13:14:16 +01:00
MrBlakeandClaude Opus 5.5 d7c86289b1 Merge origin/main (i18n) with cross-site location overview
Resolve conflicts between the i18n refactor and the new cross-site
location overview: new strings use gettext with German translations
(.po/.mo updated), version bumped to 0.18.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 13:06:46 +01:00
MrBlakeandClaude Opus 5.5 9735164da1 feat: cross-site location overview in a single diagram
New topology scope 'Lokationsübersicht standortübergreifend' draws all
locations of all sites in scope as one graph, with site and parent
location on each node, to show how buildings and locations connect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 13:03:41 +01:00
10 changed files with 134 additions and 49 deletions

No files matched your search

+6 -4
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
@@ -258,13 +258,15 @@ style of Cisco Packet Tracer:
- The top-to-bottom layout follows the cabling: provider → firewall/router → core → access → end devices, with ordering optimised for as few crossings as possible.
- Lines are routed **orthogonally** on bus bars, coloured per upstream device. Port names sit at the target device; multiple uplinks are drawn thicker and marked "2×".
- **Scope**: *entire network* (one page per site), *location overview* and/or *per rack* (one page per rack). In the rack view, directly connected devices outside the rack appear faded and dashed, with their rack.
- The **location overview** draws one diagram per site with the **locations as nodes** (server room, halls, sub-distributions …). Lines are the physical cables between locations, labelled with count and cable type (e.g. `2× SMF, 4× CAT6a`), so you can follow the cabling from the server room to the last sub-distribution. Locations containing firewalls, routers or core switches are placed at the top; each node shows its parent location and the number of racks and devices.
- The **location overview** draws one diagram per site with the **locations as nodes** (server room, halls, sub-distributions …). Lines are the physical cables between locations, labelled with count and cable type (e.g. `2× SMF, 4× CAT6a`), so you can follow the cabling from the server room to the last sub-distribution. Locations containing firewalls, routers or core switches are placed at the top; each node shows its parent location and the number of racks and devices. Devices without a location (e.g. radio bridges on the roof) are grouped in a node for their site ("without location").
- 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.17.0"
version = "0.19.1"
author = "Claude"
base_url = "customer-export"
min_version = "4.6.8"
+1
View File
@@ -80,6 +80,7 @@ class ExportForm(forms.Form):
choices=(
("site", _("Whole network (per site)")),
("locations", _("Location overview (connections between locations)")),
("locations_all", _("Cross-site location overview (all locations in one diagram)")),
("rack", _("Per rack")),
),
initial=["site"],
@@ -1507,13 +1507,16 @@ msgstr "vCPU je Kern"
msgid ""
"“Location overview” shows all locations of a site and the cables between "
"them, from the server room to the last sub-distribution. “Per rack” shows "
"each rack separately. Connected devices outside appear dashed."
"them, from the server room to the last sub-distribution. “Cross-site” "
"combines all sites in one diagram to show how buildings and their locations "
"are connected. “Per rack” shows each rack separately. Connected devices "
"outside appear dashed."
msgstr ""
"„Lokationsübersicht“ zeigt alle Lokationen eines Standorts und die Kabel "
"zwischen ihnen, vom Serverraum bis zur letzten Unterverteilung. „Je Rack“ "
"zeigt jedes Rack einzeln. Verbundene Geräte außerhalb erscheinen "
"gestrichelt."
"zwischen ihnen, vom Serverraum bis zur letzten Unterverteilung. "
"„Standortübergreifend“ fasst alle Standorte in einem Diagramm zusammen, um "
"zu sehen, wie Gebäude und ihre Lokationen verbunden sind. „Je Rack“ zeigt "
"jedes Rack einzeln. Verbundene Geräte außerhalb erscheinen gestrichelt."
msgid "%(n)d device"
msgid_plural "%(n)d devices"
@@ -1529,3 +1532,25 @@ msgid "%(n)d rack"
msgid_plural "%(n)d racks"
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)"
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"
msgid "without location"
msgstr "ohne Lokation"
+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",
)
+2
View File
@@ -618,6 +618,8 @@ def topology(scope, opts):
if "locations" in scopes:
locs = build_location_graphs(scope, opts)
pages += [(([H(2, _("Location overview"))] if i == 0 else []) + [H(3, g.title)], g) for i, g in enumerate(locs)]
if "locations_all" in scopes:
pages += [([H(2, _("Cross-site location overview"))], g) for g in build_location_graphs(scope, opts, combined=True)]
if "rack" in scopes:
racks = build_graphs(scope, opts, per="rack")
# Rack-Seiten unter einer gemeinsamen Zwischenüberschrift, Racks selbst eine Ebene tiefer (kürzeres Inhaltsverzeichnis)
@@ -176,7 +176,7 @@
<div class="card-body">
<div class="ce-label mt-0">{{ form.topo_scope.label }}</div>
{% include 'netbox_customer_export/_pills.html' with field=form.topo_scope %}
<div class="form-text mb-2">{% trans "“Location overview” shows all locations of a site and the cables between them, from the server room to the last sub-distribution. “Per rack” shows each rack separately. Connected devices outside appear dashed." %}</div>
<div class="form-text mb-2">{% trans "“Location overview” shows all locations of a site and the cables between them, from the server room to the last sub-distribution. “Cross-site” combines all sites in one diagram to show how buildings and their locations are connected. “Per rack” shows each rack separately. Connected devices outside appear dashed." %}</div>
<div class="ce-label">{{ form.topo_details.label }}</div>
{% include 'netbox_customer_export/_pills.html' with field=form.topo_details %}
<div class="ce-label">{% trans "More" %}</div>
+80 -35
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,57 +210,74 @@ 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):
def build_location_graphs(scope, opts, combined=False):
"""Lokationsübersicht: ein Graph je Standort, Knoten = Lokationen, Linien = Kabel zwischen Lokationen.
Mit `combined=True` entsteht ein einziger standortübergreifender Graph über alle Lokationen im Scope, an
jedem Knoten steht der Standort – so sieht man, wie Gebäude und ihre Lokationen untereinander verbunden sind.
Gezählt werden physische Kabel (Interfaces, Front- und Rear-Ports), deren Enden in verschiedenen Lokationen
liegen – typischerweise LWL-/Kupfer-Trunks vom Serverraum zu den Unterverteilungen. Lokationen mit
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(
scope.devices().filter(location__isnull=False)
scope.devices()
.select_related("role", "device_type__manufacturer", "site", "location__parent", "rack")
.order_by("site__name", "location__name")
)
if not devices:
return []
by_pk = {d.pk: d for d in devices}
loc_of = {d.pk: d.location for d in devices}
def node_of(d):
"""Lokation des Geräts – Geräte ohne Lokation (z.B. Richtfunk-APs am Dach) hängen am Standort selbst."""
return f"l{d.location_id}" if d.location_id else f"s{d.site_id}"
nid_of = {d.pk: node_of(d) for d in devices}
# Ebene je Lokation = „höchstes“ Gerät darin (Firewall/Core oben, reine Verteiler darunter)
tier, racks, count = {}, defaultdict(set), defaultdict(int)
for d in devices:
kind, _icon = resolver.resolve(d)
t = KINDS.get(kind, ("", 3))[1] if kind else 3
tier[d.location_id] = min(tier.get(d.location_id, 9), t)
count[d.location_id] += 1
nid = nid_of[d.pk]
tier[nid] = min(tier.get(nid, 9), t)
count[nid] += 1
if d.rack_id:
racks[d.location_id].add(d.rack_id)
racks[nid].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 []
except Exception: # noqa: BLE001
continue
a = f"l{loc_of[port.device_id].pk}"
a = nid_of[port.device_id]
for peer in peers:
peer_dev = getattr(peer, "device", None)
if peer_dev is not None:
if peer_dev.pk in by_pk:
b = f"l{loc_of[peer_dev.pk].pk}"
b = nid_of[peer_dev.pk]
elif not opts.get("topo_external"):
continue
else:
@@ -274,7 +294,7 @@ def build_location_graphs(scope, opts):
else:
continue
if a != b:
cables[port.cable_id] = (a, b, port.cable)
cables[link_key] = (a, b, link)
break
links = defaultdict(list)
@@ -282,21 +302,31 @@ def build_location_graphs(scope, opts):
links[tuple(sorted((a, b)))].append(cable)
sites = OrderedDict()
all_locs = {}
all_locs = {} # node_id -> (Name, Standort)
for d in devices:
sites.setdefault(d.site, OrderedDict())[d.location_id] = d.location
all_locs[f"l{d.location_id}"] = d.location
nid = nid_of[d.pk]
sites.setdefault(None if combined else d.site, OrderedDict())[nid] = d
all_locs[nid] = (d.location.name if d.location_id else str(d.site), d.site)
graphs = []
for site, locations in sites.items():
nodes = OrderedDict()
for loc in locations.values():
sub = [str(loc.parent)] if loc.parent_id else []
n_racks, n_dev = len(racks[loc.pk]), count[loc.pk]
for nid, d in locations.items():
loc = d.location
if loc is not None:
name = loc.name
where = [str(loc.site)] if combined else []
if loc.parent_id:
where.append(str(loc.parent))
else:
name = str(d.site)
where = [_("without location")]
sub = [" / ".join(where)] if where else []
n_racks, n_dev = len(racks[nid]), count[nid]
parts = [ngettext("%(n)d rack", "%(n)d racks", n_racks) % {"n": n_racks}] if n_racks else []
parts.append(ngettext("%(n)d device", "%(n)d devices", n_dev) % {"n": n_dev})
sub.append(" · ".join(parts))
nodes[f"l{loc.pk}"] = Node(f"l{loc.pk}", loc.name, "location", builtin_icon("location"), sub, tier=tier[loc.pk])
nodes[nid] = Node(nid, name, "location", builtin_icon("location"), sub, tier=tier[nid])
members = set(nodes)
edges = []
for (a, b), lst in links.items():
@@ -307,24 +337,31 @@ def build_location_graphs(scope, opts):
continue
tpl = outside.get(nid)
if tpl is None: # Lokation im Scope, aber an einem anderen Standort
loc = all_locs[nid]
tpl = Node(nid, loc.name, "location", builtin_icon("location"), [str(loc.site)], external=True)
name, loc_site = all_locs[nid]
tpl = Node(nid, 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)
if nodes:
_layout(nodes, edges)
graphs.append(Graph(_("Site %(name)s") % {"name": site}, nodes, edges))
title = _("All sites") if combined else _("Site %(name)s") % {"name": site}
graphs.append(Graph(title, nodes, edges))
return graphs
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]))
@@ -427,8 +464,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 ----------------------------------------------------------------------
@@ -438,6 +479,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):
@@ -580,7 +622,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)
@@ -593,7 +636,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"))
@@ -605,7 +649,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.17.0"
version = "0.19.1"
description = "NetBox plugin: customer documentation (PDF/Word) for sites, locations, tenants and tenant groups"
readme = "README.md"
requires-python = ">=3.10"