Monday, May 21, 2012

Virtual port group details

I know there are tools that get all this info, but not in the form I needed and when and where I needed - during vmnic migration  and port group reconfiguration. The idea was to redistribute traffic on different vmincs and to keep failover at the vSwitch level.  In order to check the status of the port groups on each host, I used the following:

$report=@()

get-vmhost | foreach {
foreach ($vsw in Get-VirtualSwitch -VMHost $_)
{
 $hostName = $_.Name
foreach ($vpg in Get-VirtualPortGroup -VirtualSwitch $vsw)
{
 $row = " " | Select hostName, vpgName, vpgInherit, vpgAN, vpgSN, vpgUN, vpgFailover, vpgLB
$vpgnicteaming = Get-NicTeamingPolicy -VirtualPortGroup $vpg

$row.hostName = $hostName
$row.vpgName = $vpgnicteaming.VirtualPortGroup.Name
$row.vpgInherit = $vpgnicteaming.IsFailoverOrderInherited
$row.vpgAN = $vpgnicteaming.ActiveNic
$row.vpgSN = $vpgnicteaming.StandbyNic
$row.vpgUN = $vpgnicteaming.UnusedNic
$row.vpgFailover = $vpgnicteaming.NetworkFailoverDetectionPolicy
$row.vpgLB = $vpgnicteaming.LoadBalancingPolicy

 $report += $row
}
}
}
$report

The things I am looking for is to find out for each virtual port group what are the active, stanby and unused interfaces, what type of failover and load balancing policies are implemented. After running the script I got the following listing (the listing is reduced):

hostName    : testbox.esxi
vpgName     : VM Network
vpgInherit  : True
vpgAN       : {vmnic0}
vpgSN       :
vpgUN       :
vpgFailover : LinkStatus
vpgLB       : LoadBalanceSrcId

hostName    : testbox.esxi
vpgName     : vmk_vMotion
vpgInherit  : True
vpgAN       : {vmnic1}
vpgSN       :
vpgUN       :
vpgFailover : LinkStatus
vpgLB       : LoadBalanceSrcId

My setup involves separating traffic at vmnic level - vminc0 used for VM traffic, while vmnic1 is used for vMotion. Both vminc0 and vminc1 are attached to the same vSwitch.

No comments: