The main goal of this patch was to make the VirtualBox driver wait for SSH before trying to get the IP of the VM. The generic WaitForSSH method required a Host struct as an arg. This patch moves most of the logic to the driver package so that drivers can call WaitForSSH. The existing functions in host are just wrappers to the real implementation in drivers now. Signed-off-by: Darren Shepherd <darren@rancher.com>
23 lines
304 B
Go
23 lines
304 B
Go
package ssh
|
|
|
|
import (
|
|
"net"
|
|
"time"
|
|
|
|
"github.com/docker/machine/log"
|
|
)
|
|
|
|
func WaitForTCP(addr string) error {
|
|
for {
|
|
log.Debugf("Testing TCP connection to: %s", addr)
|
|
conn, err := net.DialTimeout("tcp", addr, 2*time.Second)
|
|
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
defer conn.Close()
|
|
return nil
|
|
}
|
|
}
|