blob: 29c62fc8a8273890beedde65dd6fa78a2f9fa407 (
plain)
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
|
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Glance Test Config
# Description: OpenStack Image Test Config
### END INIT INFO
TEMPEST_CONF_FILE=/etc/tempest/tempest.conf
temp_file="/tmp/do_note_delete_me.temp"
function get_field() {
while read data; do
if [ "$1" -lt 0 ]; then
field="(\$(NF$1))"
else
field="\$$(($1 + 1))"
fi
echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}"
done
}
start()
{
if [ -e $TEMPEST_CONF_FILE ]; then
sleep 5
source /etc/nova/openrc
glance image-list > $temp_file 2>&1
if [ "$?" != "0" ]; then
echo "Glance service is not running"
exit 1
fi
id=`sed -n '4p' < $temp_file | get_field 1`
glance image-show $id > /dev/null 2>&1
if [ "$?" != "0" ]; then
cirros_image_file=`find /root/images/ -name "cirros*.img" | tail -1`
id=`glance image-create --name myfirstimage --is-public true --container-format bare --disk-format qcow2 --file ${cirros_image_file} | grep " id " | get_field 2`
fi
sed -i "s/^image_ref = .*/image_ref = ${id}/" $TEMPEST_CONF_FILE
sed -i "s/^image_ref_alt = .*/image_ref_alt = ${id}/" $TEMPEST_CONF_FILE
rm -f $temp_file > /dev/null 2>&1
nslookup google.com
[ "$?" != "0" ] && echo "WARNING: Make sure DNS server is setup correctly or else some tempest testcases will fail"
fi
}
case "$1" in
start)
start
;;
stop|force-reload|restart|reload|status)
echo "WARNING: command $1 is not supported"
;;
*)
echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
exit 1
;;
esac
exit 0
|