diff options
Diffstat (limited to 'meta-openstack-controller-test-config/recipes-devtools/python/python-glance/glance-test-config.init')
-rw-r--r-- | meta-openstack-controller-test-config/recipes-devtools/python/python-glance/glance-test-config.init | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/meta-openstack-controller-test-config/recipes-devtools/python/python-glance/glance-test-config.init b/meta-openstack-controller-test-config/recipes-devtools/python/python-glance/glance-test-config.init new file mode 100644 index 0000000..2186421 --- /dev/null +++ b/meta-openstack-controller-test-config/recipes-devtools/python/python-glance/glance-test-config.init | |||
@@ -0,0 +1,66 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ### BEGIN INIT INFO | ||
4 | # Provides: | ||
5 | # Required-Start: $remote_fs $network $syslog | ||
6 | # Required-Stop: $remote_fs $syslog | ||
7 | # Default-Start: 2 3 4 5 | ||
8 | # Default-Stop: 0 1 6 | ||
9 | # Short-Description: Glance Test Config | ||
10 | # Description: OpenStack Image Test Config | ||
11 | ### END INIT INFO | ||
12 | |||
13 | |||
14 | TEMPEST_CONF_FILE=/etc/tempest/tempest.conf | ||
15 | temp_file="/tmp/do_note_delete_me.temp" | ||
16 | |||
17 | |||
18 | function get_field() { | ||
19 | while read data; do | ||
20 | if [ "$1" -lt 0 ]; then | ||
21 | field="(\$(NF$1))" | ||
22 | else | ||
23 | field="\$$(($1 + 1))" | ||
24 | fi | ||
25 | echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}" | ||
26 | done | ||
27 | } | ||
28 | |||
29 | start() | ||
30 | { | ||
31 | if [ -e $TEMPEST_CONF_FILE ]; then | ||
32 | sleep 5 | ||
33 | source /etc/nova/openrc | ||
34 | glance image-list > $temp_file 2>&1 | ||
35 | if [ "$?" != "0" ]; then | ||
36 | echo "Glance service is not running" | ||
37 | exit 1 | ||
38 | fi | ||
39 | id=`sed -n '4p' < $temp_file | get_field 1` | ||
40 | glance image-show $id > /dev/null 2>&1 | ||
41 | if [ "$?" != "0" ]; then | ||
42 | id=`glance image-create --name myfirstimage --is-public true --container-format bare --disk-format qcow2 --file /root/images/cirros-0.3.0-x86_64-disk.img | grep " id " | get_field 2` | ||
43 | fi | ||
44 | sed -i "s/^image_ref = .*/image_ref = ${id}/" $TEMPEST_CONF_FILE | ||
45 | sed -i "s/^image_ref_alt = .*/image_ref_alt = ${id}/" $TEMPEST_CONF_FILE | ||
46 | rm -f $temp_file > /dev/null 2>&1 | ||
47 | |||
48 | nslookup google.com | ||
49 | [ "$?" != "0" ] && echo "WARNING: Make sure DNS server is setup correctly or else some tempest testcases will fail" | ||
50 | fi | ||
51 | } | ||
52 | |||
53 | case "$1" in | ||
54 | start) | ||
55 | start | ||
56 | ;; | ||
57 | stop|force-reload|restart|reload|status) | ||
58 | echo "WARNING: command $1 is not supported" | ||
59 | ;; | ||
60 | *) | ||
61 | echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" | ||
62 | exit 1 | ||
63 | ;; | ||
64 | esac | ||
65 | |||
66 | exit 0 | ||