parent
15f48a01ab
commit
4d43c36db5
|
@ -19,7 +19,10 @@ func addDomainDroplet(domcfg *libvirtxml.Domain) (*DropletT, error) {
|
|||
return nil, errors.New("domcfg == nil")
|
||||
}
|
||||
|
||||
d, _ := findDomain(domcfg)
|
||||
d, err := findDomain(domcfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if d == nil {
|
||||
// this is a new unknown droplet (not in the config file)
|
||||
d = new(DropletT)
|
||||
|
@ -38,7 +41,7 @@ func addDomainDroplet(domcfg *libvirtxml.Domain) (*DropletT, error) {
|
|||
me.changed = true
|
||||
}
|
||||
|
||||
err := updateDroplet(d, domcfg)
|
||||
err = updateDroplet(d, domcfg)
|
||||
if err != nil {
|
||||
log.Info("updateDroplet() failed for", d.pb.Hostname)
|
||||
return d, errors.New("update failed for " + domcfg.Name)
|
||||
|
|
|
@ -45,7 +45,7 @@ func convertToString(x any) string {
|
|||
case string:
|
||||
return x.(string)
|
||||
case int:
|
||||
return fmt.Sprintf("%d", x.(int64))
|
||||
return fmt.Sprintf("%d", x.(int))
|
||||
case uint:
|
||||
return fmt.Sprintf("%d", x.(uint))
|
||||
case bool:
|
||||
|
|
|
@ -351,11 +351,19 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
|||
var secnormal bool = true
|
||||
if len(domcfg.SecLabel) != 0 {
|
||||
for _, sec := range domcfg.SecLabel {
|
||||
if sec.Model == "apparmor" {
|
||||
// this should be configured in dom0
|
||||
} else {
|
||||
fmt.Printf("? SecLabel: %+v\n", sec)
|
||||
fmt.Printf("? SecLabel.Model: %+v\n", sec.Model)
|
||||
switch sec.Model {
|
||||
case "apparmor":
|
||||
// log.Info("ignoring SecLabel apparmor. not supported yet")
|
||||
// log.Info("you must set this later if you need this")
|
||||
// xmlAny(sec)
|
||||
case "dac":
|
||||
// log.Info("ignoring SecLabel dac. not supported yet")
|
||||
// log.Info("you must set this later if you need this")
|
||||
// xmlAny(sec)
|
||||
default:
|
||||
fmt.Printf("unknown SecLabel: %+v\n", sec)
|
||||
fmt.Printf("unknown SecLabel.Model: %+v\n", sec.Model)
|
||||
xmlAny(sec)
|
||||
secnormal = false
|
||||
}
|
||||
}
|
||||
|
@ -371,6 +379,7 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
|||
fmt.Printf("Not saving Domain.Metadata: %+v\n", domcfg.Metadata)
|
||||
domcfg.Metadata = nil
|
||||
}
|
||||
|
||||
// ignore Resource
|
||||
if domcfg.Resource != nil {
|
||||
if domcfg.Resource.Partition == "/machine" {
|
||||
|
@ -380,6 +389,12 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// ignore Resource
|
||||
if domcfg.ID != nil {
|
||||
// ignore domain id
|
||||
domcfg.ID = nil
|
||||
}
|
||||
|
||||
// this will move elsewhere in the protobuf someday
|
||||
// ignore all these for now
|
||||
if domcfg.OnPoweroff != "" { // normally "destroy"
|
||||
|
@ -677,6 +692,23 @@ func finalEmptyCheck(domcfg *libvirtxml.Domain) (string, error) {
|
|||
return final, nil
|
||||
}
|
||||
|
||||
func xmlAny(a any) (string, error) {
|
||||
updatedXML, err := xml.MarshalIndent(a, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to marshal updated XML: %v\n", err)
|
||||
return "", err
|
||||
}
|
||||
final := string(updatedXML)
|
||||
if final == "" {
|
||||
// everything seems to have been parsed pretty standard
|
||||
return "", nil
|
||||
}
|
||||
log.Info("Non-Standard XML Start")
|
||||
fmt.Println(final)
|
||||
log.Info("Non-Standard XML End")
|
||||
return final, nil
|
||||
}
|
||||
|
||||
func warnUserOfNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
|
||||
updatedXML, err := xml.MarshalIndent(domcfg, "", " ")
|
||||
if err != nil {
|
||||
|
@ -832,7 +864,7 @@ func libvirtxmlDomainEmpty(mydom libvirtxml.Domain) bool {
|
|||
}
|
||||
case reflect.Struct:
|
||||
if IsStructEmptyOrNil(value) {
|
||||
fmt.Printf("XML Field ignore empty Struct %s\n", field)
|
||||
// fmt.Printf("XML Field ignore empty Struct %s\n", field)
|
||||
} else {
|
||||
fmt.Printf("Field Struct is not empty %s is %+v\n", field, value)
|
||||
empty = false
|
||||
|
|
Loading…
Reference in New Issue