virtigod does xml generate now

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-26 12:32:52 -05:00
parent 5406da8e75
commit a2190048af
2 changed files with 9 additions and 7 deletions

View File

@ -29,21 +29,24 @@ func makeStandardXml(hostname string) *libvirtxml.Domain {
}
*/
func writeoutXml(domcfg *libvirtxml.Domain, filename string) bool {
func writeoutXml(domcfg *libvirtxml.Domain, filename string) error {
xmldoc, err := domcfg.Marshal()
if err != nil {
fmt.Println("can't make xml file error:\n", err)
return false
return err
}
outfile := "/tmp/" + filename + ".xml"
regfile, _ := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE, 0666)
regfile, err := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
return err
}
fmt.Fprintln(regfile, xmldoc)
log.Info("File is in", outfile)
regfile.Close()
return true
return nil
}
func setDiskFilename(domcfg *libvirtxml.Domain, filename string) {

View File

@ -14,7 +14,7 @@ import (
)
// generate the XML for 'virsh create'
func StartDropletXml(cluster *pb.Cluster, d *pb.Droplet, domcfg *libvirtxml.Domain, hostname string) {
func GenerateDropletXml(cluster *pb.Cluster, d *pb.Droplet, domcfg *libvirtxml.Domain, hostname string) error {
/*
if d == nil {
log.Info("droplet is nil")
@ -87,8 +87,7 @@ func StartDropletXml(cluster *pb.Cluster, d *pb.Droplet, domcfg *libvirtxml.Doma
}
}
writeoutXml(domcfg, d.Hostname)
os.Exit(-1)
return writeoutXml(domcfg, d.Hostname)
}
func findDisk(dirs []string, filename string) string {