fixes issue #831 and issue #771 by checking for unset active machine name

Signed-off-by: Ken Pepple <ken@solinea.com>
This commit is contained in:
Ken Pepple
2015-03-25 13:46:46 -07:00
parent 87f12c3a5c
commit be6dcc0905

View File

@@ -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 <machine name>.", 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 <machine name>.", c.App.Name)
}
machines = []*libmachine.Host{activeHost}
}