parent
53a88a1c5c
commit
eab1a35ca5
|
@ -36,7 +36,7 @@ func AddDomainDroplet(cluster *pb.NewCluster, domcfg *libvirtxml.Domain) (*pb.Dr
|
|||
}
|
||||
}
|
||||
|
||||
alle, err = updateDroplet(d, domcfg)
|
||||
alle, err = MergelibvirtDomain(d, domcfg)
|
||||
if err != nil {
|
||||
log.Info("updateDroplet() failed for", d.Hostname)
|
||||
return d, alle, errors.New("update failed for " + domcfg.Name)
|
||||
|
@ -87,7 +87,8 @@ func findDomain(c *pb.NewCluster, domcfg *libvirtxml.Domain) (*pb.Droplet, error
|
|||
return found, nil
|
||||
}
|
||||
|
||||
func updateDroplet(d *pb.Droplet, domcfg *libvirtxml.Domain) ([]*pb.Event, error) {
|
||||
// merges and updates the droplet protobuf based on the libvirt XML
|
||||
func MergelibvirtDomain(d *pb.Droplet, domcfg *libvirtxml.Domain) ([]*pb.Event, error) {
|
||||
var alle []*pb.Event
|
||||
|
||||
if d == nil {
|
||||
|
|
|
@ -475,5 +475,36 @@ func DumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
|||
domcfg.Devices.Videos = nil
|
||||
}
|
||||
|
||||
var normalAudio bool = true
|
||||
if domcfg.Devices.Audios != nil {
|
||||
for _, a := range domcfg.Devices.Audios {
|
||||
if a.SPICE != nil {
|
||||
// nothing to do for this
|
||||
} else {
|
||||
fmt.Printf("? Audio: %+v\n", a)
|
||||
normalAudio = false
|
||||
}
|
||||
}
|
||||
}
|
||||
if normalAudio {
|
||||
domcfg.Devices.Audios = nil
|
||||
}
|
||||
|
||||
var normalWatchdog bool = true
|
||||
if domcfg.Devices.Watchdogs != nil {
|
||||
for _, dog := range domcfg.Devices.Watchdogs {
|
||||
// fmt.Printf("? Watchdog: %+v\n", dog)
|
||||
if dog.Model == "itco" {
|
||||
// nothing to do for this
|
||||
} else {
|
||||
fmt.Printf("? Watchdog: %+v\n", dog)
|
||||
normalWatchdog = false
|
||||
}
|
||||
}
|
||||
}
|
||||
if normalWatchdog {
|
||||
domcfg.Devices.Watchdogs = nil
|
||||
}
|
||||
|
||||
return finalEmptyCheck(domcfg)
|
||||
}
|
||||
|
|
22
importXML.go
22
importXML.go
|
@ -3,32 +3,27 @@
|
|||
package virtigolib
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
"libvirt.org/go/libvirtxml"
|
||||
)
|
||||
|
||||
// import a libvirt xml domain
|
||||
func ImportXML(domcfg *libvirtxml.Domain) (*pb.Droplet, []*pb.Event, error) {
|
||||
/*
|
||||
func badImportXML(domcfg *libvirtxml.Domain) (*pb.Droplet, []*pb.Event, error) {
|
||||
var alle []*pb.Event
|
||||
var d *pb.Droplet
|
||||
if domcfg == nil {
|
||||
return nil, alle, errors.New("domcfg == nil")
|
||||
}
|
||||
|
||||
d = new(pb.Droplet)
|
||||
d.Hostname = domcfg.Name
|
||||
d.Uuid = domcfg.UUID
|
||||
d.StartState = pb.DropletState_OFF
|
||||
if d.Current == nil {
|
||||
d.Current = new(pb.Current)
|
||||
d, err = c.InitDroplet(domcfg.Name)
|
||||
if err != nil {
|
||||
// use merge instead
|
||||
os.Exit(-1)
|
||||
}
|
||||
d.Current.State = pb.DropletState_UNKNOWN
|
||||
d.Uuid = domcfg.UUID
|
||||
|
||||
alle, err := updateDroplet(d, domcfg)
|
||||
alle, err := MergelibvirtDomain(d, domcfg)
|
||||
if err != nil {
|
||||
log.Info("updateDroplet() failed for", d.Hostname)
|
||||
return d, alle, errors.New("update failed for " + domcfg.Name)
|
||||
|
@ -43,6 +38,7 @@ func ImportXML(domcfg *libvirtxml.Domain) (*pb.Droplet, []*pb.Event, error) {
|
|||
}
|
||||
return d, alle, nil
|
||||
}
|
||||
*/
|
||||
|
||||
func MergeXml(d *libvirtxml.Domain, xml string) error {
|
||||
err := d.Unmarshal(xml)
|
||||
|
|
Loading…
Reference in New Issue