Normally people want to migrate from virtual standard switches to distributed switches. I am a huge fan of the distributed switch and feel it should be used everywhere. The distributed switch becomes a challenge when you want to migrate hosts to a new vCenter. I have seen a lot of migrations to new vCenters via detaching the ESXi hosts and connecting to the new vCenter. This process works great assuming you are not using the distributed switch. Removing or working with VM’s on a ghosted VDS is a real challenge. So remove it before you migrate to a new vCenter.
In this multi-article solution I’ll provide some steps to migrate off a VDS to a VSS.
- Article 1: Creating a VSS and migrating the virtual machines
- Article 2: Migrating the host off the VDS
- Article 3: Migrating the host to a new vCenter and back into the distributed switch
It’s important to understand that assuming that networking is correct this process should not interrupt customer virtual machines. The movement from a distributed switch to a standard switch at most will lose a ping. When you assign a new network adapter a gratuitous arp is sent out the new adapter. If you only have two network adapters this process does remove network adapter redundancy while moving.
You need to create a standard switch with port groups on the correct VLAN ID’s.
#Import modules for PowerCLI
Connect to vCenter
Get all port groups into $dvsPGs
Get all ESXi hosts
Loop though ESXi hosts one at a time
Create the new standard switch
Loop through port groups and create them with same name as DVS and VLAN ID
This will create a virtual standard switch with the same VLAN and port group configuration as your DVS.
I like to be able to validate that the source and destination are configured the same so this powercli script provides the checking:
#Validation check DVS vs VSS for differences
Get the VDS
Get all ESXi hosts
Loop through VM hosts
Get port groups on standard switch
Loop though the standard switch port groups and look for matches on DVS
If missing then output missing element
Now we need to give the standard switch an uplink (this is critical otherwise VM’s will fail when moved)
Once it has an uplink you can use the following script to move all virtual machines:
#Move Virtual machines to new Adapters
Used same variables from previous script
Get all virtual machines (you could use get-vm “name-of-vm” to test a single vm
Loop through all virtual machines one at a time
Get the VSS for the VM (host specific)
Check for at least one physical uplink to switch (gut / sanity check)
Loop though the adapters on a virtual machine
For each adapter get VDS port group name and switch the adapter
© 2017, Joseph Griffiths. All rights reserved.