2013年2月5日 星期二

Xenserver 6 free version VM autostart

參考這個討論
http://forums.citrix.com/thread.jspa?threadID=300865

http://www.raido.be/knowledge-center/blog/detail/xenserver-6-auto-start-vms

  1. 先手動把需要Xenserver 開機後自動帶起來的VM,加上 autostart 這個 tag
  2. 然後想辦法在開機後執行下列 shell scrip ,看是要把這段script放到 /etc/rc.local   還是其他開機後會自動執行的 Shellscript 隨意。



# AutoStart VM's that are tagged with autostart tag
# Script created by Raido Consultants - http://www.raido.be

TAG="autostart" # helper function
function xe_param()
{
PARAM=$1
while read DATA; do
LINE=$(echo $DATA | egrep "$PARAM")
if [ $? -eq 0 ]; then
echo "$LINE" | awk 'BEGIN{FS=": "}{print $2}'
fi
done
} # Get all VMs
sleep 20
VMS=$(xe vm-list is-control-domain=false | xe_param uuid) for VM in $VMS; do
echo "Raido AutoStart Script : Checking VM $VM"
VM_TAGS="$(xe vm-param-get uuid=$VM param-name=tags)" if [[ $VM_TAGS == *$TAG* ]]
then
echo "starting VM $VM"
sleep 20
xe vm-start uuid=$VM
fi done




沒有留言: