mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1852 from wanyaoqi/bugfix/wyq/minor-fix0723
bugfix: fix baremetal attach network
This commit is contained in:
@@ -980,6 +980,7 @@ func (b *SBaremetalInstance) InitAdminNetif(
|
||||
nicType string,
|
||||
netType string,
|
||||
isDoImport bool,
|
||||
importIpAddr string,
|
||||
) error {
|
||||
// start prepare task
|
||||
// sync status to PREPARE
|
||||
@@ -1000,9 +1001,9 @@ func (b *SBaremetalInstance) InitAdminNetif(
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.postAttachWire(cliMac, nicType, netType)
|
||||
return b.postAttachWire(cliMac, nicType, netType, importIpAddr)
|
||||
} else if nic.IpAddr == "" {
|
||||
return b.postAttachWire(cliMac, nicType, netType)
|
||||
return b.postAttachWire(cliMac, nicType, netType, importIpAddr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1036,8 +1037,7 @@ func (b *SBaremetalInstance) attachWire(mac net.HardwareAddr, wireId string, nic
|
||||
return modules.Hosts.PerformAction(session, b.GetId(), "add-netif", params)
|
||||
}
|
||||
|
||||
func (b *SBaremetalInstance) postAttachWire(mac net.HardwareAddr, nicType string, netType string) error {
|
||||
ipAddr := ""
|
||||
func (b *SBaremetalInstance) postAttachWire(mac net.HardwareAddr, nicType string, netType string, ipAddr string) error {
|
||||
if nicType == types.NIC_TYPE_IPMI {
|
||||
oldIPMIConf := b.GetRawIPMIConfig()
|
||||
if oldIPMIConf != nil && oldIPMIConf.IpAddr != "" {
|
||||
|
||||
@@ -190,7 +190,7 @@ func (req *dhcpRequest) fetchConfig(session *mcclient.ClientSession) (*dhcp.Resp
|
||||
ipmiNic := req.baremetalInstance.GetIPMINic(req.ClientMac)
|
||||
if ipmiNic != nil && ipmiNic.Mac == req.ClientMac.String() {
|
||||
err = req.baremetalInstance.InitAdminNetif(
|
||||
req.ClientMac, req.netConfig.WireId, types.NIC_TYPE_IPMI, api.NETWORK_TYPE_IPMI, false)
|
||||
req.ClientMac, req.netConfig.WireId, types.NIC_TYPE_IPMI, api.NETWORK_TYPE_IPMI, false, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -313,7 +313,7 @@ func (req *dhcpRequest) doInitBaremetalAdminNetif(desc jsonutils.JSONObject) err
|
||||
return err
|
||||
}
|
||||
err = req.baremetalInstance.InitAdminNetif(
|
||||
req.ClientMac, req.netConfig.WireId, types.NIC_TYPE_ADMIN, api.NETWORK_TYPE_PXE, false)
|
||||
req.ClientMac, req.netConfig.WireId, types.NIC_TYPE_ADMIN, api.NETWORK_TYPE_PXE, false, "")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ type IBaremetalInstance interface {
|
||||
GetIPMINic(cliMac net.HardwareAddr) *types.SNic
|
||||
GetPXEDHCPConfig(arch uint16) (*dhcp.ResponseConfig, error)
|
||||
GetDHCPConfig(cliMac net.HardwareAddr) (*dhcp.ResponseConfig, error)
|
||||
InitAdminNetif(cliMac net.HardwareAddr, wireId, nicType, netType string, isDoImport bool) error
|
||||
InitAdminNetif(cliMac net.HardwareAddr, wireId, nicType, netType string, isDoImport bool, ipAddr string) error
|
||||
RegisterNetif(cliMac net.HardwareAddr, wireId string) error
|
||||
GetTFTPResponse() string
|
||||
}
|
||||
|
||||
@@ -105,11 +105,13 @@ func (s *sBaremetalRegisterTask) CreateBaremetal() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("BmManager add baremetal failed: %s", err)
|
||||
}
|
||||
err = pxeBm.InitAdminNetif(s.accessNic.Mac, s.AdminWire, types.NIC_TYPE_ADMIN, api.NETWORK_TYPE_PXE, true)
|
||||
err = pxeBm.InitAdminNetif(
|
||||
s.accessNic.Mac, s.AdminWire, types.NIC_TYPE_ADMIN, api.NETWORK_TYPE_PXE, true, s.RemoteIp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BmManager add admin netif failed: %s", err)
|
||||
}
|
||||
err = pxeBm.InitAdminNetif(s.IpmiMac, s.IpmiWire, types.NIC_TYPE_IPMI, api.NETWORK_TYPE_IPMI, true)
|
||||
err = pxeBm.InitAdminNetif(
|
||||
s.IpmiMac, s.IpmiWire, types.NIC_TYPE_IPMI, api.NETWORK_TYPE_IPMI, true, s.IpmiIpAddr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BmManager add ipmi netif failed: %s", err)
|
||||
}
|
||||
@@ -169,7 +171,7 @@ func (s *sBaremetalRegisterTask) updateIpmiInfo(cli *ssh.Client) {
|
||||
} else {
|
||||
nic.Mac = conf.Mac
|
||||
}
|
||||
s.sendNicInfo(nic, -1, types.NIC_TYPE_IPMI, true, "")
|
||||
s.sendNicInfo(nic, -1, types.NIC_TYPE_IPMI, false, "")
|
||||
}
|
||||
|
||||
func (s *sBaremetalRegisterTask) updateBmInfo(cli *ssh.Client, i *baremetalPrepareInfo) error {
|
||||
|
||||
Reference in New Issue
Block a user