1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
redhat_ssh_commander.go 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
Nathan LeClaire 提交于 2016-11-15 15:20 . Fix golint errors
package provision
import (
"fmt"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/log"
"github.com/docker/machine/libmachine/ssh"
)
type RedHatSSHCommander struct {
Driver drivers.Driver
}
func (sshCmder RedHatSSHCommander) SSHCommand(args string) (string, error) {
client, err := drivers.GetSSHClientFromDriver(sshCmder.Driver)
if err != nil {
return "", err
}
log.Debugf("About to run SSH command:\n%s", args)
// redhat needs "-t" for tty allocation on ssh therefore we check for the
// external client and add as needed.
// Note: CentOS 7.0 needs multiple "-tt" to force tty allocation when ssh has
// no local tty.
var output string
switch c := client.(type) {
case *ssh.ExternalClient:
c.BaseArgs = append(c.BaseArgs, "-tt")
output, err = c.Output(args)
case *ssh.NativeClient:
output, err = c.OutputWithPty(args)
}
log.Debugf("SSH cmd err, output: %v: %s", err, output)
if err != nil {
return "", fmt.Errorf(`something went wrong running an SSH command
command : %s
err : %v
output : %s`, args, err, output)
}
return output, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.13.0-rancher2

搜索帮助

0d507c66 1850385 C8b1a773 1850385