feat: 移除ssh客户端改为本地bash

This commit is contained in:
TsMask
2025-05-13 17:22:04 +08:00
parent 552abb411c
commit f7f63f1950
21 changed files with 526 additions and 590 deletions

View File

@@ -532,25 +532,29 @@ func (s *UDMVolteIMSController) Import(c *gin.Context) {
}
// 网元主机的SSH客户端
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
if err != nil {
c.JSON(200, resp.ErrMsg(err.Error()))
return
}
defer sshClient.Close()
// 网元主机的SSH客户端进行文件传输
sftpClient, err := sshClient.NewClientSFTP()
if err != nil {
c.JSON(200, resp.ErrMsg(err.Error()))
return
}
defer sftpClient.Close()
// sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
// if err != nil {
// c.JSON(200, resp.ErrMsg(err.Error()))
// return
// }
// defer sshClient.Close()
// // 网元主机的SSH客户端进行文件传输
// sftpClient, err := sshClient.NewClientSFTP()
// if err != nil {
// c.JSON(200, resp.ErrMsg(err.Error()))
// return
// }
// defer sftpClient.Close()
// 本地文件
localFilePath := file.ParseUploadFileAbsPath(body.UploadPath)
neFilePath := fmt.Sprintf("/tmp/%s", filepath.Base(localFilePath))
// 复制到远程
if err = sftpClient.CopyFileLocalToRemote(localFilePath, neFilePath); err != nil {
// if err = sftpClient.CopyFileLocalToRemote(localFilePath, neFilePath); err != nil {
// c.JSON(200, resp.ErrMsg("error uploading file"))
// return
// }
if err := file.CopyFile(localFilePath, neFilePath); err != nil {
c.JSON(200, resp.ErrMsg("error uploading file"))
return
}