From be6dcc090570207f8bbcbcabc859adb3542eb156 Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Wed, 25 Mar 2015 13:46:46 -0700 Subject: [PATCH] fixes issue #831 and issue #771 by checking for unset active machine name Signed-off-by: Ken Pepple --- commands.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/commands.go b/commands.go index 4909f7e5..63ea0f19 100644 --- a/commands.go +++ b/commands.go @@ -760,6 +760,10 @@ func cmdSsh(c *cli.Context) { log.Fatalf("unable to get active host: %v", err) } + if host == nil { + log.Fatalf("There is no active host. Please set it with %s active .", c.App.Name) + } + name = host.Name } @@ -768,6 +772,15 @@ func cmdSsh(c *cli.Context) { log.Fatal(err) } + _, err = host.GetURL() + if err != nil { + if err == drivers.ErrHostIsNotRunning { + log.Fatalf("%s is not running. Please start this with docker-machine start %s", host.Name, host.Name) + } else { + log.Fatalf("Unexpected error getting machine url: %s", err) + } + } + if len(c.Args()) <= 1 { sshCmd, err = host.GetSSHCommand() } else { @@ -880,6 +893,9 @@ func runActionWithContext(actionName string, c *cli.Context) error { if err != nil { log.Fatalf("Unable to get active host: %v", err) } + if activeHost == nil { + log.Fatalf("There is no active host. Please set it with %s active .", c.App.Name) + } machines = []*libmachine.Host{activeHost} }