forked from Juniper/contrail-provisioning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenstack-status
More file actions
executable file
·236 lines (210 loc) · 7.46 KB
/
Copy pathopenstack-status
File metadata and controls
executable file
·236 lines (210 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/sh
#
# Copyright (C) 2012, Red Hat, Inc.
# Pádraig Brady <pbrady@redhat.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
#set -x
systemctl --version >/dev/null 2>&1 && systemctl=1
[ "$systemctl" ] || RUNLEVEL=$(LANG=C who -r | sed 's/.*run-level \([0-9]\).*/\1/')
for conf in nova/nova.conf keystone/keystone.conf glance/glance-registry.conf; do
if grep -qF 'connection = mysql' /etc/$conf 2>/dev/null; then
mysqld='mysqld'
break;
fi
done
rpm -q openstack-nova-common > /dev/null && nova='nova'
rpm -q openstack-glance > /dev/null && glance='glance'
rpm -q openstack-dashboard > /dev/null && dashboard='httpd'
rpm -q openstack-keystone > /dev/null && keystone='keystone'
rpm -q openstack-quantum > /dev/null && quantum='quantum'
rpm -q openstack-swift > /dev/null && swift='swift'
rpm -q openstack-cinder > /dev/null && cinder='cinder'
rpm -q libvirt > /dev/null && libvirtd='libvirtd'
rpm -q qpid-cpp-server > /dev/null && qpidd='qpidd'
rpm -q rabbitmq-server > /dev/null && rabbitmq='rabbitmq-server'
rpm -q memcached > /dev/null && memcached='memcached'
if test "$qpidd" && test "$rabbitmq"; then
# Give preference to rabbit
# Unless nova is installed and qpid is specifed
if test "$nova" && grep -q '^rpc_backend.*qpid' /etc/nova/nova.conf; then
rabbitmq=''
else
qpidd=''
fi
fi
is_supervisor_managed() {
managed="no"
echo $1 | grep 'keystone' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-api' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-scheduler' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-conductor' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-cert' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-consoleauth' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'nova-novncproxy' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'glance-api' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'glance-registry' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'cinder-api' 2>/dev/null 1> /dev/null && managed='yes'
echo $1 | grep 'cinder-scheduler' 2>/dev/null 1> /dev/null && managed='yes'
echo $managed
}
service_installed() {
supervisor_managed=$(is_supervisor_managed $1)
if [ $supervisor_managed = "yes" ]; then
svc_name=$(echo $1 | sed 's/openstack-//g')
service $svc_name status 2>&1 | grep -v "$svc_name: unrecognized service" 2> /dev/null 1> /dev/null
else
PAGER= systemctl show $1.service >/dev/null 2>&1 ||
chkconfig --list $1 >//dev/null 2>&1
fi
}
service_enabled() {
supervisor_managed=$(is_supervisor_managed $1)
if [ $supervisor_managed = "yes" ]; then
svc_name=$(echo $1 | sed 's/openstack-//g')
service $svc_name status 2>&1 | grep -v "$svc-name: unrecognized service" 2> /dev/null 1> /dev/null
elif [ "$systemctl" ]; then
systemctl --quiet is-enabled $1.service 2>/dev/null
else
chkconfig --levels $RUNLEVEL "$1"
fi
}
if service_enabled openstack-nova-volume 2>/dev/null ||
service_enabled openstack-cinder-volume 2>/dev/null; then
tgtd='tgtd'
fi
lsb_to_string() {
case $1 in
0) echo "active" ;;
1) echo "dead" ;;
2) echo "dead" ;;
3) echo "inactive" ;;
*) echo "unknown" ;;
esac
}
check_sysv_svc() {
supervisor_managed=$(is_supervisor_managed $1)
printf '%-30s' "$1:"
bootstatus=$(service_enabled $1 && echo enabled || echo disabled)
if [ $supervisor_managed = "yes" ]; then
svc_name=$(echo $1 | sed 's/openstack-//g')
status=$(service $svc_name status | grep -s -i running >/dev/null 2>/dev/null; lsb_to_string $?)
else
status=$(service $1 status >/dev/null 2>/dev/null ; lsb_to_string $?)
fi
if [ "$bootstatus" = 'disabled' ]; then
bootstatus=' (disabled on boot)'
else
bootstatus=''
fi
printf '%s\n' "$status$bootstatus"
}
check_svc() {
if [ ! "$systemctl" ]; then
check_sysv_svc "$@"
return
fi
printf '%-30s' "$1:"
bootstatus=$(service_enabled $1 && echo enabled || echo disabled)
status=$(systemctl is-active $1.service 2>/dev/null)
# For "simple" systemd services you get
# "unknown" if you query a non enabled service
if [ "$bootstatus" = 'disabled' ]; then
bootstatus=' (disabled on boot)'
[ $status = 'unknown' ] && status='inactive'
else
bootstatus=''
fi
printf '%s\n' "$status$bootstatus"
}
if test "$nova"; then
printf "== Nova services ==\n"
service_installed openstack-nova-cert && cert=cert
service_installed openstack-nova-conductor && conductor=conductor
for svc in api $cert compute network scheduler volume $conductor; do check_svc "openstack-nova-$svc"; done
fi
if test "$glance"; then
printf "== Glance services ==\n"
for svc in api registry; do check_svc "openstack-glance-$svc"; done
fi
if test "$keystone"; then
printf "== Keystone service ==\n"
for svc in $keystone; do check_svc "openstack-$svc"; done
fi
if test "$dashboard"; then
printf "== Horizon service ==\n"
horizon_status="$(curl -s -w '%{http_code}\n' http://localhost/dashboard -o /dev/null)"
[ "$horizon_status" = 200 ] && horizon_status=active
printf '%-30s%s\n' "openstack-dashboard:" "$horizon_status"
fi
if test "$quantum"; then
printf "== Quantum services ==\n"
# TODO: Update for Folsom which has plugin ini files in a different location
if grep -q '^provider = quantum.plugins.linuxbridge' /etc/quantum/plugins.ini 2>/dev/null; then
quantum_plugin=quantum-linuxbridge-agent
fi
if grep -q '^provider = quantum.plugins.openvswitch' /etc/quantum/plugins.ini 2>/dev/null; then
quantum_plugin=quantum-openvswitch-agent
quantum_support=openvswitch
fi
for svc in quantum-server $quantum_plugin $quantum_support; do check_svc "$svc"; done
fi
if test "$swift"; then
printf "== Swift services ==\n"
check_svc openstack-swift-proxy
for ringtype in account container object; do
check_svc openstack-swift-$ringtype
for service in replicator updater auditor; do
if [ $ringtype != 'account' ] || [ $service != 'updater' ]; then
: # TODO how to check status of:
# swift-init $ringtype-$service
fi
done
done
fi
if test "$cinder"; then
printf "== Cinder services ==\n"
for service in api scheduler volume; do
check_svc openstack-cinder-$service
done
fi
printf "== Support services ==\n"
for svc in $mysqld $dashboard $libvirtd $tgtd $qpidd $rabbitmq $memcached; do
check_svc "$svc"
done
if test "$keystone"; then
printf "== Keystone users ==\n"
if ! test "$OS_USERNAME"; then
echo "Warning keystonerc not sourced" >&2
else
keystonerc=1
keystone user-list
fi
fi
if test "$keystonerc" && test "$glance"; then
printf "== Glance images ==\n"
glance index
fi
if test "$nova"; then
if ! test "$keystonerc" && ! test "$NOVA_USERNAME"; then
test "$keystone" || echo "Warning novarc not sourced" >&2
else
printf "== Nova instance flavors ==\n"
# Check direct access
nova-manage flavor list
printf "== Nova instances ==\n"
# Check access through the API
nova list # instances
fi
fi