I've been investigating this command... to create VM Kernel switches from the COS....
It works pretty well - but one thing I've noticed is that there doesn't seem to be switch for enabling VMotion on the switch... or setting the default gateway value - which the VI client does prompt you do...
Does any one know of way of setting these parameters from the COS?
Regards
Mike
I don't believe so, if they have please lets us know!
After a bit of playing around I have this working pretty well. I couldn't get the sed command to do what I wanted so ran an alternative:
cat >> /etc/vmware/hostd/hostsvc.xml
EOF
esxcfg-advcfg -s 1 /Migrate/Enabled
I've run this up in a clean scripted build situation and with a dirty one and both work fine and consistently with vmotion being configured and enabled upon connecting with a VC server. With the clean build it's part of a few other post deploy scripts and is then rebooted so you don't run the 'kill' command. You have to be a little more careful testing with an existing build as the order you do thing's matters more.
Hope you guys find it works well for you.
Cheers
Gavin
Ok, so I got this to work (I think). I will test some more -- I just want to get this down somewhere in case I get hit by a bus.
This doesn't require you to know the portgroup name, but it assumes you named your VMotion switch "VMotion" if you named it in lower case or something; modify the below script.
\# --- here is the vmotioncfg.sh script that you are calling
portvar=$(esxcfg-vswitch -l | awk '/VMotion/ \{print $2}')
cat > /etc/vmware/hostd/hostsvc.xml
EOF
esxcfg-advcfg -s 1 /Migrate/Enabled[/b]
\# \------- End of script
So. Where do you put it? I have the script on the NFS server where I keep my ESX patches and it is copied over to the ESX server with the patches during the build.
So, how do you call it? Inside the PostInstall script (In the script after you create the switches/vlans).
It should look something like:
/usr/sbin/esxcfg-vmknic -a VMotion -i 10.6.1.1 -n 255.255.128.0
/usr/sbin/esxcfg-route 10.6.127.254
chmod 755 /somepath/vmotioncfg.sh
/somepath/vmotioncfg.sh[/b]
More later.
Chris
Sweet! This thread kind of died out after some folks could not get things to work. This procedure is still working for me in my automated installs. Is anybody else having success/trouble using this?
Thanks Chris for the added automation!
Hiya,
I've successfully used this method to enable vmotion in my build script.
(I like the way of getting the portgroup number Chris)
I had hoped to be able to use the following command:
vimsh -n -e "/hostsvc/vmotion/vnic_set portgroupn"
(where n is the relevant portgroup number)
This command worked perfectly for me from the command line - but failed to work when run in rc.local.
I've no idea why - has anyone any ideas - as it is a neat way of doing it.
I next need to look at getting my vSwitch security and nic teaming settings into my scripted install.
I had hoped to use vimsh for this - but if that too fails at build time - does anyone have any suggestions for other scripting methods to set these properties?
I suspect I could write directly to the esx.conf - but I was trying to avoid that method if at all possible?
Dinny
Hiya,
I found out what the problem with vimsh was:
Thanks to GavinJ - http://www.xtravirt.com/index.php?option=com_content&task=view&id=59&Itemid=67
If once I've set up my vSwitches and Portgroups, I do a:
sleep 15[/i]
and then my vimsh command
vimsh -n -e "/hostsvc/vmotion/vnic_set portgroupn"[/i]
It works fine.
Dinny
Hi,
I have one minor issue with both of the otions offered and that is that while they work, they overwrite whatever was pre-existing in the hostsvc.xml file i.e. the NTPD service is no longer present after these options are used.
Cheers
Steve
Hi Steve,
If you're using a build script?
What if you add the NTPD stuff after configuring vmotion - or does that stop vmotion being enabled?
Dinny
Hi,
After a bit of effort I came up with the following. This basically strips off the
EOF
#Set advanced setting migrate/enabled to 1
esxcfg-advcfg -s 1 /Migrate/Enabled
}
The arguments for vimsh -n -e "/hostsvc/vmotion/vnic_set" has changed in ESX 3.5 so you can't use the internal portgroup id anymore.
4.5 Enable VMotion
Enable a VirtualNic to be used as the VMotion NIC. This can be useful when undertaking automated ESX builds. Thanks to Mike Laverick () for picking up the change between 3.0 and 3.5 for this.
USAGE vimsh -n -e "hostsvc/vmotion/vnic_set "
EXAMPLE vimsh -n -e "hostsvc/vmotion/vnic_set vmk0"
Use following to get the vmkernel nic and enable vmotion
vmk_nic=$(esxcfg-vmknic -l | awk /VMotion/'{print $1}')
vimsh -n -e "hostsvc/vmotion/vnic_set $vmk_nic"