From 3b06c2c77f2cca4b65d94b938921b9ec0a33c23a Mon Sep 17 00:00:00 2001 From: Ling Samuel Date: Thu, 21 Jan 2021 17:32:09 +0800 Subject: [PATCH] Hyper-V ip use cached value Signed-off-by: Ling Samuel --- drivers/hyperv/hyperv.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hyperv/hyperv.go b/drivers/hyperv/hyperv.go index a980cf11f4..02044481d7 100644 --- a/drivers/hyperv/hyperv.go +++ b/drivers/hyperv/hyperv.go @@ -414,6 +414,9 @@ func (d *Driver) Kill() error { } func (d *Driver) GetIP() (string, error) { + if d.IPAddress != "" { + return d.IPAddress, nil + } s, err := d.GetState() if err != nil { return "", err @@ -432,7 +435,8 @@ func (d *Driver) GetIP() (string, error) { return "", fmt.Errorf("IP not found") } - return resp[0], nil + d.IPAddress = resp[0] + return d.IPAddress, nil } func (d *Driver) publicSSHKeyPath() string {