fails on imports with duplicate mac addrs
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
7cc0bd9b2c
commit
b6dd67b73d
|
@ -308,6 +308,11 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) ([]*pb.Event, error)
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
if checkUniqueMac(mac) {
|
||||
} else {
|
||||
log.Info("droplet", d.pb.Hostname, "duplicate mac address", mac)
|
||||
return nil, errors.New("duplicate mac address")
|
||||
}
|
||||
var eth *pb.Network
|
||||
eth = new(pb.Network)
|
||||
eth.Mac = mac
|
||||
|
|
10
main.go
10
main.go
|
@ -60,6 +60,10 @@ func main() {
|
|||
// parsing the libvirt xml file failed
|
||||
log.Info("error:", filename, err)
|
||||
ok = false
|
||||
log.Info("readXml() error", filename)
|
||||
log.Info("readXml() error", err)
|
||||
log.Info("libvirt XML will have to be fixed by hand")
|
||||
os.Exit(-1)
|
||||
continue
|
||||
}
|
||||
// see if the libvirt xml droplet is already here
|
||||
|
@ -68,6 +72,10 @@ func main() {
|
|||
// some error. probably UUID mismatch or hostname duplication
|
||||
// this has to be fixed by hand
|
||||
ok = false
|
||||
log.Info("findDomain() error", filename)
|
||||
log.Info("findDomain() error", err)
|
||||
log.Info("libvirt XML will have to be fixed by hand")
|
||||
os.Exit(-1)
|
||||
continue
|
||||
}
|
||||
if d == nil {
|
||||
|
@ -78,6 +86,8 @@ func main() {
|
|||
ok = false
|
||||
log.Info("addDomainDroplet() error", filename)
|
||||
log.Info("addDomainDroplet() error", err)
|
||||
log.Info("libvirt XML will have to be fixed by hand")
|
||||
os.Exit(-1)
|
||||
}
|
||||
} else {
|
||||
// this droplet is already here
|
||||
|
|
13
validate.go
13
validate.go
|
@ -21,6 +21,19 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// will make sure the mac address is unique
|
||||
func checkUniqueMac(mac string) bool {
|
||||
for _, d := range me.cluster.Droplets {
|
||||
for _, n := range d.Networks {
|
||||
if n.Mac == mac {
|
||||
log.Info("duplicate MAC", n.Mac, "in droplet", d.Hostname)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func checkDroplets(dump bool) bool {
|
||||
// uuid map to check for duplicates
|
||||
var umap map[string]string
|
||||
|
|
Loading…
Reference in New Issue