diff options
| author | Amy Fong <amy.fong@windriver.com> | 2014-07-24 13:04:41 -0400 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-07-25 15:45:30 -0400 |
| commit | 1491d54da84195dda8c7d5ce1fac21437f2bc519 (patch) | |
| tree | cc16576ec9471de2c9d18de8987f5a046971df0f /meta-openstack/recipes-devtools/python/python-nova | |
| parent | 3085fa57f54335cfa3794aaf1f45928f5300b000 (diff) | |
| download | meta-cloud-services-1491d54da84195dda8c7d5ce1fac21437f2bc519.tar.gz | |
openstack initscript: add reset
Some of the openstack data is associated with external resources
(ie glance may have external files), we explicitly invoke the delete commands on those
in additional to dropping and recreating the databases.
Signed-off-by: Amy Fong <amy.fong@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-nova')
| -rw-r--r-- | meta-openstack/recipes-devtools/python/python-nova/nova.init | 29 | ||||
| -rw-r--r-- | meta-openstack/recipes-devtools/python/python-nova/openrc | 21 |
2 files changed, 49 insertions, 1 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.init b/meta-openstack/recipes-devtools/python/python-nova/nova.init index 87e72fa..46b28d3 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/nova.init +++ b/meta-openstack/recipes-devtools/python/python-nova/nova.init | |||
| @@ -86,6 +86,30 @@ status() | |||
| 86 | echo "$DESC is not running" | 86 | echo "$DESC is not running" |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | reset() | ||
| 90 | { | ||
| 91 | . /etc/nova/openrc | ||
| 92 | |||
| 93 | # Nova comute | ||
| 94 | simple_delete "nova list --all-tenant" "nova delete" 1 "vm" | ||
| 95 | |||
| 96 | stop | ||
| 97 | |||
| 98 | # This is to make sure postgres is configured and running | ||
| 99 | if ! pidof postmaster > /dev/null; then | ||
| 100 | /etc/init.d/postgresql-init | ||
| 101 | /etc/init.d/postgresql start | ||
| 102 | sleep 5 | ||
| 103 | fi | ||
| 104 | |||
| 105 | sudo -u postgres dropdb nova | ||
| 106 | sudo -u postgres createdb nova | ||
| 107 | sleep 2 | ||
| 108 | nova-manage db sync | ||
| 109 | |||
| 110 | start | ||
| 111 | } | ||
| 112 | |||
| 89 | case "$1" in | 113 | case "$1" in |
| 90 | start) | 114 | start) |
| 91 | start | 115 | start |
| @@ -100,8 +124,11 @@ case "$1" in | |||
| 100 | status) | 124 | status) |
| 101 | status | 125 | status |
| 102 | ;; | 126 | ;; |
| 127 | reset) | ||
| 128 | reset | ||
| 129 | ;; | ||
| 103 | *) | 130 | *) |
| 104 | echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" | 131 | echo "Usage: $0 {start|stop|force-reload|restart|reload|status|reset}" |
| 105 | exit 1 | 132 | exit 1 |
| 106 | ;; | 133 | ;; |
| 107 | esac | 134 | esac |
diff --git a/meta-openstack/recipes-devtools/python/python-nova/openrc b/meta-openstack/recipes-devtools/python/python-nova/openrc index c28f355..35327ac 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/openrc +++ b/meta-openstack/recipes-devtools/python/python-nova/openrc | |||
| @@ -4,3 +4,24 @@ export OS_PASSWORD=%OS_PASSWORD% | |||
| 4 | export OS_AUTH_URL="http://%CONTROLLER_HOST%:5000/v2.0/" | 4 | export OS_AUTH_URL="http://%CONTROLLER_HOST%:5000/v2.0/" |
| 5 | export SERVICE_ENDPOINT="http://%CONTROLLER_HOST%:35357/v2.0" | 5 | export SERVICE_ENDPOINT="http://%CONTROLLER_HOST%:35357/v2.0" |
| 6 | export SERVICE_TOKEN=%SERVICE_TOKEN% | 6 | export SERVICE_TOKEN=%SERVICE_TOKEN% |
| 7 | |||
| 8 | function get_field() { | ||
| 9 | while read data; do | ||
| 10 | if [ "$1" -lt 0 ]; then | ||
| 11 | field="(\$(NF$1))" | ||
| 12 | else | ||
| 13 | field="\$$(($1 + 1))" | ||
| 14 | fi | ||
| 15 | echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}" | ||
| 16 | done | ||
| 17 | } | ||
| 18 | |||
| 19 | function simple_delete() { | ||
| 20 | $1 | while read line; do | ||
| 21 | id=`echo $line | get_field $3` | ||
| 22 | if [ ! -z "$id" ] ; then | ||
| 23 | echo ">>> Delete $4: id=$id" | ||
| 24 | $2 $id > /dev/null 2>&1 | ||
| 25 | fi | ||
| 26 | done | ||
| 27 | } | ||
