Skip to content

Commit

Permalink
Fix get state when d.Start() and d.Restart()
Browse files Browse the repository at this point in the history
- Wait for available SSH login

Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Jan 12, 2016
1 parent bd31ec2 commit 6748d83
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions xhyve/xhyve.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}

return fmt.Sprintf("tcp://%s:2376", ip), nil
}

Expand Down Expand Up @@ -214,6 +215,18 @@ func (d *Driver) GetState() (state.State, error) {
return state.Running, nil
}

func (d *Driver) waitForIP() error {
// Wait for SSH over NAT to be available before returning to user
if err := drivers.WaitForSSH(d); err != nil {
return err
}

var err error
d.IPAddress, err = d.GetIP()

return err
}

// Print driver version, Check VirtualBox version
func (d *Driver) PreCreateCheck() error {
//TODO:libmachine PLEASE output driver version API!
Expand Down Expand Up @@ -347,7 +360,8 @@ func (d *Driver) Start() error {
}
}()

return nil
log.Infof("Waiting for an IP...")
return d.waitForIP()
}

func (d *Driver) Stop() error {
Expand Down Expand Up @@ -410,7 +424,6 @@ func (d *Driver) Restart() error {
if err != nil {
return err
}

if s == state.Running {
if err := d.Stop(); err != nil {
return err
Expand All @@ -421,7 +434,7 @@ func (d *Driver) Restart() error {
return err
}

return nil
return d.waitForIP()
}

func (d *Driver) Kill() error {
Expand Down

0 comments on commit 6748d83

Please sign in to comment.