diff --git a/addDroplet.go b/addDroplet.go index ba2701c..df60113 100644 --- a/addDroplet.go +++ b/addDroplet.go @@ -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 } diff --git a/change.go b/change.go index 160da5c..2c47fbb 100644 --- a/change.go +++ b/change.go @@ -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 "" diff --git a/main.go b/main.go index d8e18de..f2e4f11 100644 --- a/main.go +++ b/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 }