Create and Configure a Standard Virtual Switch using PowerCli & EsxCli

Using PowerCli:

ensure that no vSS named vSwitch1 already exists.
Get-VirtualSwitch -VMHost 10.26.0.221
Named vSwitch1-having 256 ports with support for jumbo frames
new-virtualswitch -vmhost 10.26.0.221 -name vss01 -NumPorts 256
Attach vmnic1 and vmnic2 as uplinks.
Get-VirtualSwitch -VMHost 10.26.0.221 -Name vss01 | Set-VirtualSwitch -Nic vmnic2
( MTU =8500 ).
Get-VirtualSwitch -VMHost 10.26.0.221 -Name vss01 | Set-VirtualSwitch -Mtu 8500
Create a port group named Tests
Get-VirtualSwitch -VMHost 10.26.0.221 -Name vss01 | New-VirtualPortGroup Tests
Set its VLAN property to 101 ,
Get-VirtualSwitch -VMHost 10.26.0.221 -Name vss01 | New-VirtualPortGroup Tests |Set-VirtualPortGroup -VLanId 101
and set its NIC Teaming to iphash .
Get-VirtualSwitch -VMHost 10.26.0.221 -Name vss01 | Get-NicTeamingPolicy | set-NicTeamingPolicy -LoadBalancingPolicy LoadBalanceIP
Enable trafic shaping -average and peak bandwidth 100Mbps.
there is no corresponding powercli for standard switch , you have to work in depth with vmware HostNetworkPolicy data-object
$esx = “10.26.0.221”
$vs1 = “vss01”
$vmhost = Get-VMHost $esx
$hostview = $vmhost | Get-View
$ns = Get-View -Id $hostview.ConfigManager.NetworkSystem
$vsConfig = $hostview.Config.Network.Vswitch | Where-Object { $_.Name -eq $vs1 }
$vsSpec = $vsConfig.Spec
$vsSpec.Policy.ShapingPolicy.AverageBandwidth = 100 * 1MB
$vsSpec.Policy.ShapingPolicy.BurstSize = 512 * 1MB
$vsSpec.Policy.ShapingPolicy.PeakBandwidth = 100 * 1MB
$vsspec.Policy.ShapingPolicy = New-Object VMWare.Vim.HostNetworkTrafficShapingPolicy
$vsSpec.Policy.shapingPolicy.enabled = $true
$netSys.UpdateVirtualSwitch( $vs1, $vsSpec)
image0013

image0013

Using ESXLI:

ensure that no vSS named vSwitch1 already exists.
Named vSwitch1-having 256 ports with support for jumbo frames
Attach vmnic1 and vmnic2 as uplinks.
( MTU =8500 ).
Create a port group named Tests
Set its VLAN property to 101 ,
and set its NIC Teaming to iphash .
Enable trafic shaping -average and peak bandwidth 100Mbps.
esxcli network vswitch standard list
esxcli network vswitch standard add -P 128 -v vSwitch1
esxcli network vswitch standard uplink add –u vmnic1 -v vSwitch1
esxcli network vswitch standard uplink add –u vmnic2 -v vSwitch1
esxcli network vswitch standard set –m 8500 –v vSwitch1
esxcli network vswitch standard portgroup add -p Test -v vSwitch1
esxcli network vswitch standard portgroup set -p Test -v 101
esxcli network vswitch standard portgroup policy failover set -p Test -l iphash
esxcli network vswitch standard port group policy shaping set -p Test -e true -k 100000 –b 100000 –t 100000

Also localcli could be used same way

localcli network vswitch standard list
localcli network vswitch standard add -P 128 -v vSwitch1
localcli network vswitch standard uplink add –u vmnic1 -v vSwitch1
localcli network vswitch standard uplink add –u vmnic2 -v vSwitch1
localcli network vswitch standard set –m 8500 –v vSwitch1
localcli network vswitch standard portgroup add -p Test -v vSwitch1
localcli network vswitch standard portgroup set -p Test -v 101
localcli network vswitch standard portgroup policy failover set -p Test -l iphash
localcli network vswitch standard port group policy shaping set -p Test -e true -k 100000 –b 100000 –t 100000

Advertisements

About Ahmad Sabry ElGendi

https://www.linkedin.com/pub/ahmad-elgendi/94/223/559
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s