ISO/VMID become Rax's own concerns; rack list shows pool + position
Summary
Four related changes from operator feedback on the current UI:
-
ISO/CT-template choice moves entirely out of NetBox. NetBox has no
idea what's actually on a node's ISO/template storage, so it can't offer
a validated choice —
netbox.BuildDeviceSpecno longer reads the oldiso_choicecustom field at all (confirmed by a test: the field is still present in a fixture'scustom_fieldsand BuildDeviceSpec is asserted to ignore it). It's picked through a new dropdown on the device detail page (built from the live ISO/CT-template storage listing Rax already fetches), saved immediately viaPOST /devices/{id}/isoto a newdevice_iso_choicesstore table, and merged into the spec byloadDeviceContextbefore diff/apply ever run. -
VMID visibility, not a behavior change. Apply already only ever
allocates a VMID (
proxmox.NextFreeVMID) and writes it back to NetBox after a successful create — that's a deliberate safety property (seenetbox.Client.SetDeviceVMID's doc comment: a generated VMID means nothing until it's actually live) and stays exactly as it was. What was missing was visibility: the device detail page now computes and shows the VMID Rax would assign for a not-yet-provisioned device with a bound rack — "not yet provisioned — Rax will assign 100" — purely a preview, never persisted or written to NetBox ahead of an actual create. -
Rack device list: swapped the Role column for Pool (parsed from the
device name, the same convention
BuildDeviceSpecalready uses) and added a Position column (NetBox's rack-unit position for the device) ahead of the Device column. - Add-IP placeholder on the device detail page now shows an IPv6 example instead of IPv4.
Also — answering "do I need to add custom fields to NetBox myself, or does
Rax create them": Rax never creates or manages NetBox schema, custom
field definitions are a one-time NetBox-admin task. Added a README section
listing exactly which fields Rax expects (VMID, cpu, ram_gb,
disk_gb, plan_label on dcim.device; vswitch on dcim.interface;
Klient_ID on tenancy.tenant) — iso_choice is explicitly not on that
list anymore.
Test plan
-
gofmt -s -w . && gofmt -l . && go build ./... && go vet ./... && go test ./...— clean -
New tests: internal/store/iso_choice_test.go(get/set/upsert/clear/ delete),internal/web/iso_choice_test.go(handler success + CSRF requirement + device detail page shows a stored choice as selected in the dropdown), updatedinternal/netbox/list_test.goandinternal/netbox/spec_test.gofor the Position/PoolName and ISOChoice-must-not-be-read-from-NetBox changes -
Manually rendered the device detail page (via the existing web-package test fixtures, VMID=0 + a bound rack + a fake ISO listing) and confirmed both the ISO <select>and the "Rax will assign 100" VMID preview render correctly