add-migrate_vmk_to_dvswitch.pl

Version 3

    This script can:

     

    • migrate a vmkernel from a standard virtual switch to a distributed virtual switch in a host

     

    • add a vmkernel port to a host in a Distributed Virtual Switch using the dvSwitch name and the dvPortGroup name.

    This feauture works through a workaround because it seems that the AddVirtualNic function doesn't work with the "distributedVirtualPort" parameter in the "nic" property. So the script create a dummy internal-only standard vswitch and add the vmkernel to this one. Then it migrate the vmk to the dvs and destroy the dummy virtual switch

     

    • set/unset a vmk as a vmotion, fault tolerance, management vmkernel port

     

    • set the mtu of the vmkernel

     

    • delete the vmkernel

     

     

    Some command line examples:

     

     

     

      1. create a vmkernel port for the host esx.domain in the dvPortGroup mydvport of the dvSwitch mydvs, marking it as a management vmkernel:

    ./add-migrate_vmk_to_dvswitch.pl --server vcenter.domain --username user --password password --hostname esx.domain --add --dvswitch_name mydvs --dvpg mydvport -i 10.10.10.111 -n 255.255.255.0 --vmk_manage

     

      1. migrate the vmkernel vmk1 from the standard port group stdpg to the dvPortGroup mydvport of the dvSwitch mydvs in the host esx.domain. Also unset it as a management vmkernel port

    ./add-migrate_vmk_to_dvswitch.pl --server vcenter.domain --username user --password password --hostname esx.domain --migrate --src_pg stdpg --dvswitch_name mydvs --dvpg mydvport --vmk_device vmk1 --vmk_remove_manage

     

      1. delete the vmkernel vmk1:

    ./add-migrate_vmk_to_dvswitch.pl --server vcenter.domain --username user --password password --hostname esx.domain --delete --vmk_device vmk1