feat: add disk management tab for servers, NAS, SAN and MSA devices
Devices whose role is one of disk_device_roles (default Server, NAS, SAN, MSA) get a "Datenträger" tab with slot layout, disks, RAID groups, warranty and age warnings, replacement history, CSV import, REST API and GraphQL. - First-visit wizard for slot count, rows, first slot number, numbering and form factor; layouts can be saved as device type templates and applied with one click. - Slot grid drawn like the device front, coloured by status, with warning icons; free slots open a pre-filled disk form. - Bulk fill of selected slots with shared attributes and one serial per line (barcode scanner friendly), with live count and duplicate checks. - Sizes in vendor notation (960 GB, 4 TB, 1,92 TB, 2 TiB); the tenant is always taken from the device and follows tenant changes. - RAID groups (RAID 0/1/5/6/10/50/60, RAID-Z1/Z2/Z3, JBOD) with hot spares, usable capacity, tolerated failures and degraded state. - "Ersetzen" marks a disk as removed and opens the successor form; removed disks stay as per-slot history. - Warnings for failed disks, expired or expiring warranties and disks older than disk_age_warning_years. - Global disk list with filters, export, global search by serial, optional device list column, CSV import, REST API and GraphQL. - New settings: disks_enabled, disk_device_roles, disk_age_warning_years, disk_warranty_warning_days. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
cbb8128385
commit
adbd697c0a
29 files changed
+3412
-7
No files matched your search
@@ -0,0 +1,84 @@
|
||||
from typing import TYPE_CHECKING, Annotated
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from netbox.graphql.types import NetBoxObjectType
|
||||
|
||||
from .models import Disk, DiskBayLayout, DiskBayTemplate, RAIDGroup
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import DeviceType, DeviceTypeType
|
||||
from tenancy.graphql.types import TenantType
|
||||
|
||||
LAYOUT_FIELDS = ["id", "slot_count", "rows", "first_slot", "numbering", "form_factor"]
|
||||
|
||||
|
||||
@strawberry_django.type(RAIDGroup, fields=["id", "name", "level", "spans", "description"])
|
||||
class NetBoxUtilitiesRAIDGroupType(NetBoxObjectType):
|
||||
device: Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")]
|
||||
disks: list[Annotated["NetBoxUtilitiesDiskType", strawberry.lazy("netbox_utilities.graphql")]]
|
||||
|
||||
@strawberry_django.field
|
||||
def usable_capacity_gb(self) -> int | None:
|
||||
return self.usable_capacity_gb
|
||||
|
||||
@strawberry_django.field
|
||||
def is_degraded(self) -> bool:
|
||||
return self.is_degraded
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
Disk,
|
||||
fields=[
|
||||
"id",
|
||||
"slot",
|
||||
"status",
|
||||
"disk_type",
|
||||
"interface",
|
||||
"form_factor",
|
||||
"manufacturer",
|
||||
"model",
|
||||
"capacity_gb",
|
||||
"serial",
|
||||
"firmware",
|
||||
"manufacture_date",
|
||||
"install_date",
|
||||
"removal_date",
|
||||
"warranty_end",
|
||||
"description",
|
||||
"comments",
|
||||
],
|
||||
)
|
||||
class NetBoxUtilitiesDiskType(NetBoxObjectType):
|
||||
device: Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")]
|
||||
tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
|
||||
raid_group: Annotated["NetBoxUtilitiesRAIDGroupType", strawberry.lazy("netbox_utilities.graphql")] | None
|
||||
|
||||
@strawberry_django.field
|
||||
def warnings(self) -> list[str]:
|
||||
return [text for _, text in self.warnings]
|
||||
|
||||
|
||||
@strawberry_django.type(DiskBayLayout, fields=LAYOUT_FIELDS)
|
||||
class NetBoxUtilitiesDiskBayLayoutType(NetBoxObjectType):
|
||||
device: Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")]
|
||||
|
||||
|
||||
@strawberry_django.type(DiskBayTemplate, fields=LAYOUT_FIELDS)
|
||||
class NetBoxUtilitiesDiskBayTemplateType(NetBoxObjectType):
|
||||
device_type: Annotated["DeviceTypeType", strawberry.lazy("dcim.graphql.types")]
|
||||
|
||||
|
||||
@strawberry.type(name="Query")
|
||||
class NetBoxUtilitiesDiskQuery:
|
||||
netbox_utilities_disk: NetBoxUtilitiesDiskType = strawberry_django.field()
|
||||
netbox_utilities_disk_list: list[NetBoxUtilitiesDiskType] = strawberry_django.field()
|
||||
netbox_utilities_raid_group: NetBoxUtilitiesRAIDGroupType = strawberry_django.field()
|
||||
netbox_utilities_raid_group_list: list[NetBoxUtilitiesRAIDGroupType] = strawberry_django.field()
|
||||
netbox_utilities_disk_bay_layout: NetBoxUtilitiesDiskBayLayoutType = strawberry_django.field()
|
||||
netbox_utilities_disk_bay_layout_list: list[NetBoxUtilitiesDiskBayLayoutType] = strawberry_django.field()
|
||||
netbox_utilities_disk_bay_template: NetBoxUtilitiesDiskBayTemplateType = strawberry_django.field()
|
||||
netbox_utilities_disk_bay_template_list: list[NetBoxUtilitiesDiskBayTemplateType] = strawberry_django.field()
|
||||
|
||||
|
||||
schema = [NetBoxUtilitiesDiskQuery]
|
||||
Reference in new issue
Block a user