Skip to content

Commit 542e8a2

Browse files
committed
fix
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 9d7b3de commit 542e8a2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

setup/bindir/cloud-sysvmadm.in

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
usage() {
2424
usage_content="
25-
The tool for stopping/starting running system vms and domain routers
25+
The tool for stopping/starting running system vms and domain routers. It requires integration API port to be enabled.
2626
2727
Usage: %s: [-d] [-u] [-p] [-m] [-s] [-r] [-a] [-n] [-t] [-l] [-z] [-v] [-i] [-j]
2828
@@ -61,6 +61,7 @@ vmids=""
6161
vmidsclause=""
6262
withids=""
6363
vmtable="vm_instance"
64+
integrationport=0
6465

6566

6667

@@ -102,6 +103,12 @@ do
102103
done
103104

104105

106+
integrationport=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "SELECT value FROM configuration WHERE name='integration.api.port'"`)
107+
if [ $integrationport -le 0 ]; then
108+
echo "Integration port is not enabled!"
109+
exit
110+
fi
111+
105112
prepare_ids_clause() {
106113
if [[ ! -z "$vmidsclause" ]]; then
107114
return
@@ -243,7 +250,7 @@ stop_start_all() {
243250
}
244251

245252
send_request(){
246-
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'}`
253+
jobid=`curl -sS "http://$ms:$integrationport/?command=$1&id=$2&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
247254
if [ "$jobid" == "" ]; then
248255
echo 2
249256
return
@@ -259,7 +266,7 @@ send_request(){
259266

260267
reboot_router(){
261268
echo "[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Restarting router with id $1" >>$LOGFILE
262-
jobid=`curl -sS "http://$ms:8096/?command=rebootRouter&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
269+
jobid=`curl -sS "http://$ms:$integrationport/?command=rebootRouter&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
263270
if [ "$jobid" == "" ]; then
264271
echo "[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart domainRouter with id $1; unable to submit the job" >>$LOGFILE
265272
echo 2
@@ -343,7 +350,7 @@ restart_networks(){
343350
}
344351

345352
restart_network(){
346-
jobid=`curl -sS "http://$ms:8096/?command=restartNetwork&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
353+
jobid=`curl -sS "http://$ms:$integrationport/?command=restartNetwork&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
347354
if [ "$jobid" == "" ]; then
348355
echo "[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart network with id $1; unable to submit the job" >>$LOGFILE
349356
echo 2
@@ -364,7 +371,7 @@ restart_network(){
364371
restart_vpc(){
365372
echo -e "INFO: Restarting vpc with id $1"
366373
echo "[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Restarting vpc with id $1" >>$LOGFILE
367-
jobid=`curl -sS "http://$ms:8096/?command=restartVPC&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
374+
jobid=`curl -sS "http://$ms:$integrationport/?command=restartVPC&id=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F: {'print $3'}`
368375
if [ "$jobid" == "" ]; then
369376
echo "[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart vpc with id $1; unable to submit the job" >>$LOGFILE
370377
echo 2
@@ -449,7 +456,7 @@ restart_vpcs(){
449456
query_async_job_result() {
450457
while [ 1 ]
451458
do
452-
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 $4'} | awk -F: {'print $2'}`
459+
jobstatus=`curl -sS "http://$ms:$integrationport/?command=queryAsyncJobResult&jobId=$1&response=json" | sed 's/\"//g' | sed 's/ //g' | sed 's/{//g' | sed 's/}//g' | awk -F, {'print $4'} | awk -F: {'print $2'}`
453460
if [ "$jobstatus" != "0" ]; then
454461
echo $jobstatus
455462
break

0 commit comments

Comments
 (0)