1
0

merge: 合并代码20240531

This commit is contained in:
TsMask
2024-06-01 18:56:18 +08:00
parent 3cc193f57d
commit 3b50e2f3f8
129 changed files with 3705 additions and 11065 deletions

View File

@@ -20,9 +20,9 @@ import (
)
const (
SoftwareStatusUploaded = "Uploaded"
SoftwareStatusInactive = "Inactive"
SoftwareStatusActive = "Active"
SoftwareStatusUploaded = "3"
SoftwareStatusInactive = "3"
SoftwareStatusActive = "1"
DigestsSignOkString = "digests signatures OK"
SoftwareVerifiedOk = "Verified OK"
)
@@ -419,7 +419,7 @@ func DownloadSoftwareFile(w http.ResponseWriter, r *http.Request) {
return
}
fileName := (*neSoftware)[0]["file_name"]
fileName := (*neSoftware)[0]["name"]
path := (*neSoftware)[0]["path"]
md5Sum := (*neSoftware)[0]["md5_sum"]
@@ -473,7 +473,7 @@ func DeleteSoftwareFile(w http.ResponseWriter, r *http.Request) {
return
}
fileName := (*neSoftware)[0]["file_name"]
fileName := (*neSoftware)[0]["name"]
path := (*neSoftware)[0]["path"]
filePath := fmt.Sprintf("%s/%s", path, fileName)
err = os.Remove(filePath)
@@ -560,7 +560,7 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return
}
fileName := (*neSoftware)[0]["file_name"]
fileName := (*neSoftware)[0]["name"]
path := (*neSoftware)[0]["path"]
srcFile := fmt.Sprintf("%s/%s", path, fileName)
@@ -611,7 +611,7 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
Version: (*neSoftware)[0]["version"],
FilePath: fmt.Sprintf("%s/software/%s/%s", config.GetYamlConfig().NE.OmcDir, neTypeLower, fileName),
PreVersion: (*neVersion)[0]["version"],
PreFile: (*neVersion)[0]["file_path"],
PreFile: (*neVersion)[0]["path"],
Status: SoftwareStatusInactive,
}
@@ -695,21 +695,29 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
log.Trace("neVersion:", neVersion)
if !config.GetYamlConfig().OMC.TestMode {
filePath := (*neVersion)[0]["file_path"]
filePath := (*neVersion)[0]["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"])
@@ -919,7 +935,7 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
PreVersion: "-",
PreFile: "-",
NewVersion: (*neVersion)[0]["version"],
NewFile: (*neVersion)[0]["file_path"],
NewFile: (*neVersion)[0]["path"],
Status: SoftwareStatusActive,
}
@@ -1021,7 +1037,7 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
PreVersion: "-",
PreFile: "-",
NewVersion: (*neVersion)[0]["version"],
NewFile: (*neVersion)[0]["file_path"],
NewFile: (*neVersion)[0]["path"],
Status: SoftwareStatusActive,
}