Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetIP and GetState to Correctly get vm status #10

Merged
merged 1 commit into from
Nov 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions xhyve.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,28 @@ func (d *Driver) GetURL() (string, error) {
}

func (d *Driver) GetIP() (string, error) {
s, err := d.GetState()
if err != nil {
return "", err
}
if s != state.Running {
return "", drivers.ErrHostIsNotRunning
}

ip, err := d.getIPfromDHCPLease()
if err != nil {
return "", err
if d.IPAddress != "" {
return d.IPAddress, nil
}

return ip, nil
return d.getIPfromDHCPLease()
}

func (d *Driver) GetState() (state.State, error) { // TODO
// VMRUN only tells use if the vm is running or not
// if stdout, _, _ := vmrun("list"); strings.Contains(stdout, d.vmxPath()) {
s, err := d.GetSShStates()
if !s {
return state.Stopping, err
}
return state.Running, nil
// }
// return state.Stopped, nil
}

func (d *Driver) GetSShStates() (bool, error) {
log.Debug("Getting to WaitForSSH function...")
if _, err := drivers.RunSSHCommandFromDriver(d, "exit 0"); err != nil {
log.Debugf("Error getting ssh command 'exit 0' : %s", err)
return false, nil
}
return true, nil
}

// Check VirtualBox version
Expand Down Expand Up @@ -245,11 +245,10 @@ func (d *Driver) Create() error {
if err := d.Start(); err != nil {
return err
}
log.Infof("Waiting for VM to come online...")

var ip string
var err error
log.Infof("Waiting for VM to come online...")
log.Debugf("d.MacAddr", d.MacAddr)
for i := 1; i <= 60; i++ {
ip, err = d.getIPfromDHCPLease()
if err != nil {
Expand Down