virtigod/start.go

41 lines
880 B
Go
Raw Normal View History

// Copyright 2024 WIT.COM Inc Licensed GPL 3.0
package main
import (
"os"
"go.wit.com/lib/virtigoxml"
"go.wit.com/log"
"libvirt.org/go/libvirtxml"
)
func newStart(start string) {
d := me.cluster.FindDroplet(start)
if d == nil {
log.Info("droplet is unknown:", start)
os.Exit(0)
}
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")
virtigoxml.StartDropletXml(me.cluster, d, domcfg, start)
}
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))
}