#/bin/sh #this script for Faster cloune on xenserver 7 #send vm-create.sh to xenserver use ftp or ssh first ./vm-create.sh #version: 0.03 #date: 2016-12-29 #yelang007sheng@163.com #select template s_template(){ templates=`xe template-list live=true |grep name-label |awk -F: '{print $2}' |sed s'/ //'` #xenserver6.5 live=false templates=`echo $templates` for((;;)) do read -p "Template[ $templates ]: " template xe template-list live=true |grep "<$template>" flag=$? if [ $flag -ne 0 ];then echo "Input Error" continue else break fi done } # select clone type s_clone_type(){ for((;;)) do read -p "Clone [1=Full Clone; 2=Faster Clone]: " clone if [ $clone -eq 1 ]; then break elif [ $clone -eq 2 ];then break else echo "Input Error: Please input 1 or 2" continue fi done } #start ..... #2. input vm name: read -p "VM Name: " name #3. input vm number: for((;;)) do read -p "VM Count: " count if [ $count -gt 0 ] 2>/dev/null; then break else echo "Input Error,Please input a number!" continue fi done #4. select template s_template #5. select clone type s_clone_type #6. install vm for((i=1;i<=$count;i++)) do if [ $clone -eq 1 ];then xe vm-install template=$template sr-name-label="Local storage" new-name-label="$name$i" sleep 1 else xe vm-install template=$template new-name-label="$name$i" sleep 1 fi done