mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
Merge pull request #3621 from swordqiu/hotfix/qj-fix-host-teaming
fix: nic teaming/bonding not working properly
This commit is contained in:
@@ -597,6 +597,7 @@ func (d *sDebianLikeRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics
|
||||
cmds.WriteString("\n")
|
||||
}
|
||||
}
|
||||
log.Debugf("%s", cmds.String())
|
||||
return rootFs.FilePutContents(fn, cmds.String(), false, false)
|
||||
}
|
||||
|
||||
@@ -1002,6 +1003,7 @@ func (r *sRedhatLikeRootFs) deployNetworkingScripts(rootFs IDiskPartition, nics
|
||||
cmds.WriteString("BOOTPROTO=dhcp\n")
|
||||
}
|
||||
var fn = fmt.Sprintf("/etc/sysconfig/network-scripts/ifcfg-%s", nicDesc.Name)
|
||||
log.Debugf("%s: %s", fn, cmds.String())
|
||||
if err := rootFs.FilePutContents(fn, cmds.String(), false, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -91,13 +91,15 @@ func convertNicConfigs(nics []*types.SServerNic) ([]*types.SServerNic, []*types.
|
||||
}
|
||||
teamNic := findTeamingNic(nics, nics[i].Mac)
|
||||
if teamNic == nil {
|
||||
// no teaming nic
|
||||
nnic := nics[i]
|
||||
nnic.Name = fmt.Sprintf("%s%d", NetDevPrefix, nnic.Index)
|
||||
allNics = append(allNics, nnic)
|
||||
continue
|
||||
}
|
||||
// copy nic into master and nnic
|
||||
master := nics[i]
|
||||
nnic := nics[i]
|
||||
nnic := *nics[i]
|
||||
tnic := *teamNic
|
||||
nnic.Name = fmt.Sprintf("%s%d", NetDevPrefix, nnic.Index)
|
||||
nnic.TeamingMaster = master
|
||||
@@ -108,9 +110,9 @@ func convertNicConfigs(nics []*types.SServerNic) ([]*types.SServerNic, []*types.
|
||||
tnic.Ip = ""
|
||||
tnic.Gateway = ""
|
||||
master.Name = fmt.Sprintf("bond%d", len(bondNics))
|
||||
master.TeamingSlaves = []*types.SServerNic{nnic, &tnic}
|
||||
master.TeamingSlaves = []*types.SServerNic{&nnic, &tnic}
|
||||
master.Mac = ""
|
||||
allNics = append(allNics, nnic, &tnic, master)
|
||||
allNics = append(allNics, &nnic, &tnic, master)
|
||||
bondNics = append(bondNics, master)
|
||||
}
|
||||
return allNics, bondNics
|
||||
|
||||
@@ -1299,7 +1299,7 @@ func (h *SHostInfo) unregister() {
|
||||
|
||||
func (h *SHostInfo) OnCatalogChanged(catalog mcclient.KeystoneServiceCatalogV3) {
|
||||
// TODO: dynamic probe endpoint type
|
||||
defaultEndpointType := "publicURL"
|
||||
defaultEndpointType := options.HostOptions.SessionEndpointType
|
||||
if options.HostOptions.ManageNtpConfiguration {
|
||||
ntpd := system_service.GetService("ntpd")
|
||||
urls, _ := catalog.GetServiceURLs("ntp", options.HostOptions.Region, "", defaultEndpointType)
|
||||
@@ -1340,6 +1340,7 @@ func (h *SHostInfo) OnCatalogChanged(catalog mcclient.KeystoneServiceCatalogV3)
|
||||
if len(urls) > 0 {
|
||||
conf["influxdb"] = map[string]interface{}{"url": urls, "database": "telegraf"}
|
||||
}
|
||||
log.Debugf("telegraf config: %s", conf)
|
||||
if !reflect.DeepEqual(telegraf.GetConf(), conf) || !telegraf.IsActive() {
|
||||
telegraf.SetConf(conf)
|
||||
telegraf.BgReload(conf)
|
||||
|
||||
@@ -26,10 +26,12 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/util/regutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/util/procutils"
|
||||
"yunion.io/x/onecloud/pkg/util/regutils2"
|
||||
)
|
||||
@@ -97,7 +99,7 @@ func GetMainNicFromDeployApi(nics []*types.SServerNic) (*types.SServerNic, error
|
||||
ip := n.Ip
|
||||
ipInt, err := netutils.NewIPV4Addr(ip)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "netutils.NewIPV4Addr %s", ip)
|
||||
}
|
||||
if mainIp == 0 {
|
||||
mainIp = ipInt
|
||||
@@ -108,7 +110,27 @@ func GetMainNicFromDeployApi(nics []*types.SServerNic) (*types.SServerNic, error
|
||||
}
|
||||
}
|
||||
}
|
||||
return mainNic, nil
|
||||
if mainNic != nil {
|
||||
return mainNic, nil
|
||||
}
|
||||
for _, n := range nics {
|
||||
ip := n.Ip
|
||||
ipInt, err := netutils.NewIPV4Addr(ip)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "netutils.NewIPV4Addr")
|
||||
}
|
||||
if mainIp == 0 {
|
||||
mainIp = ipInt
|
||||
mainNic = n
|
||||
} else if !netutils.IsPrivate(ipInt) && netutils.IsPrivate(mainIp) {
|
||||
mainIp = ipInt
|
||||
mainNic = n
|
||||
}
|
||||
}
|
||||
if mainNic != nil {
|
||||
return mainNic, nil
|
||||
}
|
||||
return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid nic")
|
||||
}
|
||||
|
||||
func GetMainNic(nics []jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
@@ -130,7 +152,27 @@ func GetMainNic(nics []jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return mainNic, nil
|
||||
if mainNic != nil {
|
||||
return mainNic, nil
|
||||
}
|
||||
for _, n := range nics {
|
||||
ip, _ := n.GetString("ip")
|
||||
ipInt, err := netutils.NewIPV4Addr(ip)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "netutils.NewIPV4Addr %s", ip)
|
||||
}
|
||||
if mainIp == 0 {
|
||||
mainIp = ipInt
|
||||
mainNic = n
|
||||
} else if !netutils.IsPrivate(ipInt) && netutils.IsPrivate(mainIp) {
|
||||
mainIp = ipInt
|
||||
mainNic = n
|
||||
}
|
||||
}
|
||||
if mainNic != nil {
|
||||
return mainNic, nil
|
||||
}
|
||||
return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid nic")
|
||||
}
|
||||
|
||||
func Netlen2Mask(netmasklen int) string {
|
||||
|
||||
Reference in New Issue
Block a user