From 9735164da1cfa826bd29011cd5693d3f48d8f12e Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 16 Nov 2026 13:03:41 +0100 Subject: [PATCH] feat: cross-site location overview in a single diagram MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 1 + netbox_customer_export/__init__.py | 2 +- netbox_customer_export/forms.py | 1 + netbox_customer_export/sections.py | 2 ++ .../templates/netbox_customer_export/export.html | 2 +- netbox_customer_export/topology.py | 14 ++++++++++---- pyproject.toml | 2 +- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 72276ec..f6b8a9c 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ style of Cisco Packet Tracer: - 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 **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). - Selectable labels: management IP, model, ports on links. diff --git a/netbox_customer_export/__init__.py b/netbox_customer_export/__init__.py index ce25f7d..de2e06a 100644 --- a/netbox_customer_export/__init__.py +++ b/netbox_customer_export/__init__.py @@ -5,7 +5,7 @@ class CustomerExportConfig(PluginConfig): name = "netbox_customer_export" verbose_name = "Kunden-Export" description = "Kundendokumentation als PDF oder Word exportieren" - version = "0.16.0" + version = "0.17.0" author = "Claude" base_url = "customer-export" min_version = "4.6.8" diff --git a/netbox_customer_export/forms.py b/netbox_customer_export/forms.py index a176499..b375821 100644 --- a/netbox_customer_export/forms.py +++ b/netbox_customer_export/forms.py @@ -79,6 +79,7 @@ class ExportForm(forms.Form): choices=( ("site", "Gesamtes Netzwerk (je Standort)"), ("locations", "Lokationsübersicht (Verbindungen zwischen Lokationen)"), + ("locations_all", "Lokationsübersicht standortübergreifend (alle Lokationen in einem Diagramm)"), ("rack", "Je Rack"), ), initial=["site"], diff --git a/netbox_customer_export/sections.py b/netbox_customer_export/sections.py index 61d509b..9d15674 100644 --- a/netbox_customer_export/sections.py +++ b/netbox_customer_export/sections.py @@ -612,6 +612,8 @@ def topology(scope, opts): if "locations" in scopes: locs = build_location_graphs(scope, opts) pages += [(([H(2, "Lokationsübersicht")] if i == 0 else []) + [H(3, g.title)], g) for i, g in enumerate(locs)] + if "locations_all" in scopes: + pages += [([H(2, "Standortübergreifende Lokationsübersicht")], 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) diff --git a/netbox_customer_export/templates/netbox_customer_export/export.html b/netbox_customer_export/templates/netbox_customer_export/export.html index 6a7e8ce..f672954 100644 --- a/netbox_customer_export/templates/netbox_customer_export/export.html +++ b/netbox_customer_export/templates/netbox_customer_export/export.html @@ -175,7 +175,7 @@
Umfang
{% include 'netbox_customer_export/_pills.html' with field=form.topo_scope %} -
„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.
+
„Lokationsübersicht“ zeigt alle Lokationen eines Standorts und die Kabel 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.
Beschriftung
{% include 'netbox_customer_export/_pills.html' with field=form.topo_details %}
Weiteres
diff --git a/netbox_customer_export/topology.py b/netbox_customer_export/topology.py index 502752a..523786a 100644 --- a/netbox_customer_export/topology.py +++ b/netbox_customer_export/topology.py @@ -208,9 +208,12 @@ def _collect(scope, opts): return by_pk, drawn, links, external -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. @@ -281,14 +284,17 @@ def build_location_graphs(scope, opts): sites = OrderedDict() all_locs = {} for d in devices: - sites.setdefault(d.site, OrderedDict())[d.location_id] = d.location + sites.setdefault(None if combined else d.site, OrderedDict())[d.location_id] = d.location all_locs[f"l{d.location_id}"] = d.location graphs = [] for site, locations in sites.items(): nodes = OrderedDict() for loc in locations.values(): - sub = [str(loc.parent)] if loc.parent_id else [] + where = [str(loc.site)] if combined else [] + if loc.parent_id: + where.append(str(loc.parent)) + sub = [" / ".join(where)] if where else [] n_racks, n_dev = len(racks[loc.pk]), count[loc.pk] parts = [f"{n_racks} Rack" + ("s" if n_racks != 1 else "")] if n_racks else [] parts.append(f"{n_dev} Gerät" + ("e" if n_dev != 1 else "")) @@ -313,7 +319,7 @@ def build_location_graphs(scope, opts): nodes = OrderedDict((k, v) for k, v in nodes.items() if k in linked) if nodes: _layout(nodes, edges) - graphs.append(Graph(f"Standort {site}", nodes, edges)) + graphs.append(Graph("Alle Standorte" if combined else f"Standort {site}", nodes, edges)) return graphs diff --git a/pyproject.toml b/pyproject.toml index be4d8e4..a3175d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-customer-export" -version = "0.16.0" +version = "0.17.0" description = "NetBox-Plugin: Kundendokumentation (PDF/Word) für Standorte, Lokationen, Mandanten und Mandantengruppen" readme = "README.md" requires-python = ">=3.10"