Working with vDS (Part 1)

In this post, we are going to talk about the automation of vDS. Before a deployment of a virtual infrastructure, who has not considered automating networking deployment? Right, we let’s see the way to automating it.

First, we need to have installed in our PowerCLI the vDS Automation module.  If we open a PowerCLI session, we can see if the module is installed or not. We must run “Get-Module” and we can check the installed modules.

cloudvm_getmodule

If we run “Get-Command -Module VMware.VimAutomation.Vds”, we can see the cmdlets included in this PowerCLI Module.

cloudvm_getcommand

Ok, ¿Which is the first step?

The first step is create a new Distributed Switch. For creating a new vDS, we are going to use the cmdlet “New-VDSwitch”. What options we can customize in our vDS?

$vDSwitch = New-VDSwitch -Name NombreVDS -Location NameDatacenter or NameNetworkFolder -NumUplinkPorts NumberOfUplinks -mtu SizeMTU(Default 1500) -Version VersionOfDistributedSwitch

Example: $vDSSwtich = New-VDSwitch -Name MyFirstVDS -Location (Get-Datacenter).Name -NumUplinkPorts 8 -mtu 1500 -version 6.5.0

cloudvm_createVDS

Also we can create a new distributed switch importing the config of another switch. For example, we have a vDS configured at the first site, but we want create a new vDS with the same configuration. First, we export config of vDS in a zip file. The command would look like this:

$vDSSwtich2 = New-VDSwitch -Name MySeconVDS -Location (Get-Datacenter).Name -BackupPath “C:\MyConfigVDS\backup.zip”.

Right, we have already created our vDS, the next step should be add hosts to our VDS. Then, Let’s Go!!!

For this step, we are going to use the PowerCLI cmdlet “Add-VDSwitchVMHost”. For adding one ESXi to our vDS:

Get-VDSwitch $vDSSwtich | Add-VDSwitchVMHost -VMHost “myesxi.cloudvm.local”

If we want to migrate all ESXi of one cluster. We can run the next commands:

 
# Get List of ESXi included in a Cluster and Get Info of the VDS
$List_ESXi = Get-Cluster -Name "MyCluster" |Get-VMHost
$VDS = Get-VDSwitch -Name "MyFirstVDS"
foreach($ESXi in $List_ESXi)
{
  Write-Host "Add ESXi : $ESXi to VDS : $VDS" 
  Get-VDSwitch $vDSSwtich | Add-VDSwitchVMHost -VMHost $ESXi</em></strong>
}

Ok, we have already created the vDS, also we have added all ESXi in a vDS. Which one could be the next step? We are going to add the Virtual Host Adapter to the dvUplinks. We use the next code for adding the ESXi’s vmnics in order (In next post, I will explain how to assign one vmnic to specific Uplink).  We are going to use the first Uplink to migrate the Management Network from Standard port group to distributed.


# We should introduce this code in the previous "foreach". For each ESXi, we are going to add their vmnics # as Uplinks of our VDS in order.

$UPLINK2 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic1
$UPLINK3 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic2
$UPLINK4 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic3

$UPLINK5 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic0
$UPLINK6 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic1
$UPLINK7 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic2
$UPLINK8 = Get-VMHost $ESXi | Get-VMHostNetworkAdapter -Physical -Name vmnic3
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK2 -Confirm:$false
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK3 -Confirm:$false
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK4 -Confirm:$false
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK5 -Confirm:$false

$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK6 -Confirm:$false
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK7 -Confirm:$false
$VDS | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $UPLINK8 -Confirm:$false

I hope this post has been helpful. In next posts we will advance more in the Automating of Distributed Switches.

Thanks for sharing!!!! 😉

 

 

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *