rpm&deb
This commit is contained in:
@@ -595,7 +595,6 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
return
|
||||
}
|
||||
|
||||
func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -669,12 +668,34 @@ 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)
|
||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
fileType, err := global.JudgeRpmOrDebPackage(filePath)
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
log.Error("Failed to JudgeRpmOrDebPackage:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
}
|
||||
if fileType == 1 {
|
||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else if fileType == 2 {
|
||||
dpkgCmd := fmt.Sprintf("sudo dpkg -i '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, dpkgCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute dpkg command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err := global.ErrCMUnknownSoftwareFormat
|
||||
log.Error(err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -759,12 +780,34 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if !config.GetYamlConfig().OMC.TestMode {
|
||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||
rpmCmd := fmt.Sprintf("rpm -Uvh --oldpackage '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
fileType, err := global.JudgeRpmOrDebPackage(filePath)
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
log.Error("Failed to JudgeRpmOrDebPackage:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
}
|
||||
if fileType == 1 {
|
||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh --oldpackage '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else if fileType == 2 {
|
||||
dpkgCmd := fmt.Sprintf("sudo dpkg -i '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, dpkgCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute dpkg command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err := global.ErrCMUnknownSoftwareFormat
|
||||
log.Error(err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user