Skip to content

Commit 35de50d

Browse files
author
Alena Prokharchyk
committed
cloud-sysvmadm: 1) added -z paramters. If specified, restrict system vm restarts to specific zone. If not specified, the intances will be restarted in all zones. 2) Fixed the help for restartNetwork option. It gets triggered by -n, not -e parameter
1 parent 890603b commit 35de50d

1 file changed

Lines changed: 28 additions & 22 deletions

File tree

setup/bindir/cloud-sysvmadm.in

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#set -x
2424

2525
usage() {
26-
printf "\nThe tool stopping/starting running system vms and domain routers \n\nUsage: %s: [-d] [-u] [-p] [-m] [-s] [-r] [-a] [-t] [-e]\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 -e - restart all Guest networks \n -t - number of parallel threads used for stopping Domain Routers. Default is 10.\n -l - log file location. Default is cloud.log under current directory.\n\n" $(basename $0) >&2
26+
printf "\nThe tool stopping/starting running system vms and domain routers \n\nUsage: %s: [-d] [-u] [-p] [-m] [-s] [-r] [-a] [-t] [-n] [-z]\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 - restart all Guest networks \n -t - number of parallel threads used for stopping Domain Routers. Default is 10.\n -l - log file location. Default is cloud.log under current directory.\n -z - do restart only for the instances in the specific zone. If not specified, restart will apply to instances in all zones\n\n" $(basename $0) >&2
2727
}
2828

2929

@@ -37,9 +37,12 @@ password=
3737
help=
3838
maxthreads=10
3939
LOGFILE=cloud.log
40+
zone=""
41+
inzone=""
4042

4143

42-
while getopts 'sarhnd:m:u:p:t:l:' OPTION
44+
45+
while getopts 'sarhnd:m:u:p:t:l:z:' OPTION
4346
do
4447
case $OPTION in
4548
s) system=1
@@ -63,21 +66,24 @@ do
6366
t) maxthreads="$OPTARG"
6467
;;
6568
l) LOGFILE="$OPTARG"
69+
;;
70+
z) zone=" AND data_center_id=""$OPTARG"
71+
inzone=" in zone id=""$OPTARG"
6672
esac
6773
done
6874

6975

7076

7177

7278
stop_start_system() {
73-
secondary=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vm_instance where state=\"Running\" and type=\"SecondaryStorageVm\""`)
74-
console=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vm_instance where state=\"Running\" and type=\"ConsoleProxy\""`)
79+
secondary=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vm_instance where state=\"Running\" and type=\"SecondaryStorageVm\"$zone"`)
80+
console=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select id from vm_instance where state=\"Running\" and type=\"ConsoleProxy\"$zone"`)
7581
length_secondary=(${#secondary[@]})
7682
length_console=(${#console[@]})
7783

7884

79-
echo -e "\nStopping and starting $length_secondary secondary storage vm(s)..."
80-
echo -e "Stopping and starting $length_secondary secondary storage vm(s)..." >>$LOGFILE
85+
echo -e "\nStopping and starting $length_secondary secondary storage vm(s)$inzone..."
86+
echo -e "Stopping and starting $length_secondary secondary storage vm(s)$inzone..." >>$LOGFILE
8187

8288
for d in "${secondary[@]}"; do
8389
echo "INFO: Stopping secondary storage vm with id $d" >>$LOGFILE
@@ -98,12 +104,12 @@ done
98104
if [ "$length_secondary" == "0" ];then
99105
echo -e "No running secondary storage vms found \n"
100106
else
101-
echo -e "Done stopping and starting secondary storage vm(s)"
102-
echo -e "Done stopping and starting secondary storage vm(s)." >>$LOGFILE
107+
echo -e "Done stopping and starting secondary storage vm(s)$inzone"
108+
echo -e "Done stopping and starting secondary storage vm(s)$inzone." >>$LOGFILE
103109
fi
104110

105-
echo -e "\nStopping and starting $length_console console proxy vm(s)..."
106-
echo -e "Stopping and starting $length_console console proxy vm(s)..." >>$LOGFILE
111+
echo -e "\nStopping and starting $length_console console proxy vm(s)$inzone..."
112+
echo -e "Stopping and starting $length_console console proxy vm(s)$inzone..." >>$LOGFILE
107113

108114
for d in "${console[@]}"; do
109115
echo "INFO: Stopping console proxy with id $d" >>$LOGFILE
@@ -124,17 +130,17 @@ done
124130
if [ "$length_console" == "0" ];then
125131
echo -e "No running console proxy vms found \n"
126132
else
127-
echo "Done stopping and starting console proxy vm(s)."
128-
echo "Done stopping and starting console proxy vm(s)." >>$LOGFILE
133+
echo "Done stopping and starting console proxy vm(s) $inzone."
134+
echo "Done stopping and starting console proxy vm(s) $inzone." >>$LOGFILE
129135
fi
130136
}
131137

132138
stop_start_router() {
133-
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\""`)
139+
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"`)
134140
length_router=(${#router[@]})
135141

136-
echo -e "\nStopping and starting $length_router running routing vm(s)... "
137-
echo -e "Stopping and starting $length_router running routing vm(s)... " >>$LOGFILE
142+
echo -e "\nStopping and starting $length_router running routing vm(s)$inzone... "
143+
echo -e "Stopping and starting $length_router running routing vm(s)$inzone... " >>$LOGFILE
138144

139145
#Spawn reboot router in parallel - run commands in <n> chunks - number of threads is configurable
140146

@@ -185,8 +191,8 @@ stop_start_router() {
185191
sleep 10
186192
done
187193

188-
echo -e "Done restarting router(s). \n"
189-
echo -e "Done restarting router(s). \n" >>$LOGFILE
194+
echo -e "Done restarting router(s)$inzone. \n"
195+
echo -e "Done restarting router(s)$inzone. \n" >>$LOGFILE
190196

191197
fi
192198
}
@@ -231,11 +237,11 @@ reboot_router(){
231237

232238
restart_networks(){
233239
networks=(`mysql -h $db --user=$user --password=$password --skip-column-names -U cloud -e "select n.id
234-
from networks n, network_offerings no where n.network_offering_id = no.id and no.system_only = 0 and n.removed is null"`)
240+
from networks n, network_offerings no where n.network_offering_id = no.id and no.system_only = 0 and n.removed is null$zone"`)
235241
length_networks=(${#networks[@]})
236242

237-
echo -e "\nRestarting networks... "
238-
echo -e "Restarting networks... " >>$LOGFILE
243+
echo -e "\nRestarting $length_networks networks$inzone... "
244+
echo -e "Restarting $length_networks networks$inzone... " >>$LOGFILE
239245

240246
#Spawn restart network in parallel - run commands in <n> chunks - number of threads is configurable
241247

@@ -287,8 +293,8 @@ restart_networks(){
287293
sleep 10
288294
done
289295

290-
echo -e "Done restarting networks. \n"
291-
echo -e "Done restarting networks. \n" >>$LOGFILE
296+
echo -e "Done restarting networks$inzone. \n"
297+
echo -e "Done restarting networks$inzone. \n" >>$LOGFILE
292298

293299
fi
294300
}

0 commit comments

Comments
 (0)