39 lines
886 B
Go
39 lines
886 B
Go
// Copyright 2024 WIT.COM Inc Licensed GPL 3.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"errors"
|
|
|
|
pb "go.wit.com/lib/protobuf/virtbuf"
|
|
"go.wit.com/lib/virtigoxml"
|
|
"go.wit.com/log"
|
|
"libvirt.org/go/libvirtxml"
|
|
)
|
|
|
|
func newStart(start string, d *pb.Droplet) error {
|
|
if d == nil {
|
|
log.Info("log.Info: droplet is unknown:", start)
|
|
return errors.New("droplet is unknown: " + start)
|
|
}
|
|
log.Info("start droplet here:", d.Hostname)
|
|
domcfg := &libvirtxml.Domain{}
|
|
|
|
mergeXML(domcfg, "standard.x86")
|
|
mergeXML(domcfg, "spice")
|
|
mergeXML(domcfg, "qcow")
|
|
|
|
return virtigoxml.GenerateDropletXml(me.dirs, d, domcfg, start)
|
|
}
|
|
|
|
func mergeXML(domcfg *libvirtxml.Domain, filename string) error {
|
|
fullname := "resources/xml/" + filename + ".xml"
|
|
pfile, err := resources.ReadFile(fullname)
|
|
if err != nil {
|
|
log.Println("ERROR:", err)
|
|
return err
|
|
}
|
|
|
|
return virtigoxml.AddDefaultXml(domcfg, string(pfile))
|
|
}
|