File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,11 @@ func (d *Driver) GetIP() (ip string, err error) {
123123 return "" , drivers .ErrHostIsNotRunning
124124 }
125125
126+ // attempt to find the address from vmrun
127+ if ip , err := d .getIPfromVmrun (); err == nil {
128+ return ip , err
129+ }
130+
126131 // determine MAC address for VM
127132 macaddr , err := d .getMacAddressFromVmx ()
128133 if err != nil {
@@ -401,6 +406,18 @@ func (d *Driver) getMacAddressFromVmx() (string, error) {
401406 return macaddr , nil
402407}
403408
409+ func (d * Driver ) getIPfromVmrun () (string , error ) {
410+ vmx := d .vmxPath ()
411+
412+ ip := regexp .MustCompile (`\d+\.\d+\.\d+\.\d+` )
413+ stdout , _ , _ := vmrun ("getGuestIPAddress" , vmx )
414+ if match := ip .FindString (stdout ); match != "" {
415+ return match , nil
416+ }
417+
418+ return "" , fmt .Errorf ("could not get IP from vmrun" )
419+ }
420+
404421func (d * Driver ) getIPfromVmnetConfiguration (macaddr string ) (string , error ) {
405422
406423 // DHCP lease table for NAT vmnet interface
You can’t perform that action at this time.
0 commit comments