You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
107
112
prepare_ids_clause() {
108
113
if [[ !-z"$vmidsclause" ]];then
109
114
return
@@ -117,168 +122,167 @@ prepare_ids_clause() {
117
122
118
123
stop_start_system() {
119
124
prepare_ids_clause
120
-
secondary=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from $vmtable where state=\"Running\" and type=\"SecondaryStorageVm\"$zone$vmidsclause"`)
121
-
console=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from $vmtable where state=\"Running\" and type=\"ConsoleProxy\"$zone$vmidsclause"`)
122
-
length_secondary=(${#secondary[@]})
123
-
length_console=(${#console[@]})
124
-
125
-
126
-
echo -e "\nStopping and starting $length_secondary secondary storage vm(s)$inzone$withids..."
echo -e "ERROR: Failed to start console proxy vm with id $d \n"
166
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to start console proxy vm with id $d">>$LOGFILE
167
-
fi
179
+
echo"Done stopping and starting console proxy vm(s) $inzone$withids."
180
+
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] Done stopping and starting console proxy vm(s) $inzone$withids.">>$LOGFILE
168
181
fi
169
-
done
170
-
171
-
if [ "$length_console"=="0" ];then
172
-
echo -e "No running console proxy vms found \n"
173
-
else
174
-
echo"Done stopping and starting console proxy vm(s) $inzone$withids."
175
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] Done stopping and starting console proxy vm(s) $inzone$withids.">>$LOGFILE
176
-
fi
177
182
}
178
183
179
184
stop_start_router() {
180
185
prepare_ids_clause
181
-
router=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vm_instance where state=\"Running\" and type=\"DomainRouter\"$zone$vmidsclause"`)
182
-
length_router=(${#router[@]})
186
+
router=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select uuid from vm_instance where state=\"Running\" and type=\"DomainRouter\"$zone$vmidsclause"`)
187
+
length_router=(${#router[@]})
183
188
184
-
echo -e "\nStopping and starting $length_router running routing vm(s)$inzone$withids... "
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'}`
249
-
if [ "$jobid"=="" ];then
250
-
echo 2
251
-
return
252
-
fi
253
-
jobresult=$(query_async_job_result $jobid)
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'}`
254
+
if [ "$jobid"=="" ];then
255
+
echo 2
256
+
return
257
+
fi
258
+
jobresult=$(query_async_job_result $jobid)
254
259
if [ "$jobresult"!="1" ];then
255
260
echo -e "ERROR: Failed to $1 id=$2; jobId is $jobid \n"
256
261
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to $1 id=$2; jobId is $jobid">>$LOGFILE
257
262
fi
258
-
echo$jobresult
263
+
echo$jobresult
259
264
}
260
265
261
266
262
267
reboot_router(){
263
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Restarting router with id $1">>$LOGFILE
264
-
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'}`
265
-
if [ "$jobid"=="" ];then
266
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart domainRouter with id $1; unable to submit the job">>$LOGFILE
267
-
echo 2
268
-
return
269
-
fi
270
-
271
-
jobresult=$(query_async_job_result $jobid)
272
-
273
-
if [ "$jobresult"!="1" ];then
274
-
echo -e "ERROR: Failed to restart domainRouter with id $1 \n"
275
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart domainRouter with id $1; jobId $jobid">>$LOGFILE
276
-
exit 0
277
-
else
278
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Successfully restarted domainRouter with id $1; jobId $jobid">>$LOGFILE
279
-
exit 0
280
-
fi
268
+
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Restarting router with id $1">>$LOGFILE
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'}`
270
+
if [ "$jobid"=="" ];then
271
+
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart domainRouter with id $1; unable to submit the job">>$LOGFILE
272
+
echo 2
273
+
return
274
+
fi
275
+
276
+
jobresult=$(query_async_job_result $jobid)
281
277
278
+
if [ "$jobresult"!="1" ];then
279
+
echo -e "ERROR: Failed to restart domainRouter with id $1 \n"
280
+
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart domainRouter with id $1; jobId $jobid">>$LOGFILE
281
+
exit 0
282
+
else
283
+
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Successfully restarted domainRouter with id $1; jobId $jobid">>$LOGFILE
284
+
exit 0
285
+
fi
282
286
}
283
287
284
288
restart_networks(){
@@ -346,7 +350,7 @@ restart_networks(){
346
350
}
347
351
348
352
restart_network(){
349
-
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'}`
350
354
if [ "$jobid"=="" ];then
351
355
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart network with id $1; unable to submit the job">>$LOGFILE
352
356
echo 2
@@ -367,7 +371,7 @@ restart_network(){
367
371
restart_vpc(){
368
372
echo -e "INFO: Restarting vpc with id $1"
369
373
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Restarting vpc with id $1">>$LOGFILE
370
-
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'}`
371
375
if [ "$jobid"=="" ];then
372
376
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] ERROR: Failed to restart vpc with id $1; unable to submit the job">>$LOGFILE
373
377
echo 2
@@ -387,7 +391,7 @@ restart_vpc(){
387
391
388
392
389
393
restart_vpcs(){
390
-
vpcs=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vpc WHERE removed is null$zone"`)
394
+
vpcs=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select uuid from vpc WHERE removed is null$zone"`)
391
395
length_vpcs=(${#vpcs[@]})
392
396
393
397
echo -e "\nRestarting $length_vpcs vpcs... "
@@ -450,21 +454,21 @@ restart_vpcs(){
450
454
}
451
455
452
456
query_async_job_result() {
453
-
while [ 1 ]
454
-
do
455
-
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'}`
456
-
if [ "$jobstatus"!="0" ];then
457
-
echo$jobstatus
458
-
break
459
-
fi
460
-
sleep 5
461
-
done
457
+
while [ 1 ]
458
+
do
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 $7'} | awk -F: {'print $2'}`
460
+
if [ "$jobstatus"!="0" ];then
461
+
echo$jobstatus
462
+
break
463
+
fi
464
+
sleep 5
465
+
done
462
466
}
463
467
464
468
if [ "$system$router$all$help$redundant$vpc"=="" ]
0 commit comments