Merge pull request #4238 from zexi/bugfix/bm-register

baremetal: fix register input params lost
This commit is contained in:
yunion-ci-robot
2019-12-20 00:16:07 +08:00
committed by GitHub
+5 -2
View File
@@ -88,10 +88,10 @@ func (this *HostManager) GetIpmiInfo(s *mcclient.ClientSession, id string, param
return ret, nil
}
func parseHosts(titles []string, data string) ([]jsonutils.JSONObject, string) {
func parseHosts(titles []string, data string) ([]*jsonutils.JSONDict, string) {
msg := ""
hosts := strings.Split(data, "\n")
ret := []jsonutils.JSONObject{}
ret := []*jsonutils.JSONDict{}
for i, host := range hosts {
host = strings.TrimSpace(host)
if len(host) == 0 {
@@ -122,6 +122,8 @@ func (this *HostManager) DoBatchRegister(s *mcclient.ClientSession, titles []str
if err != nil {
return nil, err
}
input := params.(*jsonutils.JSONDict)
input.Remove("hosts")
hosts, msg := parseHosts(titles, data)
if len(msg) > 0 {
@@ -130,6 +132,7 @@ func (this *HostManager) DoBatchRegister(s *mcclient.ClientSession, titles []str
results := make(chan modulebase.SubmitResult, len(hosts))
for _, host := range hosts {
host.Update(input)
go func(data jsonutils.JSONObject) {
ret, e := this.Create(s, data)
id, _ := data.GetString("access_mac")