Small fix to script that stop/starts system vms: added -m option (the host we send stop* api requests to); defaulted to localhost if not specified.

This commit is contained in:
alena 2011-05-12 09:51:14 -07:00
parent d456f89095
commit eed58597f2

View File

@ -5,7 +5,7 @@
#set -x
usage() {
printf "\nThe tool stopping/starting running system vms and domain routers \n\nUsage: %s: [-d] [-u] [-p] [-s] [-r] [-a] \n\n -d - cloud DB server ip address, defaulted to localhost if not specified \n -u - user name to access cloud DB, defaulted to "root" if not specified \n -p - cloud DB user password, defaulted to no password if not specified \n\n -s - stop then start all running SSVMs and Console Proxies \n -r - stop then start all running Virtual Routers\n -a - stop then start all running SSVMs, Console Proxies, and Virtual Routers\n\n" $(basename $0) >&2
printf "\nThe tool stopping/starting running system vms and domain routers \n\nUsage: %s: [-d] [-u] [-p] [-m] [-s] [-r] [-a] \n\n -d - cloud DB server ip address, defaulted to localhost if not specified \n -u - user name to access cloud DB, defaulted to "root" if not specified \n -p - cloud DB user password, defaulted to no password if not specified \n\n -m - the ip address of management server, defaulted to localhost if not specified\n\n -s - stop then start all running SSVMs and Console Proxies \n -r - stop then start all running Virtual Routers\n -a - stop then start all running SSVMs, Console Proxies, and Virtual Routers\n\n" $(basename $0) >&2
}
@ -13,11 +13,13 @@ system=
router=
all=
db=localhost
ms=localhost
user=root
password=
help=
while getopts 'sard:u:p:' OPTION
while getopts 'sarhd:m:u:p:' OPTION
do
case $OPTION in
s) system=1
@ -32,6 +34,10 @@ do
;;
p) password="$OPTARG"
;;
h) help=1
;;
m) ms="$OPTARG"
;;
?) usage
esac
done
@ -114,7 +120,7 @@ stop_start_router
}
send_request(){
jobid=`curl -sS "http://localhost:8096/?command=$1&id=$2&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
jobid=`curl -sS "http://$ms:8096/?command=$1&id=$2&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
if [ "$jobid" == "" ]; then
echo 2
return
@ -126,7 +132,7 @@ echo $jobresult
query_async_job_result() {
while [ 1 ]
do
jobstatus=`curl -sS "http://localhost:8096/?command=queryAsyncJobResult&jobId=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F, {'print $2'} | awk -F: {'print $2'}`
jobstatus=`curl -sS "http://$ms:8096/?command=queryAsyncJobResult&jobId=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F, {'print $2'} | awk -F: {'print $2'}`
if [ "$jobstatus" != "0" ]; then
echo $jobstatus
break
@ -135,12 +141,17 @@ sleep 5
done
}
if [ "$system$router$all" == "" ]
if [ "$system$router$all$help" == "" ]
then
usage
exit
fi
if [ "$help" == "1" ]
then
usage
exit
fi
if [ "$all" == "1" ]
then