aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-nova
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-nova')
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.init29
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/openrc21
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 87e72fab..46b28d32 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()
echo "$DESC is not running"
}
+reset()
+{
+ . /etc/nova/openrc
+
+ # Nova comute
+ simple_delete "nova list --all-tenant" "nova delete" 1 "vm"
+
+ stop
+
+ # This is to make sure postgres is configured and running
+ if ! pidof postmaster > /dev/null; then
+ /etc/init.d/postgresql-init
+ /etc/init.d/postgresql start
+ sleep 5
+ fi
+
+ sudo -u postgres dropdb nova
+ sudo -u postgres createdb nova
+ sleep 2
+ nova-manage db sync
+
+ start
+}
+
case "$1" in
start)
start
@@ -100,8 +124,11 @@ case "$1" in
status)
status
;;
+ reset)
+ reset
+ ;;
*)
- echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
+ echo "Usage: $0 {start|stop|force-reload|restart|reload|status|reset}"
exit 1
;;
esac
diff --git a/meta-openstack/recipes-devtools/python/python-nova/openrc b/meta-openstack/recipes-devtools/python/python-nova/openrc
index c28f3557..35327ace 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%
export OS_AUTH_URL="http://%CONTROLLER_HOST%:5000/v2.0/"
export SERVICE_ENDPOINT="http://%CONTROLLER_HOST%:35357/v2.0"
export SERVICE_TOKEN=%SERVICE_TOKEN%
+
+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
+}
+
+function simple_delete() {
+ $1 | while read line; do
+ id=`echo $line | get_field $3`
+ if [ ! -z "$id" ] ; then
+ echo ">>> Delete $4: id=$id"
+ $2 $id > /dev/null 2>&1
+ fi
+ done
+}