From ec4697ea3379b79cef47f50cac44efee283b5ace Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shinji Date: Tue, 14 Jun 2016 11:13:32 +0000 Subject: [PATCH] Add SSH logs when provisioning with RedHat derivatives Fixes #3507 Signed-off-by: KOBAYASHI Shinji --- libmachine/provision/redhat_ssh_commander.go | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/libmachine/provision/redhat_ssh_commander.go b/libmachine/provision/redhat_ssh_commander.go index 32ddd18483..04b52442a0 100644 --- a/libmachine/provision/redhat_ssh_commander.go +++ b/libmachine/provision/redhat_ssh_commander.go @@ -1,7 +1,10 @@ package provision import ( + "fmt" + "github.com/docker/machine/libmachine/drivers" + "github.com/docker/machine/libmachine/log" "github.com/docker/machine/libmachine/ssh" ) @@ -15,17 +18,29 @@ func (sshCmder RedHatSSHCommander) SSHCommand(args string) (string, error) { 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") - client = c + output, err = c.Output(args) case *ssh.NativeClient: - return c.OutputWithPty(args) + output, err = c.OutputWithPty(args) } - return client.Output(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 }