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
Copy file name to clipboardExpand all lines: setup/bindir/cloud-sysvmadm.in
+57-18Lines changed: 57 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,26 @@
23
23
#set -x
24
24
25
25
usage() {
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] [-v]\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 -v - do restart all VPCs in the entire system\n\n" $(basename $0) >&2
26
+
usage_content="
27
+
The tool for stopping/starting running system vms and domain routers
-d - cloud DB server ip address, defaulted to localhost if not specified
32
+
-u - user name to access cloud DB, defaulted to \"root\" if not specified
33
+
-p - cloud DB user password, defaulted to no password if not specified
34
+
-m - the ip address of management server, defaulted to localhost if not specified
35
+
-s - stop then start all running SSVMs and Console Proxies
36
+
-r - stop then start all running Virtual Routers
37
+
-a - stop then start all running SSVMs, Console Proxies, and Virtual Routers
38
+
-n - restart all Guest networks
39
+
-t - number of parallel threads used for stopping Domain Routers. Default is 10
40
+
-l - log file location. Default is cloud.log under current directory
41
+
-z - do restart only for the instances in the specific zone. If not specified, restart will apply to instances in all zones
42
+
-v - do restart all VPCs in the entire system
43
+
-i - do restart on instances with specific IDs. Comma-separated instance IDs to be provided. Works only when restarting SSVMs, CPVMs or VRs
44
+
-j - do restart on instances from the specified database table. If not specified, restart will apply on instances present in cloud.vm_instance database table. Works only when restarting SSVMs, CPVMs or VRs\n\n"
45
+
printf"$usage_content""$(basename $0)">&2
27
46
}
28
47
29
48
@@ -40,10 +59,14 @@ maxthreads=10
40
59
LOGFILE=cloud.log
41
60
zone=""
42
61
inzone=""
62
+
vmids=""
63
+
vmidsclause=""
64
+
withids=""
65
+
vmtable="vm_instance"
43
66
44
67
45
68
46
-
whilegetopts'sarhnvd:m:u:p:t:l:z:' OPTION
69
+
whilegetopts'sarhnvd:m:u:p:t:l:z:i:j:' OPTION
47
70
do
48
71
case$OPTIONin
49
72
s) system=1
@@ -72,21 +95,36 @@ do
72
95
;;
73
96
z) zone=" AND data_center_id=""$OPTARG"
74
97
inzone=" in zone id=""$OPTARG"
98
+
;;
99
+
i) vmids="$OPTARG"
100
+
withids=" with id=""$OPTARG"
101
+
;;
102
+
j) vmtable="$OPTARG"
75
103
esac
76
104
done
77
105
78
106
79
-
107
+
prepare_ids_clause() {
108
+
if [[ !-z"$vmidsclause" ]];then
109
+
return
110
+
fi
111
+
vmidsclause=""
112
+
if [[ !-z"$vmids" ]];then
113
+
vmidsclause=" AND uuid IN ('$vmids')"
114
+
vmidsclause=${vmidsclause/,/"','"}
115
+
fi
116
+
}
80
117
81
118
stop_start_system() {
82
-
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"`)
83
-
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"`)
119
+
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"`)
84
122
length_secondary=(${#secondary[@]})
85
123
length_console=(${#console[@]})
86
124
87
125
88
-
echo -e "\nStopping and starting $length_secondary secondary storage vm(s)$inzone..."
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] INFO: Stopping console proxy with id $d">>$LOGFILE
@@ -133,17 +171,18 @@ done
133
171
if [ "$length_console"=="0" ];then
134
172
echo -e "No running console proxy vms found \n"
135
173
else
136
-
echo"Done stopping and starting console proxy vm(s) $inzone."
137
-
echo"[$(date "+%Y.%m.%d-%H.%M.%S")] Done stopping and starting console proxy vm(s) $inzone.">>$LOGFILE
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
138
176
fi
139
177
}
140
178
141
179
stop_start_router() {
142
-
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"`)
180
+
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"`)
143
182
length_router=(${#router[@]})
144
183
145
-
echo -e "\nStopping and starting $length_router running routing vm(s)$inzone... "
0 commit comments