Skip to content

ISO/VMID become Rax's own concerns; rack list shows pool + position

Summary

Four related changes from operator feedback on the current UI:

  1. 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.BuildDeviceSpec no longer reads the old iso_choice custom field at all (confirmed by a test: the field is still present in a fixture's custom_fields and 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 via POST /devices/{id}/iso to a new device_iso_choices store table, and merged into the spec by loadDeviceContext before diff/apply ever run.
  2. 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 (see netbox.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.
  3. Rack device list: swapped the Role column for Pool (parsed from the device name, the same convention BuildDeviceSpec already uses) and added a Position column (NetBox's rack-unit position for the device) ahead of the Device column.
  4. 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), updated internal/netbox/list_test.go and internal/netbox/spec_test.go for 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

🤖 Generated with Claude Code

https://claude.ai/code/session_01U9buZPRQy7YXLodkSPFFik

Merge request reports

Loading