fix: 网元备份文件支持处理IMS配置
This commit is contained in:
@@ -153,10 +153,11 @@ func (s *NeConfigBackupController) Export(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 新增备份记录
|
// 新增备份记录
|
||||||
item := model.NeConfigBackup{
|
item := model.NeConfigBackup{
|
||||||
NeType: neInfo.NeType,
|
NeType: neInfo.NeType,
|
||||||
NeId: neInfo.NeId,
|
NeId: neInfo.NeId,
|
||||||
Name: filepath.Base(zipFilePath),
|
Name: filepath.Base(zipFilePath),
|
||||||
Path: zipFilePath,
|
Path: zipFilePath,
|
||||||
|
CreateBy: ctx.LoginUserToUserName(c),
|
||||||
}
|
}
|
||||||
s.neConfigBackupService.Insert(item)
|
s.neConfigBackupService.Insert(item)
|
||||||
c.FileAttachment(item.Path, item.Name)
|
c.FileAttachment(item.Path, item.Name)
|
||||||
|
|||||||
@@ -100,13 +100,30 @@ func (r *NeConfigBackupImpl) NeConfigLocalToNe(neInfo model.NeInfo, localFile st
|
|||||||
|
|
||||||
// 网元配置端上的临时目录
|
// 网元配置端上的临时目录
|
||||||
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
|
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
|
||||||
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp))
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc && sudo rm -rf %s", neDirTemp))
|
||||||
// 复制到网元端
|
// 复制到网元端
|
||||||
if err = sftpClient.CopyDirLocalToRemote(localDirPath, neDirTemp); err != nil {
|
if err = sftpClient.CopyDirLocalToRemote(localDirPath, neDirTemp); err != nil {
|
||||||
return fmt.Errorf("copy config to ne err")
|
return fmt.Errorf("copy config to ne err")
|
||||||
}
|
}
|
||||||
neEtcPath := fmt.Sprintf("/usr/local/etc/%s", neTypeLower)
|
|
||||||
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf %s/* %s && sudo chmod 775 %s/*.yaml", neDirTemp, neEtcPath, neEtcPath))
|
// 配置复制到网元内
|
||||||
|
if neTypeLower == "ims" {
|
||||||
|
// ims目录
|
||||||
|
imsDirArr := [...]string{"bgcf", "icscf", "ismc", "mmtel", "mrf", "oam_manager.yaml", "pcscf", "scscf", "vars.cfg", "zlog"}
|
||||||
|
for _, v := range imsDirArr {
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /usr/local/etc/ims && sudo cp -rf %s/ims/%s /usr/local/etc/ims/%v && sudo chmod 755 -R /usr/local/etc/ims/%s", neDirTemp, v, v, v))
|
||||||
|
}
|
||||||
|
// mf目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /usr/local/etc/mf && sudo cp -rf %s/mf/* /usr/local/etc/mf && sudo chmod 755 -R /usr/local/etc/mf", neDirTemp))
|
||||||
|
// rtproxy目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /usr/local/etc/rtproxy && sudo cp -rf %s/rtproxy/* /usr/local/etc/rtproxy && sudo chmod 755 /usr/local/etc/rtproxy/rtproxy.conf", neDirTemp))
|
||||||
|
// iwf目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /usr/local/etc/iwf && sudo cp -rf %s/iwf/* /usr/local/etc/iwf && sudo chmod 755 /usr/local/etc/iwf/*.yaml", neDirTemp))
|
||||||
|
} else {
|
||||||
|
neEtcPath := fmt.Sprintf("/usr/local/etc/%s", neTypeLower)
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf %s/* %s && sudo chmod 755 %s/*.yaml", neDirTemp, neEtcPath, neEtcPath))
|
||||||
|
}
|
||||||
|
|
||||||
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
|
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
|
||||||
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
|
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
|
||||||
return nil
|
return nil
|
||||||
@@ -134,11 +151,29 @@ func (r *NeConfigBackupImpl) NeConfigNeToLocal(neInfo model.NeInfo) (string, err
|
|||||||
omcPath = fmt.Sprintf("C:%s", omcPath)
|
omcPath = fmt.Sprintf("C:%s", omcPath)
|
||||||
}
|
}
|
||||||
localDirPath := fmt.Sprintf("%s/%s/%s/backup/tmp_export", omcPath, neTypeLower, neInfo.NeId)
|
localDirPath := fmt.Sprintf("%s/%s/%s/backup/tmp_export", omcPath, neTypeLower, neInfo.NeId)
|
||||||
|
|
||||||
// 网元配置文件先复制到临时目录
|
// 网元配置文件先复制到临时目录
|
||||||
nePath := fmt.Sprintf("/usr/local/etc/%s/*.yaml", neTypeLower)
|
sshClient.RunCMD("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc")
|
||||||
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
|
neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId)
|
||||||
sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p %s && sudo cp -rf %s %s", neDirTemp, nePath, neDirTemp))
|
if neTypeLower == "ims" {
|
||||||
// 复制到本地
|
// ims目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/ims", neDirTemp))
|
||||||
|
imsDirArr := [...]string{"bgcf", "icscf", "ismc", "mmtel", "mrf", "oam_manager.yaml", "pcscf", "scscf", "vars.cfg", "zlog"}
|
||||||
|
for _, v := range imsDirArr {
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf /usr/local/etc/ims/%s %s/ims", v, neDirTemp))
|
||||||
|
}
|
||||||
|
// mf目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/mf && sudo cp -rf /usr/local/etc/mf %s", neDirTemp, neDirTemp))
|
||||||
|
// rtproxy目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/rtproxy && sudo cp -rf /usr/local/etc/rtproxy/rtproxy.conf %s/rtproxy", neDirTemp, neDirTemp))
|
||||||
|
// iwf目录
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s/iwf && sudo cp -rf /usr/local/etc/iwf/*.yaml %s/iwf", neDirTemp, neDirTemp))
|
||||||
|
} else {
|
||||||
|
nePath := fmt.Sprintf("/usr/local/etc/%s/*.yaml", neTypeLower)
|
||||||
|
sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo cp -rf %s %s", neDirTemp, nePath, neDirTemp))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网元端复制到本地
|
||||||
if err = sftpClient.CopyDirRemoteToLocal(neDirTemp, localDirPath); err != nil {
|
if err = sftpClient.CopyDirRemoteToLocal(neDirTemp, localDirPath); err != nil {
|
||||||
return "", fmt.Errorf("copy config err")
|
return "", fmt.Errorf("copy config err")
|
||||||
}
|
}
|
||||||
@@ -149,6 +184,7 @@ func (r *NeConfigBackupImpl) NeConfigNeToLocal(neInfo model.NeInfo) (string, err
|
|||||||
if err := file.CompressZipByDir(zipFilePath, localDirPath); err != nil {
|
if err := file.CompressZipByDir(zipFilePath, localDirPath); err != nil {
|
||||||
return "", fmt.Errorf("compress zip err")
|
return "", fmt.Errorf("compress zip err")
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
|
_ = os.RemoveAll(localDirPath) // 删除本地临时目录
|
||||||
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
|
sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", neDirTemp)) // 删除临时目录
|
||||||
return zipFilePath, nil
|
return zipFilePath, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user