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) {
123
123
return "" , drivers .ErrHostIsNotRunning
124
124
}
125
125
126
+ // attempt to find the address from vmrun
127
+ if ip , err := d .getIPfromVmrun (); err == nil {
128
+ return ip , err
129
+ }
130
+
126
131
// determine MAC address for VM
127
132
macaddr , err := d .getMacAddressFromVmx ()
128
133
if err != nil {
@@ -401,6 +406,18 @@ func (d *Driver) getMacAddressFromVmx() (string, error) {
401
406
return macaddr , nil
402
407
}
403
408
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
+
404
421
func (d * Driver ) getIPfromVmnetConfiguration (macaddr string ) (string , error ) {
405
422
406
423
// DHCP lease table for NAT vmnet interface
You can’t perform that action at this time.
0 commit comments