2024-10-26 10:34:04 -05:00
|
|
|
// Copyright 2024 WIT.COM Inc Licensed GPL 3.0
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-10-26 12:32:37 -05:00
|
|
|
"errors"
|
2024-10-26 10:34:04 -05:00
|
|
|
|
|
|
|
"go.wit.com/lib/virtigoxml"
|
|
|
|
"go.wit.com/log"
|
|
|
|
"libvirt.org/go/libvirtxml"
|
|
|
|
)
|
|
|
|
|
2024-10-26 12:32:37 -05:00
|
|
|
func newStart(start string) error {
|
2024-10-26 10:34:04 -05:00
|
|
|
d := me.cluster.FindDroplet(start)
|
|
|
|
if d == nil {
|
|
|
|
log.Info("droplet is unknown:", start)
|
2024-10-26 12:32:37 -05:00
|
|
|
return errors.New("droplet is unknown: " + start)
|
2024-10-26 10:34:04 -05:00
|
|
|
}
|
|
|
|
log.Info("start droplet here:", d.Hostname)
|
|
|
|
domcfg := &libvirtxml.Domain{}
|
|
|
|
|
|
|
|
newAddXml(domcfg, "standard.x86")
|
|
|
|
// addDefaultXml(domcfg, "memory")
|
|
|
|
// addDefaultXml(domcfg, "network")
|
|
|
|
newAddXml(domcfg, "spice")
|
|
|
|
newAddXml(domcfg, "qcow")
|
|
|
|
|
2024-10-26 12:32:37 -05:00
|
|
|
return virtigoxml.GenerateDropletXml(me.cluster, d, domcfg, start)
|
2024-10-26 10:34:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func newAddXml(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))
|
|
|
|
}
|