While esxcfg-vswitch and esxcfg-vmnic can be used to create vSwitch with VMKernel port groups, what they are unable to do is set the attribute of “VMotion” on a portgroup, which enables the VMotion feature. However, fortunately a separate command-line tool called vimsh can. To use vimsh you must find out what the portgroup's “Internal ID” is. Each portgroup that gets created is given a name of portgroup 0 and portgroup1. You can find out the portgroup internal ID with the command
You can then enable the VMotion attribute with the command:
esxcfg-vswitch -a vSwitch3
esxcfg-vswitch -A VMotion vSwitch3
esxcfg-vswitch -L vmnic3 vSwitch3
esxcfg-vmknic -a VMotion -i 10.0.0.3 -n 255.255.255.0
service mgmt-vmware restart
vimsh -n -e “/hostsvc/vmotion/vnic_set portgroupN”
-n tells vimsh to use non-interactive mode which is suitable for scripting purposes. -e instructs vimsh to execute a command form the prompt. If you wish to learn more about vimsh, xtravirt.com now has two whitepapers about the utility which has no man page and little command-line help from VMware. One is about general usage and the other is about using the tools to do advanced network configuration.
I would like to thank JÃ¶rg Lew for putting me on to this tip!
The guys at xtravirt.com and myself were discussing the use of vimsh – I raised the issue of using vimish to advanced network configuration like load-balancing, failover orders, and so on. They/we discovered that for vimish to work affectively you need both the capabilities to restart the VMware Management Service and sleep – before executing the vimish command in a script. Thanks to the xtravirt.com guys for figuring this one out…