diff --git a/features/cm/ne.go b/features/cm/ne.go index f05bd7a5..88cf3d5d 100644 --- a/features/cm/ne.go +++ b/features/cm/ne.go @@ -115,7 +115,7 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) { syncFlag := services.GetUriParamString(r, "sync2ne", ",", false, false) body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen)) if err != nil { - log.Error("io.ReadAll is failed:", err) + log.Error("Failed to o.ReadAll:", err) services.ResponseNotFound404UriNotExist(w, r) return } @@ -131,36 +131,6 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) { neInfo.UpdateTime = time.Now().Format(time.DateTime) log.Debug("NE info:", neInfo) - hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port) - //hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) - apiUri := fmt.Sprintf(UriParamOmcNeConfig, strings.ToLower(neInfo.NeType)) - requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri) - log.Debug("requestURI2NF:", requestURI2NF) - - omcNeConfig := &OmcNeConfig{ - NeId: neInfo.NeId, - RmUID: neInfo.RmUID, - NeName: neInfo.NeName, - PvFlag: neInfo.PvFlag, - Province: neInfo.Province, - VendorName: neInfo.VendorName, - Dn: neInfo.Dn, - } - body, _ = json.Marshal(omcNeConfig) - client := resty.New() - response, err := client.R(). - EnableTrace(). - SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). - SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). - SetBody(body). - Put(requestURI2NF) - if err != nil { - log.Error("Failed to Put:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - log.Info("StatusCode: ", response.StatusCode()) - //if !config.GetYamlConfig().OMC.Chk2Ne { if syncFlag == "false" { neInfo.Status = NEStatusMaintain @@ -177,6 +147,36 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) { services.ResponseWithJson(w, http.StatusOK, mapRow) return } else { + hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port) + //hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) + apiUri := fmt.Sprintf(UriParamOmcNeConfig, strings.ToLower(neInfo.NeType)) + requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri) + log.Debug("requestURI2NF:", requestURI2NF) + + omcNeConfig := &OmcNeConfig{ + NeId: neInfo.NeId, + RmUID: neInfo.RmUID, + NeName: neInfo.NeName, + PvFlag: neInfo.PvFlag, + Province: neInfo.Province, + VendorName: neInfo.VendorName, + Dn: neInfo.Dn, + } + body, _ = json.Marshal(omcNeConfig) + client := resty.New() + response, err := client.R(). + EnableTrace(). + SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). + SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). + SetBody(body). + Put(requestURI2NF) + if err != nil { + log.Error("Failed to Put:", err) + services.ResponseInternalServerError500ProcessError(w, err) + return + } + log.Info("StatusCode: ", response.StatusCode()) + respMsg := make(map[string]interface{}) switch response.StatusCode() { case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted: @@ -222,7 +222,7 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) { syncFlag := services.GetUriParamString(r, "sync2ne", ",", false, false) body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen)) if err != nil { - log.Error("io.ReadAll is failed:", err) + log.Error("Failed to io.ReadAll:", err) services.ResponseNotFound404UriNotExist(w, r) return } @@ -233,36 +233,6 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) { neInfo.UpdateTime = time.Now().Format(time.DateTime) log.Debug("NE info:", neInfo) - hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port) - //hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) - apiUri := fmt.Sprintf(UriParamOmcNeConfig, strings.ToLower(neType)) - requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri) - log.Debug("requestURI2NF:", requestURI2NF) - - omcNeConfig := &OmcNeConfig{ - NeId: neInfo.NeId, - RmUID: neInfo.RmUID, - NeName: neInfo.NeName, - PvFlag: neInfo.PvFlag, - Province: neInfo.Province, - VendorName: neInfo.VendorName, - Dn: neInfo.Dn, - } - body, _ = json.Marshal(omcNeConfig) - client := resty.New() - response, err := client.R(). - EnableTrace(). - SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). - SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). - SetBody(body). - Put(requestURI2NF) - if err != nil { - log.Error("Failed to Put:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - log.Info("StatusCode: ", response.StatusCode()) - //if !config.GetYamlConfig().OMC.Chk2Ne { if syncFlag == "false" { neInfo.Status = NEStatusMaintain @@ -279,6 +249,36 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) { services.ResponseWithJson(w, http.StatusOK, mapRow) return } else { + hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port) + //hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) + apiUri := fmt.Sprintf(UriParamOmcNeConfig, strings.ToLower(neType)) + requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri) + log.Debug("requestURI2NF:", requestURI2NF) + + omcNeConfig := &OmcNeConfig{ + NeId: neInfo.NeId, + RmUID: neInfo.RmUID, + NeName: neInfo.NeName, + PvFlag: neInfo.PvFlag, + Province: neInfo.Province, + VendorName: neInfo.VendorName, + Dn: neInfo.Dn, + } + body, _ = json.Marshal(omcNeConfig) + client := resty.New() + response, err := client.R(). + EnableTrace(). + SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). + SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). + SetBody(body). + Put(requestURI2NF) + if err != nil { + log.Error("Failed to Put:", err) + services.ResponseInternalServerError500ProcessError(w, err) + return + } + log.Info("StatusCode: ", response.StatusCode()) + respMsg := make(map[string]interface{}) switch response.StatusCode() { case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted: