For later productive use, we needed about 2000 portgroups in our Distributed Virtual Switch for our customer VMs.
We are pre-provisioning our DVS with these portgroups, so there is no need to create the PG, when it is needed.
Our network department just needs to configure the VLAN an the hypervisors trunk ports and our customers can use this PG instantly after this configuration.
A PG rename will be automaticlly scheduled afterswards, cause it isn’t time critical.
Heres my code sniplet for inital provisioning of 2000 portgroups in the DVS and QoS limitation of 5 gbit/s with 8 gbit/s peak:
Add-PSSnapin VMware.VimAutomation.Core Add-pssnapin vmware.vimautomation.vds $vcenter = "vcenter01.example.com" Connect-VIServer $vcenter -user user1 -Password password $dvs = Get-VDSwitch -Name "dvs01" -Server $vcenter for ($i=1; $i -le 9; $i++) { New-VDportgroup -VDSwitch $dvs -Name VLAN_000$i -vlanid $i $dvPg = Get-VDPortgroup -VDSwitch $dvs -name VLAN_000$i $dvPG | Get-VDTrafficShapingPolicy -Direction In | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 $dvPG | Get-VDTrafficShapingPolicy -Direction Out | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 } for ($i=10; $i -le 99; $i++) { New-VDportgroup -VDSwitch $dvs -Name VLAN_00$i -vlanid $i $dvPg = Get-VDPortgroup -VDSwitch $dvs -name VLAN_00$i $dvPG | Get-VDTrafficShapingPolicy -Direction In | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 $dvPG | Get-VDTrafficShapingPolicy -Direction Out | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 } for ($i=100; $i -le 999; $i++) { New-VDportgroup -VDSwitch $dvs -Name VLAN_0$i -vlanid $i $dvPg = Get-VDPortgroup -VDSwitch $dvs -name VLAN_0$i $dvPG | Get-VDTrafficShapingPolicy -Direction In | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 $dvPG | Get-VDTrafficShapingPolicy -Direction Out | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 } for ($i=1000; $i -le 1999; $i++) { New-VDportgroup -VDSwitch $dvs -Name VLAN_$i -vlanid $i $dvPg = Get-VDPortgroup -VDSwitch $dvs -name VLAN_$i $dvPG | Get-VDTrafficShapingPolicy -Direction In | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 $dvPG | Get-VDTrafficShapingPolicy -Direction Out | Set-VDTrafficShapingPolicy -Enabled $true -AverageBandwidth 5000000000 -PeakBandwidth 8000000000 }
Maybe someone is interested in this sniplet 😉