parent
a4c54d6483
commit
9528d4c0fb
|
@ -159,7 +159,7 @@ func updateDroplet(d *DropletT, domcfg *libvirtxml.Domain) error {
|
|||
|
||||
e, err = updateNetwork(d, domcfg)
|
||||
if err != nil {
|
||||
log.Info("updateNetwork() failed")
|
||||
log.Info("updateNetwork() failed", err)
|
||||
return errors.New("updateNetwork() failed")
|
||||
}
|
||||
if e != nil {
|
||||
|
@ -240,16 +240,22 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) (*pb.Event, error) {
|
|||
// log.Info("Interface:", iface.Target, "MAC Address:", iface.MAC.Address)
|
||||
// fmt.Printf("source: %+v\n", iface.Source)
|
||||
hwaddr = iface.MAC.Address
|
||||
} else {
|
||||
fmt.Printf("iface: %+v\n", iface)
|
||||
fmt.Printf("Interface Target: %+v, MAC Address not available\n", iface.Target)
|
||||
return nil, errors.New("network XML does not have a MAC Address")
|
||||
}
|
||||
if iface.Source != nil {
|
||||
if iface.Source.Bridge != nil {
|
||||
brname = iface.Source.Bridge.Bridge
|
||||
if iface.Source == nil {
|
||||
fmt.Printf("non-standard network: %+v\n", iface)
|
||||
return nil, errors.New("non-standard network")
|
||||
}
|
||||
}
|
||||
|
||||
if iface.Source.Bridge == nil {
|
||||
fmt.Printf("non-standard network: %+v\n", iface)
|
||||
return nil, errors.New("bridge is blank nil and no mac address")
|
||||
}
|
||||
if iface.Source.Bridge.Bridge == "" {
|
||||
return nil, errors.New("bridge is blank and no mac address")
|
||||
}
|
||||
// log.Info("network has bridge:", iface.Source.Bridge.Bridge)
|
||||
brname = iface.Source.Bridge.Bridge
|
||||
hwaddr = "generate"
|
||||
macs[hwaddr] = brname
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ func convertToAnypb(x any) *anypb.Any {
|
|||
a, _ = anypb.New(wrapperspb.Bool(x.(bool)))
|
||||
return a
|
||||
default:
|
||||
log.Error(errors.New("Set() unknown type"), "v =", v, "x =", x)
|
||||
log.Error(errors.New("convertToAnypb() unknown type"), "v =", v, "x =", x)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
@ -46,13 +46,16 @@ func convertToString(x any) string {
|
|||
return x.(string)
|
||||
case int:
|
||||
return fmt.Sprintf("%d", x.(int64))
|
||||
case uint:
|
||||
return fmt.Sprintf("%d", x.(uint))
|
||||
case bool:
|
||||
if x.(bool) {
|
||||
return "true"
|
||||
}
|
||||
return "false"
|
||||
default:
|
||||
log.Error(errors.New("Set() unknown type"), "v =", v, "x =", x)
|
||||
log.Info("convertToSTring() unknown type", v)
|
||||
log.Error(errors.New("convertToSTring() unknown type"), "v =", v, "x =", x)
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
|
|
4
main.go
4
main.go
|
@ -76,12 +76,14 @@ func main() {
|
|||
_, err := addDomainDroplet(domcfg)
|
||||
if err != nil {
|
||||
ok = false
|
||||
log.Info("addDomainDroplet() failed", err)
|
||||
log.Info("addDomainDroplet() error", filename)
|
||||
log.Info("addDomainDroplet() error", err)
|
||||
}
|
||||
} else {
|
||||
// this droplet is already here
|
||||
err := updateDroplet(d, domcfg)
|
||||
if err != nil {
|
||||
log.Info("updateDroplet() error", filename)
|
||||
log.Info("updateDroplet() error", d.pb.Hostname, err)
|
||||
ok = false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue