writes out xml that works with virsh
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
fd85215d57
commit
7b83c8e7db
|
@ -14,6 +14,7 @@ import (
|
||||||
"libvirt.org/go/libvirtxml"
|
"libvirt.org/go/libvirtxml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
func makeStandardXml(hostname string) *libvirtxml.Domain {
|
func makeStandardXml(hostname string) *libvirtxml.Domain {
|
||||||
log.Info("create new xml file for:", hostname)
|
log.Info("create new xml file for:", hostname)
|
||||||
domcfg := &libvirtxml.Domain{}
|
domcfg := &libvirtxml.Domain{}
|
||||||
|
@ -26,6 +27,7 @@ func makeStandardXml(hostname string) *libvirtxml.Domain {
|
||||||
|
|
||||||
return domcfg
|
return domcfg
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func writeoutXml(domcfg *libvirtxml.Domain, filename string) bool {
|
func writeoutXml(domcfg *libvirtxml.Domain, filename string) bool {
|
||||||
xmldoc, err := domcfg.Marshal()
|
xmldoc, err := domcfg.Marshal()
|
||||||
|
@ -59,7 +61,7 @@ func setDiskFilename(domcfg *libvirtxml.Domain, filename string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addDefaultXml(d *libvirtxml.Domain, filename string) {
|
func AddDefaultXml(d *libvirtxml.Domain, filename string) error {
|
||||||
/*
|
/*
|
||||||
fullname := "resources/xml/" + filename + ".xml"
|
fullname := "resources/xml/" + filename + ".xml"
|
||||||
pfile, err := resources.ReadFile(fullname)
|
pfile, err := resources.ReadFile(fullname)
|
||||||
|
@ -72,11 +74,11 @@ func addDefaultXml(d *libvirtxml.Domain, filename string) {
|
||||||
err := d.Unmarshal(filename)
|
err := d.Unmarshal(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("Marshal failed on file", filename)
|
log.Info("Marshal failed on file", filename)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func readXml(filename string) (*libvirtxml.Domain, error) {
|
func ReadXml(filename string) (*libvirtxml.Domain, error) {
|
||||||
log.Verbose("parse xml file:", filename)
|
log.Verbose("parse xml file:", filename)
|
||||||
|
|
||||||
hostname := filepath.Base(filename)
|
hostname := filepath.Base(filename)
|
||||||
|
@ -241,7 +243,7 @@ func setRandomMacs(domcfg *libvirtxml.Domain) {
|
||||||
// that is "standard". This is just a way to double check that
|
// that is "standard". This is just a way to double check that
|
||||||
// there might be something interesting in a VM
|
// there might be something interesting in a VM
|
||||||
// 'standard' here means what I think is standard
|
// 'standard' here means what I think is standard
|
||||||
func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
func DumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
||||||
// dump type
|
// dump type
|
||||||
if domcfg.Type == "kvm" {
|
if domcfg.Type == "kvm" {
|
||||||
domcfg.Type = ""
|
domcfg.Type = ""
|
||||||
|
@ -762,7 +764,7 @@ func warnUserOfNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump out all the fields in libvirtxml.DomainDeviceList
|
// dump out all the fields in libvirtxml.DomainDeviceList
|
||||||
func dumpLibvirtxmlDomainNames() {
|
func DumpLibvirtxmlDomainNames() {
|
||||||
var domain libvirtxml.Domain
|
var domain libvirtxml.Domain
|
||||||
t := reflect.TypeOf(domain)
|
t := reflect.TypeOf(domain)
|
||||||
|
|
||||||
|
|
4
start.go
4
start.go
|
@ -14,7 +14,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// generate the XML for 'virsh create'
|
// generate the XML for 'virsh create'
|
||||||
func startDropletXml(d *pb.Droplet) {
|
func StartDropletXml(d *pb.Droplet, domcfg *libvirtxml.Domain, hostname string) {
|
||||||
|
/*
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Info("droplet is nil")
|
log.Info("droplet is nil")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -27,6 +28,7 @@ func startDropletXml(d *pb.Droplet) {
|
||||||
// addDefaultXml(domcfg, "network")
|
// addDefaultXml(domcfg, "network")
|
||||||
addDefaultXml(domcfg, "spice")
|
addDefaultXml(domcfg, "spice")
|
||||||
addDefaultXml(domcfg, "qcow")
|
addDefaultXml(domcfg, "qcow")
|
||||||
|
*/
|
||||||
|
|
||||||
domcfg.Type = "kvm"
|
domcfg.Type = "kvm"
|
||||||
domcfg.Name = d.Hostname
|
domcfg.Name = d.Hostname
|
||||||
|
|
Loading…
Reference in New Issue