Lines Matching refs:addr

31 func newSSHClient(addr string, user string, passwd string) (*ssh.Client, error) {
38 return ssh.Dial("tcp", addr, config)
41 func RunCmdViaSSHContext(ctx context.Context, addr string, user string, passwd string, cmd string) (err error) {
44 if err := RunCmdViaSSHContextNoRetry(ctx, addr, user, passwd, cmd); err != nil {
48 logrus.Errorf("exec cmd via SSH at %s failed: %v, try again...", addr, err)
49 return RunCmdViaSSHContextNoRetry(ctx, addr, user, passwd, cmd)
54 func RunCmdViaSSHContextNoRetry(ctx context.Context, addr string, user string, passwd string, cmd string) (err error) {
56 client, err := newSSHClient(addr, user, passwd)
58 logrus.Errorf("new SSH client to %s err: %v", addr, err)
81 logrus.Infof("run at %s: %s", addr, cmd)
102 fmt.Printf("[%s] exec at %s %s :\n", time.Now(), addr, cmd)
113 func TransFileViaSSH(verb Direct, addr string, user string, passwd string, remoteFile string, localFile string) error {
114 c, err := newSSHClient(addr, user, passwd)
116 logrus.Errorf("new SSH client to %s err: %v", addr, err)
122 logrus.Errorf("new SFTP client to %s err: %v", addr, err)
131 return fmt.Errorf("open remote file %s at %s err: %v", remoteFile, addr, err)
149 return fmt.Errorf("create remote file %s at %s err: %v", remoteFile, addr, err)
153 logrus.Infof("%sing %s at %s %s %s...", verb, remoteFile, addr, prep, localFile)
157 logrus.Errorf("%s %s at %s %s %s err: %v", verb, remoteFile, addr, prep, localFile, err)
162 logrus.Infof("%s %s at %s %s %s done, size: %d cost: %.2fs speed: %.2fMB/s", verb, remoteFile, addr, prep, localFile, n, cost, float64(n)/cost/1024/1024)