Changeset 211


Ignore:
Timestamp:
Oct 15, 2010, 11:01:59 AM (14 years ago)
Author:
rock
Message:

Rename & Modify: execute command to client

File:
1 moved

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/drbl_client_cmd

    r204 r211  
    2424echo "Usage: drbl_xen_cmd.sh options"
    2525echo "Options:"
    26 echo "-h|--host           which host"
    27 echo "-v|--vm             vm name"
    28 echo "-x|--xen_command    xen command"
     26echo "-c|--client         client name"
     27echo "-x|--execute        execute command"
    2928echo "Example:"
    30 echo "drbl_xen_cmd.sh -h drbl101 -v drbl131 -x 'shutdown'"
     29echo "drbl_xen_cmd.sh -c drbl101 -x 'shutdown'"
    3130}
    3231
     
    4140while [ $# -gt 0 ]; do
    4241    case "$1" in
    43         -h|--host)
     42        -c|--client)
    4443            shift
    4544            if [ -z "$(echo $1 |grep ^-.)" ]; then
     
    5352            fi
    5453            ;;
    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)
    6855            shift
    6956            if [ -z "$(echo $1 |grep ^-.)" ]; then
    7057                if [ -n "$(echo $1)" ]; then
    71                 xen_command="$1"
     58                command="$1"
    7259                else
    73                     echo "-x xen command is null"
     60                    echo "-x command is null"
    7461                    Usage && exit 2
    7562                fi 
     
    9279# = 2. Check null value =
    9380[ -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
    9682
    9783
    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
     85grep $client_name $Work_Home/etc/IP_HOST_TABLE >> /dev/null
    11986if [ $? -ne 0 ]; then
    12087    echo "[Error] This host is not DRBL client"
     
    12289fi
    12390
     91echo "[$client_name]"
    12492
    12593# = 4. ssh host to deploy VM  =
     
    12896
    12997# start ssh
    130 ssh -o StrictHostKeyChecking=no $host_IP "$xen_command"
     98ssh -o StrictHostKeyChecking=no $host_IP "$command"
    13199
Note: See TracChangeset for help on using the changeset viewer.