Changeset 211 for drbl-virt/sbin/drbl_client_cmd
- Timestamp:
- Oct 15, 2010, 11:01:59 AM (14 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/drbl_client_cmd
r204 r211 24 24 echo "Usage: drbl_xen_cmd.sh options" 25 25 echo "Options:" 26 echo "-h|--host which host" 27 echo "-v|--vm vm name" 28 echo "-x|--xen_command xen command" 26 echo "-c|--client client name" 27 echo "-x|--execute execute command" 29 28 echo "Example:" 30 echo "drbl_xen_cmd.sh - h drbl101 -v drbl131 -x 'shutdown'"29 echo "drbl_xen_cmd.sh -c drbl101 -x 'shutdown'" 31 30 } 32 31 … … 41 40 while [ $# -gt 0 ]; do 42 41 case "$1" in 43 - h|--host)42 -c|--client) 44 43 shift 45 44 if [ -z "$(echo $1 |grep ^-.)" ]; then … … 53 52 fi 54 53 ;; 55 -v|--vm) 56 shift 57 if [ -z "$(echo $1 |grep ^-.)" ]; then 58 if [ -n "$(echo $1)" ]; then 59 vm_name=$1 60 else 61 echo "-v vm_name is null" 62 Usage && exit 2 63 fi 64 shift 65 fi 66 ;; 67 -x|--xen_command) 54 -x|--command) 68 55 shift 69 56 if [ -z "$(echo $1 |grep ^-.)" ]; then 70 57 if [ -n "$(echo $1)" ]; then 71 xen_command="$1"58 command="$1" 72 59 else 73 echo "-x xencommand is null"60 echo "-x command is null" 74 61 Usage && exit 2 75 62 fi … … 92 79 # = 2. Check null value = 93 80 [ -z $client_name ] && echo "[Error] no host" && Usage && exit 2 94 [ -z $vm_name ] && echo "[Error] no VM value" && Usage && exit 2 95 [ -z "$xen_command" ] && echo "[Error] no xen command" && Usage && exit 2 81 [ -z "$command" ] && echo "[Error] no command" && Usage && exit 2 96 82 97 83 98 # = 3. Check exist 99 # VM name 100 IP_VM_files=$(ls $Work_Home/etc/IP_VM_eth[0-9]*) 101 102 for IP_VM_file in $IP_VM_files 103 do 104 IP_VM_ip=$(cat $IP_VM_file | grep "$vm_name" | awk '{print $1}') 105 if [ -n $IP_VM_name ]; then 106 IP_VM_right_file=$IP_VM_file 107 IP_VM_right_ip=$IP_VM_ip 108 fi 109 done 110 111 if [ -z $IP_VM_right_ip ]; then 112 echo "" 113 echo "[Error] this vm name is wrong!" 114 echo "Please check $Wokr_Home/etc/" 115 exit 2 116 fi 117 118 cat $Work_Home/etc/IP_HOST_TABLE | grep $client_name 84 # = 3. Check client exist 85 grep $client_name $Work_Home/etc/IP_HOST_TABLE >> /dev/null 119 86 if [ $? -ne 0 ]; then 120 87 echo "[Error] This host is not DRBL client" … … 122 89 fi 123 90 91 echo "[$client_name]" 124 92 125 93 # = 4. ssh host to deploy VM = … … 128 96 129 97 # start ssh 130 ssh -o StrictHostKeyChecking=no $host_IP "$ xen_command"98 ssh -o StrictHostKeyChecking=no $host_IP "$command" 131 99
Note: See TracChangeset
for help on using the changeset viewer.