fix: ims etc backup list

This commit is contained in:
2023-10-26 16:25:02 +08:00
parent fab2c9f90d
commit 4a651caac0
4 changed files with 24 additions and 5 deletions

View File

@@ -423,7 +423,13 @@ func ExportCmFromNF(w http.ResponseWriter, r *http.Request) {
var scpCmd string
ipType := global.ParseIPAddr(neInfo.Ip)
if neTypeLower != "omc" {
omcNetypeLower := strings.ToLower(config.GetYamlConfig().OMC.NeType)
etcListIMS := "{*.yaml,mmtel,vars.cfg}"
if config.GetYamlConfig().NE.EtcListIMS != "" {
etcListIMS = config.GetYamlConfig().NE.EtcListIMS
}
switch neTypeLower {
case omcNetypeLower:
if ipType == global.IsIPv4 {
scpCmd = fmt.Sprintf("scp -r %s@%s:%s/%s/*.yaml %s/etc/%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.EtcDir,
@@ -433,7 +439,17 @@ func ExportCmFromNF(w http.ResponseWriter, r *http.Request) {
neInfo.Ip, config.GetYamlConfig().NE.EtcDir,
neTypeLower, config.GetYamlConfig().OMC.Backup, neTypeLower)
}
} else {
case "ims":
if ipType == global.IsIPv4 {
scpCmd = fmt.Sprintf("scp -r %s@%s:%s/%s/%s %s/etc/%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.EtcDir, neTypeLower,
etcListIMS, config.GetYamlConfig().OMC.Backup, neTypeLower)
} else {
scpCmd = fmt.Sprintf("scp -r %s@[%s]:%s/%s/%s %s/etc/%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.EtcDir, neTypeLower,
etcListIMS, config.GetYamlConfig().OMC.Backup, neTypeLower)
}
default:
if ipType == global.IsIPv4 {
scpCmd = fmt.Sprintf("scp -r %s@%s:%s/etc/*.yaml %s/etc/%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.OmcDir, config.GetYamlConfig().OMC.Backup, neTypeLower)

View File

@@ -698,7 +698,7 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return
}
} else if fileType == 2 {
dpkgCmd := fmt.Sprintf("sudo dpkg -i '%s'", filePath)
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
cmd := exec.Command("ssh", sshHost, dpkgCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
@@ -744,7 +744,6 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
services.ResponseInternalServerError500ProcessError(w, err)
return
}
}
}
@@ -839,7 +838,7 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return
}
} else if fileType == 2 {
dpkgCmd := fmt.Sprintf("sudo dpkg -i '%s'", filePath)
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
cmd := exec.Command("ssh", sshHost, dpkgCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))

View File

@@ -114,6 +114,7 @@ type YamlConfig struct {
OmcDir string `yaml:"omcdir"`
ScpDir string `yaml:"scpdir"`
LicenseDir string `yaml:"licensedir"`
EtcListIMS string `yaml:"etcListIMS"`
} `yaml:"ne"`
Auth struct {

View File

@@ -69,6 +69,7 @@ mml:
mmlHome: ./mmlhome
upload: /home/agtuser
# NE config
ne:
user: root
etcdir: /usr/local/etc
@@ -76,6 +77,8 @@ ne:
omcdir: /usr/local/omc
scpdir: /tmp
licensedir: /usr/local/etc/{neType}/license
# backup etc list of IMS
etcListIMS: '{*.yaml,mmtel,vars.cfg}'
# chk2ne: true/false, if put OmcNeConfig parameters to NE
omc: