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]>
This commit is contained in:
commit
d7c86289b1
37 files changed
+2108
-421
No files matched your search
+139
-133
@@ -5,6 +5,8 @@ from itertools import groupby
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import gettext_lazy, ngettext
|
||||
from netbox.plugins import get_plugin_config
|
||||
|
||||
from .blocks import EMPTY, H, IMAGES, KV, LANDSCAPE, P, PAGEBREAK, REF, T, get
|
||||
@@ -66,27 +68,27 @@ def num(value):
|
||||
def _rack_pos(d, o=None):
|
||||
if not d.rack:
|
||||
return None
|
||||
pos = f" / HE {num(d.position)}" if d.position else ""
|
||||
pos = " / " + _("U %(u)s") % {"u": num(d.position)} if d.position else ""
|
||||
return f"{d.rack}{pos}"
|
||||
|
||||
|
||||
DEVICE_COLUMNS = OrderedDict(
|
||||
[
|
||||
("name", ("Name", lambda d, o: d.name or str(d))),
|
||||
("model", ("Hersteller / Modell", lambda d, o: f"{d.device_type.manufacturer} {d.device_type.model}")),
|
||||
("site", ("Standort", lambda d, o: d.site)),
|
||||
("location", ("Lokation", lambda d, o: d.location)),
|
||||
("rack", ("Rack / HE", _rack_pos)),
|
||||
("status", ("Status", lambda d, o: d.get_status_display())),
|
||||
("platform", ("Plattform / OS", lambda d, o: d.platform)),
|
||||
("primary_ip", ("Management-IP", lambda d, o: primary_ips(d, o))),
|
||||
("oob_ip", ("OOB-IP", lambda d, o: ip_text([d.oob_ip], o))),
|
||||
("serial", ("Seriennummer", lambda d, o: d.serial)),
|
||||
("cpu", ("CPU", lambda d, o: hardware_utilities.cpu_text(d))),
|
||||
("ram", ("RAM", lambda d, o: hardware_utilities.ram_text(d))),
|
||||
("asset_tag", ("Inventarnr.", lambda d, o: d.asset_tag)),
|
||||
("tenant", ("Mandant", lambda d, o: d.tenant)),
|
||||
("description", ("Beschreibung", lambda d, o: d.description)),
|
||||
("name", (gettext_lazy("Name"), lambda d, o: d.name or str(d))),
|
||||
("model", (gettext_lazy("Manufacturer / model"), lambda d, o: f"{d.device_type.manufacturer} {d.device_type.model}")),
|
||||
("site", (gettext_lazy("Site"), lambda d, o: d.site)),
|
||||
("location", (gettext_lazy("Location"), lambda d, o: d.location)),
|
||||
("rack", (gettext_lazy("Rack / U"), _rack_pos)),
|
||||
("status", (gettext_lazy("Status"), lambda d, o: d.get_status_display())),
|
||||
("platform", (gettext_lazy("Platform / OS"), lambda d, o: d.platform)),
|
||||
("primary_ip", (gettext_lazy("Management IP"), lambda d, o: primary_ips(d, o))),
|
||||
("oob_ip", (gettext_lazy("OOB IP"), lambda d, o: ip_text([d.oob_ip], o))),
|
||||
("serial", (gettext_lazy("Serial number"), lambda d, o: d.serial)),
|
||||
("cpu", (gettext_lazy("CPU"), lambda d, o: hardware_utilities.cpu_text(d))),
|
||||
("ram", (gettext_lazy("RAM"), lambda d, o: hardware_utilities.ram_text(d))),
|
||||
("asset_tag", (gettext_lazy("Asset tag"), lambda d, o: d.asset_tag)),
|
||||
("tenant", (gettext_lazy("Tenant"), lambda d, o: d.tenant)),
|
||||
("description", (gettext_lazy("Description"), lambda d, o: d.description)),
|
||||
]
|
||||
)
|
||||
DEFAULT_DEVICE_COLUMNS = ["name", "model", "location", "rack", "primary_ip", "serial"]
|
||||
@@ -97,44 +99,44 @@ def _device_table(devices, columns, opts):
|
||||
return T([c[0] for c in cols], [[c[1](d, opts) for c in cols] for d in devices])
|
||||
|
||||
|
||||
def _empty(opts, blocks, text="Keine Einträge vorhanden."):
|
||||
def _empty(opts, blocks, text=None):
|
||||
if opts.get("include_empty"):
|
||||
blocks.append(P(text))
|
||||
blocks.append(P(text or _("No entries.")))
|
||||
return blocks
|
||||
return []
|
||||
|
||||
|
||||
# --- Abschnitte -------------------------------------------------------------
|
||||
|
||||
@section("overview", "Übersicht & Standortdaten", "Allgemein", hint="Kennzahlen, Adressen, Lokationsbaum")
|
||||
@section("overview", gettext_lazy("Overview & site data"), gettext_lazy("General"), hint=gettext_lazy("Key figures, addresses, location tree"))
|
||||
def overview(scope, opts):
|
||||
blocks = [H(1, "Übersicht")]
|
||||
blocks = [H(1, _("Overview"))]
|
||||
counts = [
|
||||
("Standorte", scope.sites().count()),
|
||||
("Racks", scope.racks().count()),
|
||||
("Geräte", scope.devices().count()),
|
||||
("Virtuelle Maschinen", scope.virtual_machines().count()),
|
||||
("Präfixe", scope.prefixes().count()),
|
||||
("VLANs", scope.vlans().count()),
|
||||
("Leitungen", scope.circuits().count()),
|
||||
(_("Sites"), scope.sites().count()),
|
||||
(_("Racks"), scope.racks().count()),
|
||||
(_("Devices"), scope.devices().count()),
|
||||
(_("Virtual machines"), scope.virtual_machines().count()),
|
||||
(_("Prefixes"), scope.prefixes().count()),
|
||||
(_("VLANs"), scope.vlans().count()),
|
||||
(_("Circuits"), scope.circuits().count()),
|
||||
]
|
||||
blocks.append(KV([(f"{scope.label}", scope.obj)] + counts))
|
||||
if getattr(scope.obj, "description", ""):
|
||||
blocks.append(P(scope.obj.description))
|
||||
|
||||
for site in scope.sites().select_related("region", "group", "tenant"):
|
||||
blocks.append(H(2, f"Standort {site.name}"))
|
||||
blocks.append(H(2, _("Site %(name)s") % {"name": site.name}))
|
||||
blocks.append(
|
||||
KV(
|
||||
[
|
||||
("Status", site.get_status_display()),
|
||||
("Region", site.region),
|
||||
("Mandant", site.tenant),
|
||||
("Einrichtung", site.facility),
|
||||
("Anschrift", site.physical_address),
|
||||
("Lieferanschrift", site.shipping_address),
|
||||
("Zeitzone", site.time_zone),
|
||||
("Beschreibung", site.description),
|
||||
(_("Status"), site.get_status_display()),
|
||||
(_("Region"), site.region),
|
||||
(_("Tenant"), site.tenant),
|
||||
(_("Facility"), site.facility),
|
||||
(_("Physical address"), site.physical_address),
|
||||
(_("Shipping address"), site.shipping_address),
|
||||
(_("Time zone"), site.time_zone),
|
||||
(_("Description"), site.description),
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -142,20 +144,20 @@ def overview(scope, opts):
|
||||
if locs.exists():
|
||||
blocks.append(
|
||||
T(
|
||||
["Lokation", "Übergeordnet", "Status", "Beschreibung"],
|
||||
[_("Location"), _("Parent"), _("Status"), _("Description")],
|
||||
[[(" " * loc.level) + loc.name, loc.parent, loc.get_status_display(), loc.description] for loc in locs],
|
||||
)
|
||||
)
|
||||
return blocks
|
||||
|
||||
|
||||
@section("contacts", "Ansprechpartner", "Allgemein", hint="Kontakte an Standorten, Lokationen, Mandanten")
|
||||
@section("contacts", gettext_lazy("Contacts"), gettext_lazy("General"), hint=gettext_lazy("Contacts of sites, locations, tenants"))
|
||||
def contacts(scope, opts):
|
||||
ContactAssignment = apps.get_model("tenancy", "ContactAssignment")
|
||||
targets = [
|
||||
(scope.sites(), "Standort"),
|
||||
(scope.location_objects(), "Lokation"),
|
||||
(scope.tenant_objects(), "Mandant"),
|
||||
(scope.sites(), _("Site")),
|
||||
(scope.location_objects(), _("Location")),
|
||||
(scope.tenant_objects(), _("Tenant")),
|
||||
]
|
||||
rows = []
|
||||
for qs, label in targets:
|
||||
@@ -167,41 +169,41 @@ def contacts(scope, opts):
|
||||
rows.append(
|
||||
[f"{label}: {a.object}", a.contact.name, a.role, a.get_priority_display(), a.contact.phone, a.contact.email]
|
||||
)
|
||||
blocks = [H(1, "Ansprechpartner")]
|
||||
blocks = [H(1, _("Contacts"))]
|
||||
if not rows:
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(T(["Zuordnung", "Name", "Rolle", "Priorität", "Telefon", "E-Mail"], rows))
|
||||
blocks.append(T([_("Assigned to"), _("Name"), _("Role"), _("Priority"), _("Phone"), _("Email")], rows))
|
||||
return blocks
|
||||
|
||||
|
||||
@section("racks", "Racks", "Infrastruktur", hint="Nach Standort & Lokation, mit Rack-Ansicht")
|
||||
@section("racks", gettext_lazy("Racks"), gettext_lazy("Infrastructure"), hint=gettext_lazy("By site & location, with rack elevation"))
|
||||
def racks(scope, opts):
|
||||
qs = (
|
||||
scope.racks()
|
||||
.select_related("site", "location", "role", "tenant", "rack_type")
|
||||
.order_by("site__name", "location__name", "name")
|
||||
)
|
||||
blocks = [H(1, "Racks")]
|
||||
blocks = [H(1, _("Racks"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
photos = _rack_photos(scope, opts)
|
||||
for site, site_racks in groupby(qs, key=lambda r: r.site):
|
||||
blocks.append(H(2, f"Standort {site}"))
|
||||
blocks.append(H(2, _("Site %(name)s") % {"name": site}))
|
||||
for location, loc_racks in groupby(site_racks, key=lambda r: r.location):
|
||||
blocks.append(H(3, f"Lokation {location}" if location else "Ohne Lokation"))
|
||||
blocks.append(H(3, _("Location %(name)s") % {"name": location} if location else _("No location")))
|
||||
for rack in loc_racks:
|
||||
rack_heading = H(4, f"Rack {rack.name}")
|
||||
rack_heading = H(4, _("Rack %(name)s") % {"name": rack.name})
|
||||
blocks.append(rack_heading)
|
||||
blocks.append(
|
||||
KV(
|
||||
[
|
||||
("Status", rack.get_status_display()),
|
||||
("Rolle", rack.role),
|
||||
("Typ", rack.rack_type),
|
||||
("Höhe", f"{rack.u_height} HE"),
|
||||
("Facility-ID", rack.facility_id),
|
||||
("Mandant", rack.tenant),
|
||||
("Beschreibung", rack.description),
|
||||
(_("Status"), rack.get_status_display()),
|
||||
(_("Role"), rack.role),
|
||||
(_("Type"), rack.rack_type),
|
||||
(_("Height"), _("%(u)s U") % {"u": rack.u_height}),
|
||||
(_("Facility ID"), rack.facility_id),
|
||||
(_("Tenant"), rack.tenant),
|
||||
(_("Description"), rack.description),
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -212,7 +214,7 @@ def racks(scope, opts):
|
||||
)
|
||||
with_images = bool(opts.get("rack_images"))
|
||||
for face in opts.get("rack_faces") or ["front"]:
|
||||
caption = "Vorderseite" if face == "front" else "Rückseite"
|
||||
caption = _("Front") if face == "front" else _("Rear")
|
||||
svg, svg_error = render_rack_svg(rack, face, scope.user, images=with_images, devices=rack_devs)
|
||||
png = None
|
||||
# PNG wird für Word gebraucht (falls kein cairosvg) und ersetzt ein fehlgeschlagenes SVG
|
||||
@@ -224,7 +226,7 @@ def racks(scope, opts):
|
||||
if svg or png:
|
||||
images.append((svg, caption, png))
|
||||
else:
|
||||
errors.append(f"Rack-Ansicht ({caption}) konnte nicht erzeugt werden: {svg_error}")
|
||||
errors.append(_("Rack elevation (%(face)s) could not be created: %(error)s") % {"face": caption, "error": svg_error})
|
||||
if images:
|
||||
blocks.append(IMAGES(images))
|
||||
blocks += [P(e) for e in errors]
|
||||
@@ -233,7 +235,7 @@ def racks(scope, opts):
|
||||
if devs.exists():
|
||||
blocks.append(
|
||||
T(
|
||||
["HE", "Gerät", "Hersteller / Modell", "Seite"],
|
||||
[_("U"), _("Device"), _("Manufacturer / model"), _("Face")],
|
||||
[
|
||||
[num(d.position) if d.position else EMPTY, d.name, f"{d.device_type.manufacturer} {d.device_type.model}", d.get_face_display() if d.face else EMPTY]
|
||||
for d in devs
|
||||
@@ -270,20 +272,24 @@ def _photo_appendix(opts, rack, rack_heading, atts):
|
||||
return []
|
||||
appendix = opts.setdefault("_appendix", [])
|
||||
if not appendix:
|
||||
appendix.append(H(1, "Anhang: Rack-Fotos"))
|
||||
appendix.append(H(1, _("Appendix: rack photos")))
|
||||
where = " / ".join(str(x) for x in (rack.site, rack.location) if x)
|
||||
heading = H(2, f"Rack {rack.name}" + (f" ({where})" if where else ""))
|
||||
heading = H(2, _("Rack %(name)s") % {"name": rack.name} + (f" ({where})" if where else ""))
|
||||
appendix.append(heading)
|
||||
for i in range(0, len(images), 2): # zwei Fotos je Zeile
|
||||
appendix.append(IMAGES(images[i:i + 2], photos=True))
|
||||
appendix.append(REF("Zurück zur Rack-Ansicht", rack_heading.anchor, prefix="↑ "))
|
||||
appendix.append(REF(_("Back to rack elevation"), rack_heading.anchor, prefix="↑ "))
|
||||
n = len(images)
|
||||
return [REF(f"Anhang Rack-Fotos – Rack {rack.name}", heading.anchor, prefix=f"{n} Foto{'s' if n != 1 else ''}, siehe ")]
|
||||
return [REF(
|
||||
_("Appendix rack photos – rack %(name)s") % {"name": rack.name},
|
||||
heading.anchor,
|
||||
prefix=ngettext("%(n)d photo, see ", "%(n)d photos, see ", n) % {"n": n},
|
||||
)]
|
||||
|
||||
|
||||
@section("devices", "Geräte", "Infrastruktur", hint="Tabellen je Geräterolle")
|
||||
@section("devices", gettext_lazy("Devices"), gettext_lazy("Infrastructure"), hint=gettext_lazy("Tables per device role"))
|
||||
def devices(scope, opts):
|
||||
blocks = [H(1, "Geräte")]
|
||||
blocks = [H(1, _("Devices"))]
|
||||
base = scope.devices().select_related(
|
||||
"device_type__manufacturer", "role", "site", "location", "rack", "platform", "primary_ip4", "primary_ip6", "oob_ip", "tenant"
|
||||
)
|
||||
@@ -297,44 +303,44 @@ def devices(scope, opts):
|
||||
blocks.append(H(2, role.name))
|
||||
if opts.get("group_by_site"):
|
||||
for site, site_devs in groupby(devs, key=lambda d: d.site):
|
||||
blocks.append(H(3, f"Standort {site}"))
|
||||
blocks.append(H(3, _("Site %(name)s") % {"name": site}))
|
||||
blocks.append(_device_table(list(site_devs), columns, opts))
|
||||
else:
|
||||
blocks.append(_device_table(devs, columns, opts))
|
||||
return blocks if found else _empty(opts, blocks)
|
||||
|
||||
|
||||
@section("disks", "Datenträger & RAID", "Infrastruktur", default=False, hint="Aus Netbox-Utilities (falls installiert)")
|
||||
@section("disks", gettext_lazy("Disks & RAID"), gettext_lazy("Infrastructure"), default=False, hint=gettext_lazy("From Netbox-Utilities (if installed)"))
|
||||
def disks(scope, opts):
|
||||
from . import disks_utilities
|
||||
|
||||
blocks = [H(1, "Datenträger & RAID")]
|
||||
blocks = [H(1, _("Disks & RAID"))]
|
||||
if not disks_utilities.is_installed():
|
||||
return _empty(opts, blocks, "Keine Datenträger erfasst.")
|
||||
return _empty(opts, blocks, _("No disks recorded."))
|
||||
blocks += disks_utilities.disk_blocks(scope, opts)
|
||||
return blocks if len(blocks) > 1 else _empty(opts, blocks)
|
||||
|
||||
|
||||
@section("floorplans", "Raumpläne", "Infrastruktur", default=False, hint="Aus NetBox-FloorPlan (falls installiert)")
|
||||
@section("floorplans", gettext_lazy("Floor plans"), gettext_lazy("Infrastructure"), default=False, hint=gettext_lazy("From NetBox-FloorPlan (if installed)"))
|
||||
def floorplans(scope, opts):
|
||||
from . import floorplan
|
||||
|
||||
blocks = [H(1, "Raumpläne")]
|
||||
blocks = [H(1, _("Floor plans"))]
|
||||
if not floorplan.is_installed():
|
||||
return _empty(opts, blocks, "Keine Raumpläne erfasst.")
|
||||
return _empty(opts, blocks, _("No floor plans recorded."))
|
||||
blocks += floorplan.floorplan_blocks(scope, opts)
|
||||
return blocks if len(blocks) > 1 else _empty(opts, blocks, "Keine Raumpläne erfasst.")
|
||||
return blocks if len(blocks) > 1 else _empty(opts, blocks, _("No floor plans recorded."))
|
||||
|
||||
|
||||
@section("power", "Stromversorgung", "Infrastruktur", default=False, hint="Power Panels & Feeds")
|
||||
@section("power", gettext_lazy("Power"), gettext_lazy("Infrastructure"), default=False, hint=gettext_lazy("Power panels & feeds"))
|
||||
def power(scope, opts):
|
||||
qs = scope.power_feeds().select_related("power_panel", "rack").order_by("power_panel__name", "name")
|
||||
blocks = [H(1, "Stromversorgung")]
|
||||
blocks = [H(1, _("Power"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(
|
||||
T(
|
||||
["Panel", "Feed", "Rack", "Status", "Typ", "Phase", "Spannung", "Ampere"],
|
||||
[_("Panel"), _("Feed"), _("Rack"), _("Status"), _("Type"), _("Phase"), _("Voltage"), _("Amperage")],
|
||||
[[f.power_panel, f.name, f.rack, get(f, "status"), get(f, "type"), get(f, "phase"), f"{f.voltage} V", f"{f.amperage} A"] for f in qs],
|
||||
)
|
||||
)
|
||||
@@ -370,10 +376,10 @@ def _vm_totals(vms):
|
||||
)
|
||||
|
||||
|
||||
@section("clusters", "Virtualisierungs-Cluster", "Infrastruktur", default=False, hint="Hosts und Ressourcen je Cluster")
|
||||
@section("clusters", gettext_lazy("Virtualization clusters"), gettext_lazy("Infrastructure"), default=False, hint=gettext_lazy("Hosts and resources per cluster"))
|
||||
def clusters(scope, opts):
|
||||
qs = scope.clusters().select_related("type", "group", "tenant").order_by("group__name", "name")
|
||||
blocks = [H(1, "Virtualisierungs-Cluster")]
|
||||
blocks = [H(1, _("Virtualization clusters"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
vms_by_cluster = {}
|
||||
@@ -395,22 +401,22 @@ def clusters(scope, opts):
|
||||
_mb(disk),
|
||||
])
|
||||
|
||||
details.append(H(2, f"Cluster {cluster.name}"))
|
||||
details.append(H(2, _("Cluster %(name)s") % {"name": cluster.name}))
|
||||
details.append(KV([
|
||||
("Typ", cluster.type),
|
||||
("Gruppe", cluster.group),
|
||||
("Status", get(cluster, "status")),
|
||||
("Zuordnung", getattr(cluster, "scope", None)),
|
||||
("Mandant", cluster.tenant),
|
||||
("Hosts", len(hosts)),
|
||||
("VMs aktiv / gesamt", f"{active} / {len(vms)}"),
|
||||
("Kerne / Threads (Hosts)", f"{p_cores} / {p_threads}" if p_cores else None),
|
||||
("RAM (Hosts)", hardware_utilities.format_memory(p_ram) if p_ram else None),
|
||||
("vCPU (Summe VMs)", num(vcpu) if vcpu else None),
|
||||
("vCPU je Kern", f"{num(round(float(vcpu) / p_cores, 1))} : 1" if vcpu and p_cores else None),
|
||||
("RAM (Summe VMs)", (_mb(ram) + ram_pct) if ram else None),
|
||||
("Speicher (Summe)", _mb(disk) if disk else None),
|
||||
("Beschreibung", cluster.description),
|
||||
(_("Type"), cluster.type),
|
||||
(_("Group"), cluster.group),
|
||||
(_("Status"), get(cluster, "status")),
|
||||
(_("Scope"), getattr(cluster, "scope", None)),
|
||||
(_("Tenant"), cluster.tenant),
|
||||
(_("Hosts"), len(hosts)),
|
||||
(_("VMs active / total"), f"{active} / {len(vms)}"),
|
||||
(_("Cores / threads (hosts)"), f"{p_cores} / {p_threads}" if p_cores else None),
|
||||
(_("RAM (hosts)"), hardware_utilities.format_memory(p_ram) if p_ram else None),
|
||||
(_("vCPU (total of VMs)"), num(vcpu) if vcpu else None),
|
||||
(_("vCPU per core"), f"{num(round(float(vcpu) / p_cores, 1))} : 1" if vcpu and p_cores else None),
|
||||
(_("RAM (total of VMs)"), (_mb(ram) + ram_pct) if ram else None),
|
||||
(_("Storage (total)"), _mb(disk) if disk else None),
|
||||
(_("Description"), cluster.description),
|
||||
]))
|
||||
if hosts:
|
||||
rows = []
|
||||
@@ -427,102 +433,102 @@ def clusters(scope, opts):
|
||||
(f"{num(h_vcpu)} ({num(round(float(h_vcpu) / h_cores, 1))} : 1)" if h_cores else num(h_vcpu)) if h_vcpu else EMPTY,
|
||||
(_mb(h_ram) + (f" ({round(h_ram / (h_pram * 1024) * 100)} %)" if h_pram else "")) if h_ram else EMPTY,
|
||||
])
|
||||
details.append(T(["Host", "Hersteller / Modell", "CPU", "RAM", "VMs", "vCPU", "RAM VMs"], rows))
|
||||
details.append(T([_("Host"), _("Manufacturer / model"), _("CPU"), _("RAM"), _("VMs"), _("vCPU"), _("RAM of VMs")], rows))
|
||||
if any(vm.device_id is None for vm in vms):
|
||||
details.append(P("VMs ohne festen Host sind nur in den Cluster-Summen enthalten."))
|
||||
details.append(P(_("VMs without a fixed host are only included in the cluster totals.")))
|
||||
|
||||
blocks.append(T(["Cluster", "Typ", "Hosts", "VMs aktiv / gesamt", "vCPU / Kerne", "RAM VMs / Hosts", "Speicher"], summary))
|
||||
blocks.append(T([_("Cluster"), _("Type"), _("Hosts"), _("VMs active / total"), _("vCPU / cores"), _("RAM of VMs / hosts"), _("Storage")], summary))
|
||||
return blocks + details
|
||||
|
||||
|
||||
@section("vms", "Virtuelle Maschinen", "Infrastruktur", default=False, hint="Cluster, Ressourcen, IP")
|
||||
@section("vms", gettext_lazy("Virtual machines"), gettext_lazy("Infrastructure"), default=False, hint=gettext_lazy("Cluster, resources, IP"))
|
||||
def vms(scope, opts):
|
||||
qs = scope.virtual_machines().select_related("cluster", "role", "platform", "primary_ip4", "primary_ip6").order_by("cluster__name", "name")
|
||||
blocks = [H(1, "Virtuelle Maschinen")]
|
||||
blocks = [H(1, _("Virtual machines"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(
|
||||
T(
|
||||
["Name", "Cluster", "Rolle", "Status", "OS", "vCPU", "RAM (MB)", "Disk (MB)", "IP"],
|
||||
[_("Name"), _("Cluster"), _("Role"), _("Status"), _("OS"), "vCPU", _("RAM (MB)"), _("Disk (MB)"), "IP"],
|
||||
[[vm.name, vm.cluster, vm.role, get(vm, "status"), vm.platform, vm.vcpus, vm.memory, vm.disk, primary_ips(vm, opts)] for vm in qs],
|
||||
)
|
||||
)
|
||||
return blocks
|
||||
|
||||
|
||||
@section("vrfs", "VRFs", "Netzwerk", hint="Inkl. Route Targets")
|
||||
@section("vrfs", gettext_lazy("VRFs"), gettext_lazy("Network"), hint=gettext_lazy("Including route targets"))
|
||||
def vrfs(scope, opts):
|
||||
qs = scope.vrfs().select_related("tenant").prefetch_related("import_targets", "export_targets").order_by("name")
|
||||
blocks = [H(1, "VRFs")]
|
||||
blocks = [H(1, _("VRFs"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(
|
||||
T(
|
||||
["Name", "RD", "Mandant", "Import-RT", "Export-RT", "Beschreibung"],
|
||||
[_("Name"), "RD", _("Tenant"), _("Import RT"), _("Export RT"), _("Description")],
|
||||
[[v.name, v.rd, v.tenant, v.import_targets, v.export_targets, v.description] for v in qs],
|
||||
)
|
||||
)
|
||||
return blocks
|
||||
|
||||
|
||||
@section("prefixes", "IP-Netze", "Netzwerk", hint="Präfixe gruppiert nach VRF")
|
||||
@section("prefixes", gettext_lazy("IP networks"), gettext_lazy("Network"), hint=gettext_lazy("Prefixes grouped by VRF"))
|
||||
def prefixes(scope, opts):
|
||||
qs = scope.prefixes().select_related("vrf", "vlan", "role", "tenant").order_by("vrf__name", "prefix")
|
||||
qs = qs.filter(prefix__family__in=ip_versions(opts))
|
||||
blocks = [H(1, "IP-Netze")]
|
||||
blocks = [H(1, _("IP networks"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
for vrf, items in groupby(qs, key=lambda p: p.vrf):
|
||||
blocks.append(H(2, f"VRF {vrf}" if vrf else "Global"))
|
||||
blocks.append(H(2, f"VRF {vrf}" if vrf else _("Global")))
|
||||
blocks.append(
|
||||
T(
|
||||
["Präfix", "VLAN", "Rolle", "Status", "Scope", "Beschreibung"],
|
||||
[_("Prefix"), "VLAN", _("Role"), _("Status"), _("Scope"), _("Description")],
|
||||
[[p.prefix, p.vlan, p.role, get(p, "status"), p.scope, p.description] for p in items],
|
||||
)
|
||||
)
|
||||
return blocks
|
||||
|
||||
|
||||
@section("vlans", "VLANs", "Netzwerk", hint="VID, Name, Gruppe, Rolle")
|
||||
@section("vlans", gettext_lazy("VLANs"), gettext_lazy("Network"), hint=gettext_lazy("VID, name, group, role"))
|
||||
def vlans(scope, opts):
|
||||
qs = scope.vlans().select_related("group", "site", "role", "tenant").order_by("group__name", "vid")
|
||||
blocks = [H(1, "VLANs")]
|
||||
blocks = [H(1, _("VLANs"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(
|
||||
T(
|
||||
["VID", "Name", "Gruppe", "Standort", "Rolle", "Status", "Beschreibung"],
|
||||
["VID", _("Name"), _("Group"), _("Site"), _("Role"), _("Status"), _("Description")],
|
||||
[[v.vid, v.name, v.group, v.site, v.role, get(v, "status"), v.description] for v in qs],
|
||||
)
|
||||
)
|
||||
return blocks
|
||||
|
||||
|
||||
@section("ips", "IP-Adressen", "Netzwerk", default=False, hint="Ausführlich – kann lang werden")
|
||||
@section("ips", gettext_lazy("IP addresses"), gettext_lazy("Network"), default=False, hint=gettext_lazy("Detailed – can get long"))
|
||||
def ips(scope, opts):
|
||||
qs = scope.ip_addresses().select_related("vrf", "tenant").prefetch_related("assigned_object").order_by("vrf__name", "address")
|
||||
qs = qs.filter(address__family__in=ip_versions(opts))
|
||||
blocks = [H(1, "IP-Adressen")]
|
||||
blocks = [H(1, _("IP addresses"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
for vrf, items in groupby(qs, key=lambda i: i.vrf):
|
||||
blocks.append(H(2, f"VRF {vrf}" if vrf else "Global"))
|
||||
blocks.append(H(2, f"VRF {vrf}" if vrf else _("Global")))
|
||||
rows = []
|
||||
for ip in items:
|
||||
obj = ip.assigned_object
|
||||
parent = getattr(obj, "parent_object", None)
|
||||
rows.append([ip.address, get(ip, "status"), get(ip, "role"), ip.dns_name, f"{parent} – {obj}" if parent else obj, ip.description])
|
||||
blocks.append(T(["Adresse", "Status", "Rolle", "DNS-Name", "Zugewiesen an", "Beschreibung"], rows))
|
||||
blocks.append(T([_("Address"), _("Status"), _("Role"), _("DNS name"), _("Assigned to"), _("Description")], rows))
|
||||
return blocks
|
||||
|
||||
|
||||
@section("wireless", "WLANs", "Netzwerk", default=False, hint="SSIDs, Authentifizierung")
|
||||
@section("wireless", gettext_lazy("Wireless LANs"), gettext_lazy("Network"), default=False, hint=gettext_lazy("SSIDs, authentication"))
|
||||
def wireless(scope, opts):
|
||||
qs = scope.wireless_lans().select_related("group", "vlan").order_by("ssid")
|
||||
blocks = [H(1, "WLANs")]
|
||||
blocks = [H(1, _("Wireless LANs"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
headers = ["SSID", "Gruppe", "VLAN", "Status", "Authentifizierung", "Verschlüsselung"]
|
||||
headers = ["SSID", _("Group"), "VLAN", _("Status"), _("Authentication"), _("Cipher")]
|
||||
show_psk = opts.get("include_secrets")
|
||||
if show_psk:
|
||||
headers.append("PSK")
|
||||
@@ -536,15 +542,15 @@ def wireless(scope, opts):
|
||||
return blocks
|
||||
|
||||
|
||||
@section("circuits", "Leitungen", "Netzwerk", default=False, hint="Provider, Leitungs-ID, Bandbreite")
|
||||
@section("circuits", gettext_lazy("Circuits"), gettext_lazy("Network"), default=False, hint=gettext_lazy("Provider, circuit ID, bandwidth"))
|
||||
def circuits(scope, opts):
|
||||
qs = scope.circuits().select_related("provider", "type", "tenant").order_by("provider__name", "cid")
|
||||
blocks = [H(1, "Leitungen")]
|
||||
blocks = [H(1, _("Circuits"))]
|
||||
if not qs.exists():
|
||||
return _empty(opts, blocks)
|
||||
blocks.append(
|
||||
T(
|
||||
["Leitungs-ID", "Provider", "Typ", "Status", "Bandbreite (Kbit/s)", "Beschreibung"],
|
||||
[_("Circuit ID"), _("Provider"), _("Type"), _("Status"), _("Commit rate (Kbps)"), _("Description")],
|
||||
[[c.cid, c.provider, c.type, get(c, "status"), c.commit_rate, c.description] for c in qs],
|
||||
)
|
||||
)
|
||||
@@ -558,23 +564,23 @@ DEFAULT_LICENSE_SOURCES = [
|
||||
"model": "netbox_lifecycle.licenseassignment",
|
||||
"device_field": "device",
|
||||
"columns": [
|
||||
("Lizenz", "license"),
|
||||
("Hersteller", "license.manufacturer"),
|
||||
("Gerät", "device"),
|
||||
("Anzahl", "quantity"),
|
||||
("Vertrag", "license.contract"),
|
||||
("Beschreibung", "description"),
|
||||
(gettext_lazy("License"), "license"),
|
||||
(gettext_lazy("Manufacturer"), "license.manufacturer"),
|
||||
(gettext_lazy("Device"), "device"),
|
||||
(gettext_lazy("Quantity"), "quantity"),
|
||||
(gettext_lazy("Contract"), "license.contract"),
|
||||
(gettext_lazy("Description"), "description"),
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@section("licenses", "Lizenzen", "Verträge & Lizenzen", hint="Aus NetBox-SLM oder anderem Lizenz-Plugin")
|
||||
@section("licenses", gettext_lazy("Licenses"), gettext_lazy("Contracts & licenses"), hint=gettext_lazy("From NetBox-SLM or another license plugin"))
|
||||
def licenses(scope, opts):
|
||||
from . import licenses_slm
|
||||
|
||||
sources = get_plugin_config("netbox_customer_export", "license_sources") or DEFAULT_LICENSE_SOURCES
|
||||
blocks = [H(1, "Lizenzen")]
|
||||
blocks = [H(1, _("Licenses"))]
|
||||
found_source = False
|
||||
if licenses_slm.is_installed():
|
||||
found_source = True
|
||||
@@ -595,15 +601,15 @@ def licenses(scope, opts):
|
||||
cols = src["columns"]
|
||||
blocks.append(T([c[0] for c in cols], [[get(o, c[1]) for c in cols] for o in qs]))
|
||||
if not found_source:
|
||||
return _empty(opts, blocks, "Kein Lizenz-Plugin installiert (NetBox-SLM oder netbox-lifecycle) – siehe README.")
|
||||
return _empty(opts, blocks, _("No license plugin installed (NetBox-SLM or netbox-lifecycle) – see README."))
|
||||
return blocks if len(blocks) > 1 else _empty(opts, blocks)
|
||||
|
||||
|
||||
@section("topology", "Netzwerk-Topologie", "Netzwerk", default=False, hint="Diagramm mit Symbolen, wie Packet Tracer")
|
||||
@section("topology", gettext_lazy("Network topology"), gettext_lazy("Network"), default=False, hint=gettext_lazy("Diagram with symbols, like Packet Tracer"))
|
||||
def topology(scope, opts):
|
||||
from .topology import build_graphs, build_location_graphs, render_png
|
||||
|
||||
title = H(1, "Netzwerk-Topologie")
|
||||
title = H(1, _("Network topology"))
|
||||
scopes = opts.get("topo_scope") or ["site"]
|
||||
ports = "ports" in (opts.get("topo_details") or [])
|
||||
pages = [] # (Überschriften, Graph) – je eine Querformat-Seite
|
||||
@@ -611,15 +617,15 @@ def topology(scope, opts):
|
||||
pages += [([H(2, g.title)], g) for g in build_graphs(scope, opts, per="site")]
|
||||
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)]
|
||||
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, "Standortübergreifende Lokationsübersicht")], g) for g in build_location_graphs(scope, opts, combined=True)]
|
||||
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)
|
||||
pages += [(([H(2, "Topologie je Rack")] if i == 0 else []) + [H(3, g.title)], g) for i, g in enumerate(racks)]
|
||||
pages += [(([H(2, _("Topology per rack"))] if i == 0 else []) + [H(3, g.title)], g) for i, g in enumerate(racks)]
|
||||
if not pages:
|
||||
return _empty(opts, [title], "Keine verkabelten Geräte gefunden.")
|
||||
return _empty(opts, [title], _("No cabled devices found."))
|
||||
# Die Abschnittsüberschrift steht mit auf der ersten Seite
|
||||
return [
|
||||
LANDSCAPE(([title] if i == 0 else []) + headings, render_png(g, show_ports=ports))
|
||||
|
||||
Reference in new issue
Block a user