fix: sync to ne
This commit is contained in:
@@ -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,6 +131,22 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
|
||||
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
||||
log.Debug("NE info:", neInfo)
|
||||
|
||||
//if !config.GetYamlConfig().OMC.Chk2Ne {
|
||||
if syncFlag == "false" {
|
||||
neInfo.Status = NEStatusMaintain
|
||||
affected, err := dborm.XormInsertNeInfo(neInfo)
|
||||
if err != nil {
|
||||
log.Error("Failed to insert Ne info:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
mapRow := make(map[string]interface{})
|
||||
row := map[string]interface{}{"affectedRows": affected}
|
||||
mapRow["data"] = row
|
||||
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))
|
||||
@@ -161,22 +177,6 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
log.Info("StatusCode: ", response.StatusCode())
|
||||
|
||||
//if !config.GetYamlConfig().OMC.Chk2Ne {
|
||||
if syncFlag == "false" {
|
||||
neInfo.Status = NEStatusMaintain
|
||||
affected, err := dborm.XormInsertNeInfo(neInfo)
|
||||
if err != nil {
|
||||
log.Error("Failed to insert Ne info:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
mapRow := make(map[string]interface{})
|
||||
row := map[string]interface{}{"affectedRows": affected}
|
||||
mapRow["data"] = row
|
||||
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
||||
return
|
||||
} else {
|
||||
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,6 +233,22 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
|
||||
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
||||
log.Debug("NE info:", neInfo)
|
||||
|
||||
//if !config.GetYamlConfig().OMC.Chk2Ne {
|
||||
if syncFlag == "false" {
|
||||
neInfo.Status = NEStatusMaintain
|
||||
affected, err := dborm.XormUpdateNeInfo(neInfo)
|
||||
if err != nil {
|
||||
log.Error("Failed to update Ne info:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
return
|
||||
}
|
||||
|
||||
mapRow := make(map[string]interface{})
|
||||
row := map[string]interface{}{"affectedRows": affected}
|
||||
mapRow["data"] = row
|
||||
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))
|
||||
@@ -263,22 +279,6 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
log.Info("StatusCode: ", response.StatusCode())
|
||||
|
||||
//if !config.GetYamlConfig().OMC.Chk2Ne {
|
||||
if syncFlag == "false" {
|
||||
neInfo.Status = NEStatusMaintain
|
||||
affected, err := dborm.XormUpdateNeInfo(neInfo)
|
||||
if err != nil {
|
||||
log.Error("Failed to update Ne info:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
return
|
||||
}
|
||||
|
||||
mapRow := make(map[string]interface{})
|
||||
row := map[string]interface{}{"affectedRows": affected}
|
||||
mapRow["data"] = row
|
||||
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
||||
return
|
||||
} else {
|
||||
respMsg := make(map[string]interface{})
|
||||
switch response.StatusCode() {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||
|
||||
Reference in New Issue
Block a user