better mac addr checking

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-25 15:18:37 -05:00
parent 89a43a46bf
commit 8dc0bf6fac
1 changed files with 27 additions and 14 deletions

View File

@ -250,26 +250,33 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) ([]*pb.Event, error)
log.Info("Non-Standard Network XML Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard Network XML End")
return nil, errors.New("non-standard network")
return nil, errors.New("non-standard network. source == nil")
}
if iface.Source.Bridge == nil {
// fmt.Printf("non-standard network: %+v\n", iface)
updatedXML, _ := xml.MarshalIndent(domcfg.Devices.Interfaces, "", " ")
log.Info("Non-Standard Network XML Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard Network XML End")
return nil, errors.New("bridge is blank nil and no mac address")
if hwaddr == "" {
fmt.Printf("non-standard network: %+v\n", iface)
updatedXML, _ := xml.MarshalIndent(domcfg.Devices.Interfaces, "", " ")
log.Info("Non-Standard Network XML Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard Network XML End")
return nil, errors.New("bridge is nil and no mac address")
}
brname = ""
}
if iface.Source.Bridge.Bridge == "" {
updatedXML, _ := xml.MarshalIndent(domcfg.Devices.Interfaces, "", " ")
log.Info("Non-Standard Network XML Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard Network XML End")
return nil, errors.New("bridge is blank and no mac address")
if hwaddr == "" {
fmt.Printf("non-standard network: %+v\n", iface)
fmt.Printf("iface.Mac: %+v\n", iface)
updatedXML, _ := xml.MarshalIndent(domcfg.Devices.Interfaces, "", " ")
log.Info("Non-Standard Network XML Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard Network XML End")
return nil, errors.New("bridge is blank and no mac address")
}
brname = iface.Source.Bridge.Bridge
}
// log.Info("network has bridge:", iface.Source.Bridge.Bridge)
brname = iface.Source.Bridge.Bridge
if hwaddr == "" {
hwaddr = "generate " + domcfg.Name
log.Info("need to generate mac addr for bridge:", brname)
@ -285,9 +292,15 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) ([]*pb.Event, error)
if eth.Mac == mac {
// log.Info("OKAY. FOUND ETH:", eth.Mac, eth.Name, brname)
found = true
if brname == "" {
// if new bridge name is blank, keep the old one
brname = eth.Name
}
if eth.Name != brname {
if argv.IgnoreBr {
log.Info("ignoring network changed bridge name:", eth.Mac, eth.Name, brname)
log.Info("network was:", eth.Mac, eth.Name)
log.Info("network now:", eth.Mac, brname)
log.Info("ignoring network change (--xml-ignore-net)")
} else {
return nil, errors.New("bridge name changed")
}