Only get the IP of a running machine

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2015-12-22 17:55:32 +01:00
parent af87c000d2
commit 0c783976e0
1 changed files with 8 additions and 0 deletions

View File

@ -356,6 +356,14 @@ func (d *Driver) Kill() error {
}
func (d *Driver) GetIP() (string, error) {
s, err := d.GetState()
if err != nil {
return "", err
}
if s != state.Running {
return "", drivers.ErrHostIsNotRunning
}
stdout, err := cmdOut("((", "Get-VM", d.MachineName, ").networkadapters[0]).ipaddresses[0]")
if err != nil {
return "", err