From 27673ee68f5095fcaef5baee3fe5f31a65205314 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 16 Nov 2026 13:18:48 +0100 Subject: [PATCH] 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 --- README.md | 2 +- netbox_customer_export/__init__.py | 2 +- .../locale/de/LC_MESSAGES/django.mo | Bin 22258 -> 22305 bytes .../locale/de/LC_MESSAGES/django.po | 3 ++ netbox_customer_export/topology.py | 49 +++++++++++------- pyproject.toml | 2 +- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 75f2a21..9749f64 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,7 @@ 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). diff --git a/netbox_customer_export/__init__.py b/netbox_customer_export/__init__.py index 4aea9b6..e652079 100644 --- a/netbox_customer_export/__init__.py +++ b/netbox_customer_export/__init__.py @@ -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.19.0" + version = "0.19.1" author = "Claude" base_url = "customer-export" min_version = "4.6.8" diff --git a/netbox_customer_export/locale/de/LC_MESSAGES/django.mo b/netbox_customer_export/locale/de/LC_MESSAGES/django.mo index f5959c1b863d1ee63a56a058a694ecbfcea87398..81c0276b1eb1ad49c1bbf0261e96ea54c9376f76 100644 GIT binary patch delta 5882 zcmYM&32;}%9l-II5OP9D5F=N}2_X?AASfyt5=)>V$Psh^(JG1(qlS`z3h3Vo)UzHn zidHD1R0R)Iw3LdiV6_D;QaiOCPbv7~7wF<%BDazqF(6X8i|~bs0tlmHX3mwx}t@l zehp5eeiNFxcd-!L(L)cm*2ao#<)3AD#GF z8qH6?_gK_pp5*dQfQ~a06xPs z>_9Vd7)^2N;CR9w=!B(Mhn2{pqa|qI_oEYZqFa*8$#tT9be<9{#0pHuiRI+q4%0)& zS?CJSLsQj)Zq0HupkJb2%Nq2(C(ukhgHEsm9e6jo_iv(yy8~TVZbfV#bey6@XsASA z9E~29>QHY$2bdk|OEHuB3iJ%z9@^W`%&bNiupTpUYpDMj&CFZqg5E=K%EYG>oH*^+ zc*Qw*67?d?#IrFAFG5$m0KLJkL^E<5I`Aqq18YP55zL_ecxc~@S=9f4p1GaKnMg$M zhXbm#csF<7vjIrmCYO)2XZmGu*=b{yaKsy0^9HDL(_fV9rGYSP-5sLHjQY z-h@Xpe{=^0_x$1D7IY6^K~udKUGZ1w06m7qE6+m%E5RBZjHbK^4SXRQz!L0%%h61< zq4WI)6H_T{roaJ>GAiQ%kH;kHqtTU}j1F9b22hU%)__iQ3HtfYM-OESx_~R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-KvM<^=0UxPoAaW0AsRmL1Gd1N3)9kp2iY%f(!n4gL0w+ zN1}T@9$o0?==(ndJuA23*?1p1eiJ&+o3XzY{T=Z>y3PSKkeefL zpg(%pMxzjt1}rdPWXoTg>X6_RFxGelK*~By^$a$g3Y_qg(eZdVdXiCf4^((#GrY z#=GdA?nK{$&#)aHL<4KsC-ro!qTdz`bVPJKn$ScvfSb?-Z$~S!04wpu*x!@TFp>s* zzE5PGg7aAI{z8yR+gd(T!#m(r@W+}2X5($~{@t;EA3E+~ z%*ChB578R*%>AW?`dhj!Tri`3=pKKAPS}8`%&ZZ5iko9Oc8S-=qvLAP38%*X9L%Gi zpl4?xI?pmJ!Kcwm{e5VB|F?0$Gq5`j+>812_oIOwMHi|+EbZr`d)x}muo&IK&S<8C z(S=7LAH6UUo$pCBu(fCZH&-tcsMA^Jruiv8|r zi3g&Aj78`9De?<8OvWqlapc!UNKVr5G$h1EM-GWhQ z2IH^*Yq1b#MDIku8;@W$euti^4x`f7@ho)y&geYdFx&UP4-F$5f-Y2xzQ5O@6HLRV zcmsNvZbuK_>u6;*qtEX~7dVP;-49rVxqLhvUy07&8BO>+OsIC~Ps0b6pod}w8o*xk zfjabo{b=UL&;@h&Jh~+%cs_PQ4{0r0;_K1z3$YL%i}zQf>%BaNFSwCyjsv&G8+)P$ k(J$5aI6H$$#)j}S`ggBe+I(W`b&b!>ZMUv$><=0L1sn`o*8l(j diff --git a/netbox_customer_export/locale/de/LC_MESSAGES/django.po b/netbox_customer_export/locale/de/LC_MESSAGES/django.po index 67c96d5..81141a5 100644 --- a/netbox_customer_export/locale/de/LC_MESSAGES/django.po +++ b/netbox_customer_export/locale/de/LC_MESSAGES/django.po @@ -1551,3 +1551,6 @@ msgstr "Export" msgid "Settings" msgstr "Einstellungen" + +msgid "without location" +msgstr "ohne Lokation" diff --git a/netbox_customer_export/topology.py b/netbox_customer_export/topology.py index 407c4e2..5b71c1f 100644 --- a/netbox_customer_export/topology.py +++ b/netbox_customer_export/topology.py @@ -231,24 +231,30 @@ def build_location_graphs(scope, opts, combined=False): 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 = {} # ("c"|"w", pk) -> (Knoten a, Knoten b, Kabel oder WirelessLink) outside = {} # node_id -> Node (andere Standorte / Provider) @@ -266,12 +272,12 @@ def build_location_graphs(scope, opts, combined=False): 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: @@ -296,24 +302,31 @@ def build_location_graphs(scope, opts, combined=False): links[tuple(sorted((a, b)))].append(cable) sites = OrderedDict() - all_locs = {} + all_locs = {} # node_id -> (Name, Standort) for d in devices: - sites.setdefault(None if combined else 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(): - where = [str(loc.site)] if combined else [] - if loc.parent_id: - where.append(str(loc.parent)) + 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[loc.pk]), count[loc.pk] + 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(): @@ -324,8 +337,8 @@ def build_location_graphs(scope, opts, combined=False): 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), diff --git a/pyproject.toml b/pyproject.toml index 23f52d4..c6d7d7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-customer-export" -version = "0.19.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"