Files
ilkerandClaude Opus 5.5 e7b3d30105 placement: whole machines, held one cluster at a time
A compute node on a bare-metal site is given a whole machine: Node.Machine
marks one, HeadOnly marks the hypervisor beside them that runs heads, and
AllocatedTo says who has a machine. Placement takes a machine whole, never
puts a head on one or compute on a head-only host. The database holds each
machine for one live cluster (cluster_machine, migration 010), from the
moment it is recorded, and Reservations reports it with no device id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:34:12 +01:00

25 lines
769 B
Go

package store
import "github.com/ilkermanap/hpcod/internal/placement"
// PlacementFrom is what gets recorded for the candidate the planner chose.
// Shared by everything that allocates - the portal's pages, its API, and
// setup's self-test - so a cluster is recorded the same way whichever of
// them asked for it.
func PlacementFrom(c placement.Candidate) Placement {
p := Placement{Site: c.SiteID}
for _, vm := range c.Placement {
sv := VM{
Role: vm.Role, NodeIndex: vm.Index, HostNode: vm.HostNode,
Cores: vm.Cores, MemoryGB: vm.MemoryGB, Machine: vm.Machine,
}
for _, d := range vm.Devices {
sv.Devices = append(sv.Devices, Device{
NativeID: d.NativeID, Capability: string(d.Capability),
})
}
p.VMs = append(p.VMs, sv)
}
return p
}