This commit is contained in:
2023-09-19 16:44:44 +08:00
parent 5babf47cce
commit a9d74f75b9
2 changed files with 21 additions and 9 deletions

View File

@@ -539,12 +539,12 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
log.Debug("neVersion:", neVersion)
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
mkdirCmd := fmt.Sprintf("mkdir -p %s/software/%s", config.GetYamlConfig().NE.OmcDir, neTypeLower)
mkdirCmd := fmt.Sprintf("sudo mkdir -p %s/software/%s", config.GetYamlConfig().NE.OmcDir, neTypeLower)
cmd := exec.Command("ssh", sshHost, mkdirCmd)
out, err := cmd.CombinedOutput()
log.Tracef("Exec output: %v", string(out))
if err != nil {
log.Error("Faile to exec cmd:", err)
log.Error("Faile to mkdir:", err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
@@ -552,9 +552,10 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
fileName := (*neSoftware)[0]["file_name"]
path := (*neSoftware)[0]["path"]
srcFile := fmt.Sprintf("%s/%s", path, fileName)
dstDir := fmt.Sprintf("%s@%s:%s/software/%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.OmcDir, neTypeLower)
cmd = exec.Command("scp", "-r", srcFile, dstDir)
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
cmd = exec.Command("scp", "-r", srcFile, scpDir)
out, err = cmd.CombinedOutput()
log.Tracef("Exec output: %v", string(out))
if err != nil {
@@ -562,6 +563,17 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
services.ResponseInternalServerError500ProcessError(w, err)
return
}
neFilePath := config.GetYamlConfig().NE.ScpDir + "/" + fileName
cpCmd := fmt.Sprintf("sudo cp -f %s %s/software/%s", neFilePath,
config.GetYamlConfig().NE.OmcDir, neTypeLower)
cmd = exec.Command("ssh", sshHost, cpCmd)
out, err = cmd.CombinedOutput()
log.Tracef("Exec output: %v", string(out))
if err != nil {
log.Error("Faile to execute cp command:", err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
if len(*neVersion) == 0 {
neVersionData := dborm.NeVersion{