ESXi: Fix failure to get VM IP when `displayName` differs from `vm_name`

The value in the Name field returned by 'esxcli network vm list'
actually returns the VMs `displayName`. As such, we need to match
against `displayName` to discover the VMs 'WorldID'.
'WorldId' is ultimately used/needed as an argument in the command that
returns the VMs IP.
This commit is contained in:
DanHam 2018-07-02 13:19:41 +01:00
parent 3eab3cc99b
commit cd7d3812ea
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 7 additions and 1 deletions

View File

@ -389,7 +389,13 @@ func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error) {
return "", err return "", err
} }
record, err := r.find("Name", config.VMName) // The value in the Name field returned by 'esxcli network vm list'
// corresponds directly to the value of displayName set in the VMX file
var displayName string
if v, ok := state.GetOk("display_name"); ok {
displayName = v.(string)
}
record, err := r.find("Name", displayName)
if err != nil { if err != nil {
return "", err return "", err
} }