Skip to content
Merged
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions pkg/drivers/vmware/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ func (d *Driver) GetIP() (ip string, err error) {
return "", drivers.ErrHostIsNotRunning
}

// attempt to find the address from vmrun
if ip, err := d.getIPfromVmrun(); err == nil {
return ip, err
}

// determine MAC address for VM
macaddr, err := d.getMacAddressFromVmx()
if err != nil {
Expand Down Expand Up @@ -401,6 +406,18 @@ func (d *Driver) getMacAddressFromVmx() (string, error) {
return macaddr, nil
}

func (d *Driver) getIPfromVmrun() (string, error) {
vmx := d.vmxPath()

ip := regexp.MustCompile(`\d+\.\d+\.\d+\.\d+`)
stdout, _, _ := vmrun("getGuestIPAddress", vmx)
if match := ip.FindString(stdout); match != "" {
return match, nil
}

return "", fmt.Errorf("could not get IP from vmrun")
}

func (d *Driver) getIPfromVmnetConfiguration(macaddr string) (string, error) {

// DHCP lease table for NAT vmnet interface
Expand Down