Hello - could someone tell me what I'm not doing?? I enter the following command in the command line and it works fine to enable vmotion, however, it isn't working in my script where everything else does:
%post
cat >/tmp/ESXpostconfig.sh <<EOF
#!/bin/bash
#esxcfg-vswitch -L vmnic1 vSwitch0
add prod switch vSwitch1 and vSwitch2 and configure uplinks adding additional uplink to service console
esxcfg-vswitch -L vmnic2 vSwitch0
esxcfg-vswitch -a vSwitch1
esxcfg-vswitch -L vmnic1 vSwitch1
esxcfg-vswitch -L vmnic3 vSwitch1
esxcfg-vswitch -a vSwitch2
esxcfg-vswitch -L vmnic4 vSwitch2
esxcfg-vswitch -L vmnic5 vSwitch2
add port groups and vlans to vSwitch1 and vSwitch2
esxcfg-vswitch -A linux_network vSwitch1
esxcfg-vswitch -v 401 -p linux_network vSwitch1
esxcfg-vswitch -A windows_network vSwitch2
esxcfg-vswitch -v 402 -p windows_network vSwitch2
#Configure NTP
echo " Configuring NTP"
echo "restrict kod nomodify notrap noquery nopeer" > /etc/ntp.conf
echo "restrict 127.0.0.1" >> /etc/ntp.conf
echo "server ntp.brown.edu" >> /etc/ntp.conf
echo "server ntp2.brown.edu" >> /etc/ntp.conf
echo "driftfile /var/lib/ntp/drift" >> /etc/ntp.conf
echo "server ntp.brown.edu" > /etc/ntp/step-tickers
echo "server ntp2.brown.edu" > /etc/ntp/step-tickers
additional config steps for NTP
esxcfg-firewall --e ntpClient
chkconfig --level 345 ntpd on
/sbin/hwclock --systohc --utc
service ntpd restart
configure authentication with AD
esxcfg-auth --enablead --addomain=ad.brown.edu --addc=sorry can't post this info
service mgmt-vmware restart
add users
sorry, can't post this
#enable root login
perl -p -i.old -e "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config
service sshd restart
#Unload the VMFS-2 module
vmkload_mod -u vmfs2
add vmotion kernel port to vSwitch0, configure VMkernel IP, add uplink for redundancy
#esxcfg-vswitch -A Vmotion vSwitch0
#esxcfg-vmknic -a -i 128.148.176.228 -n 255.255.255.0 Vmotion
#esxcfg-vswitch -L vmnic1 vSwitch0
#esxcfg-route 128.148.176.1
enable Vmotion
vimsh -n -e "/hostsvc/vmotion/vnic_set vmk0"
EOF
HELP!
I use a slightly different ks file taken from the ESX Deployment Appliance (EDA):
service mgmt-vmware restart
echo Waiting for hostd to accept connections...
sleep 180
while ; do
sleep 5
echo Waiting for hostd to accept connections...
done
echo "Configuring VMotion"
vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0
vmware-vim-cmd internalsvc/refresh_network
I generally find I have to restart the network and the mgmt-vmware service to commit the changes before it works correctly and even after doing this, I tell the script to sleep for a few minutes to ensure that it has fully started etc...
Here is an overview of one of my ks files in relation to vmotion for you to compare...
Add vSwitches
/usr/sbin/esxcfg-vswitch -a vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch1
Add and Configure vmkernel ports
/usr/sbin/esxcfg-vswitch -A "VMotion" vSwitch1
/usr/sbin/esxcfg-vmknic -a "VMotion" -i 192.168.20.101 -n 255.255.255.0
Set the VMkernel default gateway
/usr/sbin/esxcfg-route 10.160.224.62
Restart the network and management services so the changes are committed
service network restart
echo Sleeping for 2 minutes.....please wait
sleep 120
service mgmt-vmware restart
Now pause for 5 minutes to ensure the management service has fully restarted - otherwise vimsh won't work
echo Sleeping for 5 minutes.....please wait
sleep 300
Enable VMotion
vimsh -n -e "/hostsvc/vmotion/vnic_set vmk0"
Put the host into maintenance mode
vimsh -n -e " /hostsvc/maintenance_mode_enter"
End the Post Install file and make it executable
EOF
Hope that helps
I use a slightly different ks file taken from the ESX Deployment Appliance (EDA):
service mgmt-vmware restart
echo Waiting for hostd to accept connections...
sleep 180
while ; do
sleep 5
echo Waiting for hostd to accept connections...
done
echo "Configuring VMotion"
vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0
vmware-vim-cmd internalsvc/refresh_network
Mikey - thank you - your script didn't point me to how to refresh the network, in your example you put the host into maintenance mode after you enabled vmotion. What does this accomplish other than preparing the server for shutdown \ reboot or some other task that requires maintenance mode? What would the vimsh command be to accomplish this? or would you use vmware-vim-cmd internalsvc/refresh_network?
gman
who needs stinking vimsh right? Thanks for your post, up until now I was under the impression the only way to get vmotion enabled was with vimsh. Well done.
gman
The network is refreshed in my script as part of the "service network restart" command...!
The Maintenance mode entry is purely the end of my script, nothing to do with vmotion
indeed it is, over looked that because I was focusing on the vmotion portion, very nice. Another helpful answer is all I can award based on this system since I already awarded a correct answer, my apologies, thanks again!
