providers/hyper-v: support more than one NIC [GH-4346]

This commit is contained in:
Mitchell Hashimoto 2015-11-23 12:05:37 -08:00
parent 55e872eda4
commit b23b48a614
2 changed files with 13 additions and 2 deletions

View File

@ -103,6 +103,7 @@ BUG FIXES:
- guests/suse: DHCP network interfaces properly configured [GH-6502]
- hosts/slackware: Better detection of NFS [GH-6367]
- providers/hyper-v: support generation 2 VMs [GH-6372]
- providers/hyper-v: support VMs with more than one NIC [GH-4346]
- providers/virtualbox: ignore "Unknown" status bridge interfaces [GH-6061]
- provisioners/ansible: use quotes for the `ansible_ssh_private_key_file`
value in the generated inventory [GH-6209]

View File

@ -7,9 +7,19 @@ Param(
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
$ip_address = ""
$vm = Get-VM -Id $VmId -ErrorAction "Stop"
$network = Get-VMNetworkAdapter -VM $vm
$ip_address = $network.IpAddresses[0]
$networks = Get-VMNetworkAdapter -VM $vm
foreach ($network in $networks) {
if ($network.IpAddresses.Length -gt 0) {
$ip_address = $network.IpAddresses[0]
if (-Not ([string]::IsNullOrEmpty($ip_address))) {
# We found our IP address!
break
}
}
}
$resultHash = @{
ip = "$ip_address"
}