style: 网元模块RunSSHClient函数命名
This commit is contained in:
@@ -298,26 +298,26 @@ func (r *NeInfoImpl) CheckUniqueNeTypeAndNeId(neType, neId, id string) bool {
|
||||
return uniqueId == ""
|
||||
}
|
||||
|
||||
// NeRunSSHclient 网元主机的SSH客户端-为创建相关连接
|
||||
func (r *NeInfoImpl) NeRunSSHclient(neType, neId string) (*ssh.ConnSSH, error) {
|
||||
// NeRunSSHClient 网元主机的SSH客户端-为创建相关连接
|
||||
func (r *NeInfoImpl) NeRunSSHClient(neType, neId string) (*ssh.ConnSSH, error) {
|
||||
neInfo := r.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||
if neInfo.NeId != neId {
|
||||
logger.Errorf("NeRunSSHclient NeType:%s NeID:%s not found", neType, neId)
|
||||
logger.Errorf("NeRunSSHClient NeType:%s NeID:%s not found", neType, neId)
|
||||
return nil, fmt.Errorf("neinfo not found")
|
||||
}
|
||||
// 取主机信息
|
||||
if neInfo.HostIDs == "" {
|
||||
logger.Errorf("NeRunSSHclient NeType:%s NeID:%s hostId not found", neType, neId)
|
||||
logger.Errorf("NeRunSSHClient NeType:%s NeID:%s hostId not found", neType, neId)
|
||||
return nil, fmt.Errorf("neinfo hostId not found")
|
||||
}
|
||||
neInfo.Hosts = NewNeHostImpl.neHostRepository.SelectByIds(strings.Split(neInfo.HostIDs, ","))
|
||||
if len(neInfo.Hosts) <= 0 {
|
||||
logger.Errorf("NeRunSSHclient Hosts %s not found", neInfo.HostIDs)
|
||||
logger.Errorf("NeRunSSHClient Hosts %s not found", neInfo.HostIDs)
|
||||
return nil, fmt.Errorf("neinfo host not found")
|
||||
}
|
||||
neHost := neInfo.Hosts[0]
|
||||
if neHost.HostType != "ssh" {
|
||||
logger.Errorf("NeRunSSHclient Hosts first HostType %s not ssh", neHost.HostType)
|
||||
logger.Errorf("NeRunSSHClient Hosts first HostType %s not ssh", neHost.HostType)
|
||||
return nil, fmt.Errorf("neinfo host type not ssh")
|
||||
}
|
||||
|
||||
@@ -331,15 +331,15 @@ func (r *NeInfoImpl) NeRunSSHclient(neType, neId string) (*ssh.ConnSSH, error) {
|
||||
client, err = connSSH.NewClient()
|
||||
}
|
||||
if err != nil {
|
||||
logger.Errorf("NeRunSSHclient NewClient err => %s", err.Error())
|
||||
logger.Errorf("NeRunSSHClient NewClient err => %s", err.Error())
|
||||
return nil, fmt.Errorf("neinfo ssh client new err")
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// NeRunCMD 向网元发送cmd命令
|
||||
func (r *NeInfoImpl) NeRunCMD(neType, neId, cmd string) (string, error) {
|
||||
sshClient, err := r.NeRunSSHclient(neType, neId)
|
||||
// NeRunSSHCmd 网元主机的SSH客户端发送cmd命令
|
||||
func (r *NeInfoImpl) NeRunSSHCmd(neType, neId, cmd string) (string, error) {
|
||||
sshClient, err := r.NeRunSSHClient(neType, neId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -348,7 +348,7 @@ func (r *NeInfoImpl) NeRunCMD(neType, neId, cmd string) (string, error) {
|
||||
// 执行命令
|
||||
output, err := sshClient.RunCMD(cmd)
|
||||
if err != nil {
|
||||
logger.Errorf("NeRunCMD RunCMD %s err => %s", output, err.Error())
|
||||
logger.Errorf("NeRunSSHCmd RunCMD %s err => %s", output, err.Error())
|
||||
return "", fmt.Errorf("neinfo ssh run cmd err")
|
||||
}
|
||||
return output, nil
|
||||
@@ -447,7 +447,7 @@ func (r *NeInfoImpl) neConfOAMWirte(neType, neId string, content any, sync bool)
|
||||
// 同步到网元端
|
||||
if sync {
|
||||
// 网元主机的SSH客户端
|
||||
sshClient, err := r.NeRunSSHclient(neType, neId)
|
||||
sshClient, err := r.NeRunSSHClient(neType, neId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -609,7 +609,7 @@ func (r *NeInfoImpl) NeConfPara5GWirte(content map[string]any, syncNE []string)
|
||||
for _, neTI := range syncNE {
|
||||
ti := strings.SplitN(neTI, "@", 2)
|
||||
// 网元主机的SSH客户端
|
||||
sshClient, err := r.NeRunSSHclient(ti[0], ti[1])
|
||||
sshClient, err := r.NeRunSSHClient(ti[0], ti[1])
|
||||
if err != nil {
|
||||
errMsg = append(errMsg, fmt.Sprintf("%s : %s", ti, err.Error()))
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user