Initial implementation: host lifecycle + PXE + admin dashboard
Go service for Proxmox homelab cluster provisioning. Handles PXE boot, Proxmox autoinstall (answer file generation), cluster join via SSH, and Infrastructure API registration. - Host state machine (registered → pxe_ready → installing → ready) - dnsmasq supervisor with MAC-based allowlist - iPXE script and Proxmox answer file generation - First-boot phone-home → cluster join → infra registration - Operation locking with expiry (409 on conflict) - SSE event hub for real-time dashboard updates - Admin dashboard (host grid, detail, registration form) - Config-driven server types with hot-reload - Docker deployment (multi-stage fat image) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type HostState string
|
||||
|
||||
const (
|
||||
StateRegistered HostState = "registered"
|
||||
StatePXEReady HostState = "pxe_ready"
|
||||
StatePXEBooted HostState = "pxe_booted"
|
||||
StateInstalling HostState = "installing"
|
||||
StateInstalled HostState = "installed"
|
||||
StateFirstBoot HostState = "first_boot"
|
||||
StateJoining HostState = "joining"
|
||||
StateReady HostState = "ready"
|
||||
StateFailed HostState = "failed"
|
||||
)
|
||||
|
||||
type Host struct {
|
||||
ID int64
|
||||
Hostname string
|
||||
MAC string
|
||||
ServerType string
|
||||
State HostState
|
||||
IPAddress string
|
||||
HardwareID string
|
||||
InfraHostID int64
|
||||
Notes string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type OperationKind string
|
||||
|
||||
const (
|
||||
OpRebuildProxmox OperationKind = "rebuild_proxmox"
|
||||
)
|
||||
|
||||
type OperationState string
|
||||
|
||||
const (
|
||||
OpActive OperationState = "active"
|
||||
OpCompleted OperationState = "completed"
|
||||
OpFailed OperationState = "failed"
|
||||
)
|
||||
|
||||
type Operation struct {
|
||||
ID int64
|
||||
HostID int64
|
||||
Kind OperationKind
|
||||
State OperationState
|
||||
ImageID int64
|
||||
StartedAt time.Time
|
||||
CompletedAt *time.Time
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
ID int64
|
||||
Name string
|
||||
Kind string
|
||||
Version string
|
||||
KernelPath string
|
||||
InitrdPath string
|
||||
IsDefault bool
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type ServerType struct {
|
||||
Key string
|
||||
DisplayName string `yaml:"display_name"`
|
||||
BootDisk string `yaml:"boot_disk"`
|
||||
ManagementNIC string `yaml:"management_nic"`
|
||||
GPU bool `yaml:"gpu"`
|
||||
HostnamePrefix string `yaml:"hostname_prefix"`
|
||||
ExpectedNICs []NICDef `yaml:"expected_nics"`
|
||||
}
|
||||
|
||||
type NICDef struct {
|
||||
Name string `yaml:"name"`
|
||||
Speed string `yaml:"speed"`
|
||||
}
|
||||
Reference in New Issue
Block a user