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]>
This commit is contained in:
1 parent
174a41e838
commit
27673ee68f
6 files changed
+37
-21
No files matched your search
@@ -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.
|
- 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×".
|
- 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.
|
- **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.
|
- 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.
|
- 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).
|
- Provider circuits appear as a cloud, devices of other sites dashed (can be disabled).
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class CustomerExportConfig(PluginConfig):
|
|||||||
name = "netbox_customer_export"
|
name = "netbox_customer_export"
|
||||||
verbose_name = _("Customer Export")
|
verbose_name = _("Customer Export")
|
||||||
description = _("Export customer documentation as PDF or Word")
|
description = _("Export customer documentation as PDF or Word")
|
||||||
version = "0.19.0"
|
version = "0.19.1"
|
||||||
author = "Claude"
|
author = "Claude"
|
||||||
base_url = "customer-export"
|
base_url = "customer-export"
|
||||||
min_version = "4.6.8"
|
min_version = "4.6.8"
|
||||||
|
|||||||
Binary file not shown.
@@ -1551,3 +1551,6 @@ msgstr "Export"
|
|||||||
|
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr "Einstellungen"
|
msgstr "Einstellungen"
|
||||||
|
|
||||||
|
msgid "without location"
|
||||||
|
msgstr "ohne Lokation"
|
||||||
@@ -231,24 +231,30 @@ def build_location_graphs(scope, opts, combined=False):
|
|||||||
|
|
||||||
resolver = SymbolResolver()
|
resolver = SymbolResolver()
|
||||||
devices = list(
|
devices = list(
|
||||||
scope.devices().filter(location__isnull=False)
|
scope.devices()
|
||||||
.select_related("role", "device_type__manufacturer", "site", "location__parent", "rack")
|
.select_related("role", "device_type__manufacturer", "site", "location__parent", "rack")
|
||||||
.order_by("site__name", "location__name")
|
.order_by("site__name", "location__name")
|
||||||
)
|
)
|
||||||
if not devices:
|
if not devices:
|
||||||
return []
|
return []
|
||||||
by_pk = {d.pk: d for d in devices}
|
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)
|
# Ebene je Lokation = „höchstes“ Gerät darin (Firewall/Core oben, reine Verteiler darunter)
|
||||||
tier, racks, count = {}, defaultdict(set), defaultdict(int)
|
tier, racks, count = {}, defaultdict(set), defaultdict(int)
|
||||||
for d in devices:
|
for d in devices:
|
||||||
kind, _icon = resolver.resolve(d)
|
kind, _icon = resolver.resolve(d)
|
||||||
t = KINDS.get(kind, ("", 3))[1] if kind else 3
|
t = KINDS.get(kind, ("", 3))[1] if kind else 3
|
||||||
tier[d.location_id] = min(tier.get(d.location_id, 9), t)
|
nid = nid_of[d.pk]
|
||||||
count[d.location_id] += 1
|
tier[nid] = min(tier.get(nid, 9), t)
|
||||||
|
count[nid] += 1
|
||||||
if d.rack_id:
|
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)
|
cables = {} # ("c"|"w", pk) -> (Knoten a, Knoten b, Kabel oder WirelessLink)
|
||||||
outside = {} # node_id -> Node (andere Standorte / Provider)
|
outside = {} # node_id -> Node (andere Standorte / Provider)
|
||||||
@@ -266,12 +272,12 @@ def build_location_graphs(scope, opts, combined=False):
|
|||||||
peers = port.link_peers or []
|
peers = port.link_peers or []
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
continue
|
continue
|
||||||
a = f"l{loc_of[port.device_id].pk}"
|
a = nid_of[port.device_id]
|
||||||
for peer in peers:
|
for peer in peers:
|
||||||
peer_dev = getattr(peer, "device", None)
|
peer_dev = getattr(peer, "device", None)
|
||||||
if peer_dev is not None:
|
if peer_dev is not None:
|
||||||
if peer_dev.pk in by_pk:
|
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"):
|
elif not opts.get("topo_external"):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@@ -296,24 +302,31 @@ def build_location_graphs(scope, opts, combined=False):
|
|||||||
links[tuple(sorted((a, b)))].append(cable)
|
links[tuple(sorted((a, b)))].append(cable)
|
||||||
|
|
||||||
sites = OrderedDict()
|
sites = OrderedDict()
|
||||||
all_locs = {}
|
all_locs = {} # node_id -> (Name, Standort)
|
||||||
for d in devices:
|
for d in devices:
|
||||||
sites.setdefault(None if combined else d.site, OrderedDict())[d.location_id] = d.location
|
nid = nid_of[d.pk]
|
||||||
all_locs[f"l{d.location_id}"] = d.location
|
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 = []
|
graphs = []
|
||||||
for site, locations in sites.items():
|
for site, locations in sites.items():
|
||||||
nodes = OrderedDict()
|
nodes = OrderedDict()
|
||||||
for loc in locations.values():
|
for nid, d in locations.items():
|
||||||
where = [str(loc.site)] if combined else []
|
loc = d.location
|
||||||
if loc.parent_id:
|
if loc is not None:
|
||||||
where.append(str(loc.parent))
|
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 []
|
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 = [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})
|
parts.append(ngettext("%(n)d device", "%(n)d devices", n_dev) % {"n": n_dev})
|
||||||
sub.append(" · ".join(parts))
|
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)
|
members = set(nodes)
|
||||||
edges = []
|
edges = []
|
||||||
for (a, b), lst in links.items():
|
for (a, b), lst in links.items():
|
||||||
@@ -324,8 +337,8 @@ def build_location_graphs(scope, opts, combined=False):
|
|||||||
continue
|
continue
|
||||||
tpl = outside.get(nid)
|
tpl = outside.get(nid)
|
||||||
if tpl is None: # Lokation im Scope, aber an einem anderen Standort
|
if tpl is None: # Lokation im Scope, aber an einem anderen Standort
|
||||||
loc = all_locs[nid]
|
name, loc_site = all_locs[nid]
|
||||||
tpl = Node(nid, loc.name, "location", builtin_icon("location"), [str(loc.site)], external=True)
|
tpl = Node(nid, name, "location", builtin_icon("location"), [str(loc_site)], external=True)
|
||||||
nodes[nid] = Node(**{**tpl.__dict__})
|
nodes[nid] = Node(**{**tpl.__dict__})
|
||||||
edges.append(Edge(
|
edges.append(Edge(
|
||||||
a, b, [str(c) for c in lst], summary=_cable_summary(lst),
|
a, b, [str(c) for c in lst], summary=_cable_summary(lst),
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "netbox-customer-export"
|
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"
|
description = "NetBox plugin: customer documentation (PDF/Word) for sites, locations, tenants and tenant groups"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
|
|||||||
Reference in new issue
Block a user