d
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -598,15 +599,23 @@ func ImportCmToNF(w http.ResponseWriter, r *http.Request) {
|
||||
scpZipCmd = fmt.Sprintf("scp -r %s %s@[%s]:%s", filePath,
|
||||
config.GetYamlConfig().NE.User, neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
}
|
||||
neFilePath := config.GetYamlConfig().NE.ScpDir + "/" + fileName
|
||||
unzipCmd := fmt.Sprintf("sudo unzip -o %s -d %s", neFilePath, config.GetYamlConfig().NE.EtcDir)
|
||||
|
||||
err = ExecCmd(fmt.Sprintf("%s && %s", scpZipCmd, unzipCmd))
|
||||
err = ExecCmd(scpZipCmd)
|
||||
if err != nil {
|
||||
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
neFilePath := config.GetYamlConfig().NE.ScpDir + "/" + fileName
|
||||
unzipCmd := fmt.Sprintf("ssh sudo unzip -o %s -d %s", neFilePath, config.GetYamlConfig().NE.EtcDir)
|
||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||
cmd := exec.Command("ssh", sshHost, unzipCmd)
|
||||
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
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user