Migrating distributed vSwitch to new vCenter

Customer called me to ask how they could easily migrate their existing vCenter to a new vCenter including all distributed vSwitches. They were moving from vCenter 4.0 to vCenter 4.1 and at the same time creating an AD intergrated vCenter and moving from physical to a virtual vCenter. The upgrade path would be a difficult road and they decided to just perform a fresh vCenter install. Since a dvSwitch is linked to vCenter and not the ESX host, you cannot move the dvSwitch to a new vCenter by connecting the ESX host to the new vCenter. We had to use a different path.

Biggest issue in this was the recreating of all the distributed virtual portgroups in the new vCenter, since they have over 400 different VLANs it would be a lot of manual work and of course error prone. Another issue was that the whole migration should take place without downtime for the VMs.

The migration path I suggested is found below. I searched for some PowerShell scripts to help automate this migration and found some great scripts from (of course) Luc Dekens (click for scripts) and Glenn Sizemore ( click for blog) that served as the basics for my migration scripts. The migration will be performed in a few steps. I haven’t automated all the steps and I created a number of small scripts instead of one big script to keep more control on the whole process.

Migration preparation

For this migration to work, you will need a ESX host with multiple vmnics. Since we’re going to move VMs from dvSwitch to vSwitch on the same host and can’t afford to lose network connectivity during these steps, it is important that you have a vmnic available for your existing dvSwitch and the new vSwitch. If your host has only a few vmnics, you might consider running on just one vmnic per (d)vSwitch during this migration. If your using Ethernet Channels, be sure to check with your network admins what the consequences are!!!

In this first version of my scripts, I only migrate the VLAN ID of the dvPortGroups. I’m working on a newer version that will migrate more dvPortGroups attributes like loadbalancing and security settings.

A global overview of the migration

Create a standard vSwitch and portgroups with VLAN-IDs on the ESX host

Change the portgroup of the VMs from dvPortGroup to the new temporary PortGroups

Create the new dvSwitch plus dvPortGroups on the new vCenter

Remove the dvSwitch from the ESX host

Move the ESX host to the new vCenter

Add the ESX host to the new dvSwitch

Change the portgroup of the VMs from temporary PortGroup to the new dvPortGroups

Perform Migration

Step01-Get-distributedswitch: This script reads the dvSwitches and dvPortGroups. Then the standard vSwitch will be created with the normal PortGroups and a CSV will be created holding a list of the PortGroups and their VLAN ID.

Manual intervention: add one or more vmnics to the vswitch

Step02-Move-VM-to-vSwitch: VMs will be migrated from the dvPortGroups to the temporary standard PortGroups

Step03-create-dvswitch-dvportgroup: On the new vCenter the new dvSwitch and dvPortGroups will be created.

Manual intervention: Remove the old dvSwitch from the ESX host

Manual intervention: Move the ESX host to the new vCenter

Manual intervention: Add the ESX host to the new dvSwitch

Step04-Move-VM-to-dvSwitch : VMs will be migrated from the temporary PortGroups to the dvPortGroups

In the near future I will post some updates to these scripts and try to automate even more steps to make this a complete migration wizard. Feel free to comment with new ideas or issues you are running into. The powershell scripts below can be downloaded as ZIP: Migrate-dvSwitch-001