forked from JiYou/openstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglance
More file actions
executable file
·123 lines (107 loc) · 3.51 KB
/
Copy pathglance
File metadata and controls
executable file
·123 lines (107 loc) · 3.51 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
#!/bin/bash
set -e
#---------------------------------------------------
# Set up ENV
#---------------------------------------------------
export OS_USERNAME=""
export OS_AUTH_KEY=""
export OS_AUTH_TENANT=""
export OS_STRATEGY=""
export OS_AUTH_STRATEGY=""
export OS_AUTH_URL=""
export ADMIN_USER=glance
export ADMIN_PASSWORD=keystone_glance_password
export SERVICE_ENDPOINT=http://10.239.82.187:5000/v2.0/
api_logfile=/var/log/nova/glance-api.log
registry_logfile=/var/log/nova/glance-registry.log
GLANCE_DIR=/opt/stack/glance
#---------------------------------------------------
# Check keystone is running?
#---------------------------------------------------
is_api_running=`ps aux | grep glance-api | grep -v grep | wc -l`
is_registry_running=`ps aux | grep glance-registry | grep -v grep | wc -l`
function start_glance()
{
cd $GLANCE_DIR
nohup python ./bin/glance-registry \
--config-file=/etc/glance/glance-registry.conf\
>$registry_logfile 2>&1 &
echo "glance-registry is starting, please wait."
sleep 5
cat $registry_logfile | tail -5
nohup python ./bin/glance-api
--config-file=/etc/glance/glance-api.conf
>$api_logfile 2>&1 &
echo "glance-api is starting, please wait."
sleep 5
cat $api_logfile | tail -5
}
case "$1" in
status)
if [[ $is_api_running -gt 0 ]]; then
echo "glance-api is running"
tail -5 $api_logfile
else
echo "glance-api is not running"
cat $api_logfile | grep -i "error" | tail -5
fi
if [[ $is_registry_running -gt 0 ]]; then
echo "glance-registry is running"
tail -5 $registry_logfile
else
echo "glance-registry is not running"
cat $registry_logfile | grep -i "error" | tail -5
fi
;;
start)
if [[ $is_api_running -gt 0 && $is_registry_running -gt 0 ]]; then
echo "glance is running"
else
nkill glance-api >/dev/null 2>&1 &
nkill glance-registry >/dev/null 2>&1 &
start_glance
fi
;;
restart)
nkill glance-api >/dev/null 2>&1 &
nkill glance-registry >/dev/null 2>&1 &
start_glance
;;
stop)
if [[ $is_api_running -eq 0 && $is_registry_running -eq 0 ]]; then
echo "glance is not running."
else
if [[ $is_api_running -gt 0 ]]; then
echo "begin to stop glance-api..."
nkill glance-api >/dev/null 2>&1 &
else
echo "glance-api is not running."
fi
if [[ $is_registry_running -gt 0 ]]; then
echo "begin to stop glance-registry..."
nkill glance-registry >/dev/null 2>&1 &
else
echo "glance-registry is not running."
fi
fi
;;
test)
if [[ $is_api_running -eq 0 && $is_registry_running -eq 0 ]]; then
echo "glance is not running."
elif [[ $is_api_running -eq 0 ]]; then
echo "glance-api is not running."
elif [[ $is_registry_running -eq 0 ]]; then
echo "glance-registry is not running."
else
export http_proxy=""
export https_proxy=""
export ftp_proxy=""
echo "querying the uploaded image(s)..."
glance image-list
fi
;;
*)
echo "Usage: /etc/init.d/glance {start|stop|restart|status|test}"
exit 0
;;
esac