f-28: api: add uefi params

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-05-23 22:26:21 +02:00
commit 325f1acff5
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
5 changed files with 15 additions and 0 deletions

View file

@ -49,6 +49,7 @@ type VMCreateRequest struct {
Name string `json:"name"`
Memory int `json:"memory"`
CPUs int `json:"cpus"`
UEFI bool `json:"uefi"`
Password string `json:"password"`
SSHKey string `json:"sshkey"`
Interfaces []VMInterface `json:"interfaces"`
@ -61,6 +62,7 @@ type VM struct {
MetadataPort string `json:"metadata_port"`
Memory int `json:"memory"`
CPUs int `json:"cpus"`
UEFI bool `json:"uefi"`
Interfaces []VMInterface `json:"interfaces"`
Storage []VMStorage `json:"storage"`
}

View file

@ -79,6 +79,7 @@ func vmFromDB(name string, entries map[string]string) (VM, error) {
vm.MetadataPort = entries[prefix+"metadata_port"]
vm.Memory, _ = strconv.Atoi(entries[prefix+"memory"])
vm.CPUs, _ = strconv.Atoi(entries[prefix+"cpus"])
vm.UEFI = entries[prefix+"uefi"] == "true"
subnet := entries[prefix+"subnet"]
ip := entries[prefix+"ip"]

View file

@ -84,6 +84,7 @@ func (s *Server) startVM(w http.ResponseWriter, r *http.Request) {
VolumePath: req.Storage[0].Path,
Memory: req.Memory,
CPUs: req.CPUs,
UEFI: req.UEFI,
Password: req.Password,
SSHKey: req.SSHKey,
}

View file

@ -20,6 +20,7 @@ type StartVMCommand struct {
VolumePath string
Memory int
CPUs int
UEFI bool
Password string
SSHKey string
}
@ -46,6 +47,9 @@ func (c StartVMCommand) Prepare(db *badger.DB, _ *configuration.Config) error {
kv.AddInDB(db, "vm/"+c.Name+"/volume_path", c.VolumePath)
kv.AddInDB(db, "vm/"+c.Name+"/memory", strconv.Itoa(c.Memory))
kv.AddInDB(db, "vm/"+c.Name+"/cpus", strconv.Itoa(c.CPUs))
if c.UEFI {
kv.AddInDB(db, "vm/"+c.Name+"/uefi", "true")
}
if c.Password != "" {
kv.AddInDB(db, "vm/"+c.Name+"/password", c.Password)
}