From f2284b2bd569b83c05f03464869864055db7c1a1 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 12 Jul 2015 07:42:27 -0400 Subject: [PATCH] Just informing the user that re-eval may be necessary, instead of going to the trouble of trying to detect IP changes Signed-off-by: Dave Henderson --- commands/restart.go | 59 +-------------------------------------------- commands/start.go | 1 + 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/commands/restart.go b/commands/restart.go index efc6f73cfc..6e04f75655 100644 --- a/commands/restart.go +++ b/commands/restart.go @@ -1,10 +1,6 @@ package commands import ( - "os" - "strings" - - "github.com/docker/machine/libmachine" "github.com/docker/machine/log" "github.com/codegangsta/cli" @@ -14,58 +10,5 @@ func cmdRestart(c *cli.Context) { if err := runActionWithContext("restart", c); err != nil { log.Fatal(err) } - - warnIfActiveIPChanged(c) -} - -func warnIfActiveIPChanged(c *cli.Context) { - if activeInList(c.Args()) { - activeURL := os.Getenv("DOCKER_HOST") - log.Debugf("checking to see if active host's URL has changed from %s", activeURL) - - h := getActiveHost(c) - u, err := h.GetURL() - if err != nil { - log.Fatal(err) - } - if activeURL != u { - // TODO: hardcoded port here is a giant kludge... - var swarmOpt string - if strings.Contains(activeURL, ":3376") { - swarmOpt = "--swarm " - } - log.Warnf("Active machine was restarted, and has a new IP address.\nRun 'eval \"$(docker-machine env %s%s)\"' again.", swarmOpt, h.Name) - } - } -} - -func activeInList(machines []string) bool { - active := os.Getenv("DOCKER_MACHINE_NAME") - return active != "" && inArray(active, machines) -} - -func getActiveHost(c *cli.Context) *libmachine.Host { - certInfo := getCertPathInfo(c) - store, err := getDefaultStore( - c.GlobalString("storage-path"), - certInfo.CaCertPath, - certInfo.CaKeyPath, - ) - if err != nil { - log.Fatal(err) - } - active, err := store.GetActive() - if err != nil { - log.Fatal(err) - } - return active -} - -func inArray(s string, a []string) bool { - for _, cur := range a { - if cur == s { - return true - } - } - return false + log.Info("Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command.") } diff --git a/commands/start.go b/commands/start.go index 161e67ae7a..2cd7054ed7 100644 --- a/commands/start.go +++ b/commands/start.go @@ -10,4 +10,5 @@ func cmdStart(c *cli.Context) { if err := runActionWithContext("start", c); err != nil { log.Fatal(err) } + log.Info("Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.") }