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)
|
syncFlag := services.GetUriParamString(r, "sync2ne", ",", false, false)
|
||||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("io.ReadAll is failed:", err)
|
log.Error("Failed to o.ReadAll:", err)
|
||||||
services.ResponseNotFound404UriNotExist(w, r)
|
services.ResponseNotFound404UriNotExist(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -131,36 +131,6 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
||||||
log.Debug("NE info:", neInfo)
|
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 !config.GetYamlConfig().OMC.Chk2Ne {
|
||||||
if syncFlag == "false" {
|
if syncFlag == "false" {
|
||||||
neInfo.Status = NEStatusMaintain
|
neInfo.Status = NEStatusMaintain
|
||||||
@@ -177,6 +147,36 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
||||||
return
|
return
|
||||||
} else {
|
} 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{})
|
respMsg := make(map[string]interface{})
|
||||||
switch response.StatusCode() {
|
switch response.StatusCode() {
|
||||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
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)
|
syncFlag := services.GetUriParamString(r, "sync2ne", ",", false, false)
|
||||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("io.ReadAll is failed:", err)
|
log.Error("Failed to io.ReadAll:", err)
|
||||||
services.ResponseNotFound404UriNotExist(w, r)
|
services.ResponseNotFound404UriNotExist(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -233,36 +233,6 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
neInfo.UpdateTime = time.Now().Format(time.DateTime)
|
||||||
log.Debug("NE info:", neInfo)
|
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 !config.GetYamlConfig().OMC.Chk2Ne {
|
||||||
if syncFlag == "false" {
|
if syncFlag == "false" {
|
||||||
neInfo.Status = NEStatusMaintain
|
neInfo.Status = NEStatusMaintain
|
||||||
@@ -279,6 +249,36 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
services.ResponseWithJson(w, http.StatusOK, mapRow)
|
||||||
return
|
return
|
||||||
} else {
|
} 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{})
|
respMsg := make(map[string]interface{})
|
||||||
switch response.StatusCode() {
|
switch response.StatusCode() {
|
||||||
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
|
||||||
|
|||||||
Reference in New Issue
Block a user