fix: change user issue

This commit is contained in:
2024-05-24 18:29:16 +08:00
parent 9091385574
commit 053fe3c429

View File

@@ -697,19 +697,27 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
if !config.GetYamlConfig().OMC.TestMode {
filePath := (*neVersion)[0]["file_path"]
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
srcFile := fmt.Sprintf("%s/actpkg.sh", config.GetYamlConfig().OMC.BinDir)
runCmd := fmt.Sprintf("sudo rm -f %s/actpkg.sh", config.GetYamlConfig().NE.ScpDir)
err = RunSSHCmd(sshHost, runCmd)
if err != nil {
log.Errorf("Failed to run cmd: %s", runCmd)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
srcFile := fmt.Sprintf("%s/actpkg.sh", config.GetYamlConfig().OMC.BinDir)
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
cmd := exec.Command("scp", "-r", srcFile, scpDir)
_, err := cmd.CombinedOutput()
if err != nil {
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
log.Errorf("Failed to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
runCmd := fmt.Sprintf("sudo %s/actpkg.sh '%s' %s",
runCmd = fmt.Sprintf("sudo %s/actpkg.sh '%s' %s",
config.GetYamlConfig().NE.ScpDir, filePath, neTypeUpper)
if neTypeLower == "omc" {
idNeVersion, _ := strconv.Atoi((*neVersion)[0]["id"])
@@ -897,6 +905,14 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
if !config.GetYamlConfig().OMC.TestMode {
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
runCmd := fmt.Sprintf("sudo rm -f %s/rbkpkg.sh", config.GetYamlConfig().NE.ScpDir)
err = RunSSHCmd(sshHost, runCmd)
if err != nil {
log.Errorf("Failed to run cmd: %s", runCmd)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
srcFile := fmt.Sprintf("%s/rbkpkg.sh", config.GetYamlConfig().OMC.BinDir)
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
@@ -909,7 +925,7 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return
}
runCmd := fmt.Sprintf("sudo %s/rbkpkg.sh '%s' %s",
runCmd = fmt.Sprintf("sudo %s/rbkpkg.sh '%s' %s",
config.GetYamlConfig().NE.ScpDir, filePath, neTypeUpper)
if neTypeLower == "omc" {
idNeVersion, _ := strconv.Atoi((*neVersion)[0]["id"])