From 3cf26c8dedc8c41384d3e6b1fdcc44d9420891aa Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 21 Oct 2026 08:30:49 +0200 Subject: [PATCH] feat: optional disk install date in disks export Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- netbox_customer_export/__init__.py | 2 +- netbox_customer_export/disks_utilities.py | 13 ++++++++----- netbox_customer_export/forms.py | 2 ++ .../templates/netbox_customer_export/export.html | 8 ++++++++ pyproject.toml | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d03c6ae..2bcb1bf 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,7 @@ The **license key** only appears with the "Export secrets" option (requires If [Netbox-Utilities](https://git.mrblake.cc/MrBlake/Netbox-Utilities) with disk management is installed, the **Disks & RAID** section (off by default) lists for each device in scope: occupied slots, raw capacity, hot spares and failed disks, the RAID groups (level, count, usable capacity, fault tolerance) and a table of all installed disks with -slot, status, type, model, size, serial number, firmware, RAID group, warranty and warnings (failed, warranty +slot, status, type, model, size, serial number, firmware, RAID group, optionally the install date, warranty and warnings (failed, warranty expired/expiring soon, too old – thresholds from the Utilities configuration). Removed disks (history) are not shown. Without the plugin the section stays empty. diff --git a/netbox_customer_export/__init__.py b/netbox_customer_export/__init__.py index a984835..5715091 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.10.0" + version = "0.11.0" author = "Claude" base_url = "customer-export" min_version = "4.6.8" diff --git a/netbox_customer_export/disks_utilities.py b/netbox_customer_export/disks_utilities.py index e7f118a..fb73733 100644 --- a/netbox_customer_export/disks_utilities.py +++ b/netbox_customer_export/disks_utilities.py @@ -52,7 +52,9 @@ def disk_blocks(scope, opts): for disk in disks: by_device.setdefault(disk.device, []).append(disk) - headers = ["Steckplatz", "Status", "Typ", "Hersteller / Modell", "Größe", "Seriennummer", "Firmware", "RAID", "Garantie bis", "Hinweise"] + show_installed = bool(opts.get("disk_install_date")) + headers = ["Steckplatz", "Status", "Typ", "Hersteller / Modell", "Größe", "Seriennummer", "Firmware", "RAID"] + headers += ["Eingebaut"] * show_installed + ["Garantie bis", "Hinweise"] blocks = [] for device, items in by_device.items(): slots = sum(b.slot_count for b in DiskBayLayout.objects.filter(device=device)) @@ -84,7 +86,7 @@ def disk_blocks(scope, opts): rows = [] for d in items: hints = "\n".join(text for _lvl, text in helpers.disk_warnings(d, **warn_cfg)) - rows.append([ + row = [ _slot(d), d.get_status_display(), " / ".join(x for x in (d.get_disk_type_display(), d.get_interface_display()) if x), @@ -93,8 +95,9 @@ def disk_blocks(scope, opts): d.serial, d.firmware, d.raid_group, - _date(d.warranty_end), - hints, - ]) + ] + if show_installed: + row.append(_date(getattr(d, "install_date", None))) + rows.append(row + [_date(d.warranty_end), hints]) blocks.append(T(headers, rows)) return blocks diff --git a/netbox_customer_export/forms.py b/netbox_customer_export/forms.py index a11f755..4948d3a 100644 --- a/netbox_customer_export/forms.py +++ b/netbox_customer_export/forms.py @@ -53,6 +53,8 @@ class ExportForm(forms.Form): ) group_by_site = forms.BooleanField(required=False, initial=True, label="Geräte nach Standort gruppieren") + disk_install_date = forms.BooleanField(required=False, initial=False, label="Einbaudatum der Datenträger anzeigen") + rack_svg = forms.BooleanField(required=False, initial=True, label="Rack-Ansichten (SVG) einbetten") rack_images = forms.BooleanField(required=False, initial=False, label="Gerätebilder anzeigen (wie in NetBox)") rack_faces = forms.MultipleChoiceField( diff --git a/netbox_customer_export/templates/netbox_customer_export/export.html b/netbox_customer_export/templates/netbox_customer_export/export.html index 6502e82..9d68f82 100644 --- a/netbox_customer_export/templates/netbox_customer_export/export.html +++ b/netbox_customer_export/templates/netbox_customer_export/export.html @@ -122,6 +122,14 @@ +
+
+

Datenträger

+
+ +
+
+

diff --git a/pyproject.toml b/pyproject.toml index 14a7e2d..b8fa5bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-customer-export" -version = "0.10.0" +version = "0.11.0" description = "NetBox-Plugin: Kundendokumentation (PDF/Word) für Standorte, Lokationen, Mandanten und Mandantengruppen" readme = "README.md" requires-python = ">=3.10"