virtigo/start.go

64 lines
1.3 KiB
Go

// 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) {
meDrop := findDroplet(start)
d := meDrop.pb
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(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))
}
/*
func findDisk(filename string) string {
for _, dirname := range me.cluster.Dirs {
// log.Info("look in dir", dirname)
var count int
newdir, _ := os.ReadDir(dirname)
for _, file := range newdir {
count += 1
if file.Name() == filename {
log.Info("Found file", filename, "in", dirname)
return filepath.Join(dirname, file.Name())
}
}
if count == 0 {
log.Info("Warning? dirname", dirname, "was empty. Not mounted?")
}
}
return ""
}
*/