Moving Virtual Machine to Distributed Virtual Switch

The distributed virtual switch introduced in vSphere 4 has many benefits over the traditional switch. For one thing, you no longer have possible glitches with live migrating virtual machines from one host to another using traditional switches, and all your port settings go with your virtual machines.

If you have virtual machines using traditional switches, you can easily move them to new distributed virtual switches. The rest of this article explains how to achieve this.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

You can use the reconfigVM_Task method defined in vSphere API (in VI Java API, it’s defined on VirtualMachine class). The tricky part is always the parameter because there are tons of possibilities with the parameter type VirtualMachineConfigSpec.

To find out how to populate the parameter, you can try the Onyx. Here are the SOAP request I recorded while changing a VM to DVS. With this XML, you can be sure about two things by studing the content within the spec tag: what parameters and what values should be there. Note that the tag names in the XML map to the same property names in data objects of parameters. I should add that you don’t have to match 100% what vSphere Client sends to the vCenter, but it’s definitely a good starting point from where you can reduce some of the sub data objects or sub properties.

<soap:Envelope xmlns:xsd=”” xmlns:xsi=”” xmlns:soap=””>
    <ReconfigVM_Task xmlns=”urn:internalvim25″>
      <_this xsi:type=”ManagedObjectReference” type=”VirtualMachine” serverGuid=”BA9CE658-75F7-4A99-ACE6-99EB1376B94A”>vm-134</_this>
          <device xsi:type=”VirtualE1000″>
              <label>Network adapter 1</label>
              <summary>VM Network</summary>
            <backing xsi:type=”VirtualEthernetCardDistributedVirtualPortBackingInfo”>
                <switchUuid>49 cd 3f 50 a8 dd ce 80-03 0d 01 06 6b 91 e4 34</switchUuid>

This entry was posted in vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. pranav
    Posted August 3, 2011 at 10:28 am | Permalink

    I am not sure whether this is right place holder for this question :

    Actually I am facing one problem when I am modifying VirtualDeviceConfigSpec i.e. removing all the nics first and adding it back again and modifying dv port group then for that dv port group after power on device status shows as not connected somehow.

    I am doing following in add part of getNICDeviceConfigSpec() , but still not able to get it connected, do I need to do some more things

    VirtualDeviceConnectInfo vdci = new VirtualDeviceConnectInfo();

    System.out.println(“setting start connected as true “);
    System.out.println( nic.getMacAddress() );

  2. Stephen McKay
    Posted April 25, 2016 at 6:27 pm | Permalink

    Steve – your popup banner add for the ‘”Super vCenter” with True HTML5 Client’ is truly super annoying. There has to be a better way.

One Trackback

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.