2014-04-06 13:21:22 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2014-04-06 13:21:22 -04:00
|
|
|
)
|
|
|
|
|
2016-12-16 14:51:55 -05:00
|
|
|
// CommHost returns the VM's IP address which should be used to access it by SSH.
|
2015-06-13 19:23:33 -04:00
|
|
|
func CommHost(state multistep.StateBag) (string, error) {
|
2014-04-06 13:21:22 -04:00
|
|
|
vmName := state.Get("vmName").(string)
|
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
|
2016-12-11 13:49:54 -05:00
|
|
|
mac, err := driver.MAC(vmName)
|
2014-04-06 13:21:22 -04:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
2016-12-11 13:49:54 -05:00
|
|
|
ip, err := driver.IPAddress(mac)
|
2014-04-06 13:21:22 -04:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:23:33 -04:00
|
|
|
return ip, nil
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|