From 3bbd08214617f5a5e7b54253f9f8b786623546c8 Mon Sep 17 00:00:00 2001 From: Amy Fong Date: Thu, 24 Jul 2014 13:04:41 -0400 Subject: 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 --- .../python/python-cinder/cinder-volume | 38 +++++++++++++++++++++- .../python/python-cinder/cinder.init | 38 +++++++++++++++++++++- .../python/python-cinder/glusterfs_setup.sh | 7 +++- .../python/python-cinder/nfs_setup.sh | 7 +++- 4 files changed, 86 insertions(+), 4 deletions(-) (limited to 'meta-openstack/recipes-devtools/python/python-cinder') diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume index aec6ab0..f753810 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume +++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume @@ -69,6 +69,39 @@ status() echo "$DESC is not running" } +reset() +{ + . /etc/nova/openrc + + # Cleanup cinder volume + simple_delete "cinder list --all-tenant" "cinder delete" 1 "cinder volume" + + # Cleanup cinder backup + simple_delete "cinder backup-list" "cinder backup-delete" 1 "cinder backup" + + stop + + if ! pidof postmaster > /dev/null; then + /etc/init.d/postgresql-init + /etc/init.d/postgresql start + fi + [ ! -d /var/log/cinder ] && mkdir /var/log/cinder + sudo -u postgres dropdb cinder + sudo -u postgres createdb cinder + cinder-manage db sync + + if [ ! -f /etc/cinder/nfs_shares ]; then + /bin/bash /etc/cinder/drivers/nfs_setup.sh + fi + + # Create Cinder glusterfs_share config file with default glusterfs server + if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f /usr/sbin/glusterfsd ]; then + /bin/bash /etc/cinder/drivers/glusterfs_setup.sh + fi + + start +} + case "$1" in start) start @@ -83,8 +116,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-cinder/cinder.init b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init index ecf9d66..f130ac8 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/cinder.init +++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init @@ -71,6 +71,39 @@ status() echo "$DESC is not running" } +reset() +{ + . /etc/nova/openrc + + # Cleanup cinder volume + simple_delete "cinder list --all-tenant" "cinder delete" 1 "cinder volume" + + # Cleanup cinder backup + simple_delete "cinder backup-list" "cinder backup-delete" 1 "cinder backup" + + stop + + if ! pidof postmaster > /dev/null; then + /etc/init.d/postgresql-init + /etc/init.d/postgresql start + fi + [ ! -d /var/log/cinder ] && mkdir /var/log/cinder + sudo -u postgres dropdb cinder + sudo -u postgres createdb cinder + cinder-manage db sync + + if [ ! -f /etc/cinder/nfs_shares ]; then + /bin/bash /etc/cinder/drivers/nfs_setup.sh + fi + + # Create Cinder glusterfs_share config file with default glusterfs server + if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f /usr/sbin/glusterfsd ]; then + /bin/bash /etc/cinder/drivers/glusterfs_setup.sh + fi + + start +} + case "$1" in start) start @@ -85,8 +118,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-cinder/glusterfs_setup.sh b/meta-openstack/recipes-devtools/python/python-cinder/glusterfs_setup.sh index 30997d1..1c87ff9 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/glusterfs_setup.sh +++ b/meta-openstack/recipes-devtools/python/python-cinder/glusterfs_setup.sh @@ -1,7 +1,12 @@ #! /bin/bash +is_default=%IS_DEFAULT% +if [ $# -eq 1 ]; then + is_default=$1 +fi + # Default setup -if [ "$1" == "1" ]; then +if [ "$is_default" == "1" ]; then mkdir /etc/cinder/glusterfs_volumes /etc/init.d/glusterd start gluster volume create glusterfs_volumes controller:/etc/cinder/glusterfs_volumes force diff --git a/meta-openstack/recipes-devtools/python/python-cinder/nfs_setup.sh b/meta-openstack/recipes-devtools/python/python-cinder/nfs_setup.sh index 1d7c475..f07602a 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/nfs_setup.sh +++ b/meta-openstack/recipes-devtools/python/python-cinder/nfs_setup.sh @@ -1,7 +1,12 @@ #! /bin/bash +is_default=%IS_DEFAULT% +if [ $# -eq 1 ]; then + is_default=$1 +fi + # Default setup -if [ "$1" == "1" ]; then +if [ "$is_default" == "1" ]; then mkdir /etc/cinder/nfs_volumes echo "/etc/cinder/nfs_volumes *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)" >> /etc/exports fi -- cgit v1.2.3-54-g00ecf