aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack
diff options
context:
space:
mode:
authorAmy Fong <amy.fong@windriver.com>2014-07-24 13:04:41 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-07-25 15:45:25 -0400
commit3bbd08214617f5a5e7b54253f9f8b786623546c8 (patch)
treed782a074f3a013b302446817ef9d147ddee6bb60 /meta-openstack
parentce99c21125614dfa72428a9ef3ed563db8c99c93 (diff)
downloadmeta-cloud-services-3bbd08214617f5a5e7b54253f9f8b786623546c8.tar.gz
meta-cloud-services-3bbd08214617f5a5e7b54253f9f8b786623546c8.tar.bz2
meta-cloud-services-3bbd08214617f5a5e7b54253f9f8b786623546c8.zip
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')
-rw-r--r--meta-openstack/recipes-devtools/python/python-barbican/barbican.init5
-rw-r--r--meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init23
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/cinder-volume38
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/cinder.init38
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/glusterfs_setup.sh7
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/nfs_setup.sh7
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder_git.bb45
-rw-r--r--meta-openstack/recipes-devtools/python/python-glance/glance.init29
-rw-r--r--meta-openstack/recipes-devtools/python/python-heat/heat.init24
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone/keystone39
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone_git.bb4
-rw-r--r--meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init4
-rw-r--r--meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init50
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.init29
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/openrc21
-rw-r--r--meta-openstack/recipes-devtools/python/python-swift/swift.init29
-rw-r--r--meta-openstack/recipes-devtools/python/python-swift_git.bb3
17 files changed, 361 insertions, 34 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-barbican/barbican.init b/meta-openstack/recipes-devtools/python/python-barbican/barbican.init
index 8bf0de1c..5b353e1b 100644
--- a/meta-openstack/recipes-devtools/python/python-barbican/barbican.init
+++ b/meta-openstack/recipes-devtools/python/python-barbican/barbican.init
@@ -86,15 +86,16 @@ case "$1" in
stop)
stop
;;
- restart|force-reload|reload)
+ restart|force-reload|reload|reset)
stop
+ sleep 1
start
;;
status)
status
;;
*)
- 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-ceilometer/ceilometer.init b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
index d3c72e4a..ba0f426d 100644
--- a/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
+++ b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
@@ -70,6 +70,24 @@ status()
echo "$DESC is not running"
}
+reset()
+{
+ 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 2
+ fi
+ [ ! -d /var/log/ceilometer ] && mkdir /var/log/ceilometer
+ sudo -u postgres dropdb ceilometer
+ sudo -u postgres createdb ceilometer
+ ceilometer-dbsync
+
+ start
+}
+
case "$1" in
start)
start
@@ -84,8 +102,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-volume b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume
index aec6ab09..f753810e 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 ecf9d66e..f130ac81 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 30997d12..1c87ff9d 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 1d7c475e..f07602a3 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
diff --git a/meta-openstack/recipes-devtools/python/python-cinder_git.bb b/meta-openstack/recipes-devtools/python/python-cinder_git.bb
index 7b3bb284..2d7e76cc 100644
--- a/meta-openstack/recipes-devtools/python/python-cinder_git.bb
+++ b/meta-openstack/recipes-devtools/python/python-cinder_git.bb
@@ -33,6 +33,12 @@ do_install_prepend() {
sed 's:%PYTHON_SITEPACKAGES_DIR%:${PYTHON_SITEPACKAGES_DIR}:g' -i ${S}/${SRCNAME}/tests/fake_flags.py
}
+CINDER_LVM_VOLUME_BACKING_FILE_SIZE ?= "2G"
+CINDER_NFS_VOLUME_SERVERS_DEFAULT = "controller:/etc/cinder/nfs_volumes"
+CINDER_NFS_VOLUME_SERVERS ?= "${CINDER_NFS_VOLUME_SERVERS_DEFAULT}"
+CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT = "controller:/glusterfs_volumes"
+CINDER_GLUSTERFS_VOLUME_SERVERS ?= "${CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT}"
+
do_install_append() {
TEMPLATE_CONF_DIR=${S}${sysconfdir}/${SRCNAME}
CINDER_CONF_DIR=${D}${sysconfdir}/${SRCNAME}
@@ -74,13 +80,24 @@ do_install_append() {
# test setup
cp run_tests.sh ${CINDER_CONF_DIR}
cp -r tools ${CINDER_CONF_DIR}
-}
-CINDER_LVM_VOLUME_BACKING_FILE_SIZE ?= "2G"
-CINDER_NFS_VOLUME_SERVERS_DEFAULT = "controller:/etc/cinder/nfs_volumes"
-CINDER_NFS_VOLUME_SERVERS ?= "${CINDER_NFS_VOLUME_SERVERS_DEFAULT}"
-CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT = "controller:/glusterfs_volumes"
-CINDER_GLUSTERFS_VOLUME_SERVERS ?= "${CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT}"
+ #Create cinder volume group backing file
+ sed 's/%CINDER_LVM_VOLUME_BACKING_FILE_SIZE%/${CINDER_LVM_VOLUME_BACKING_FILE_SIZE}/g' -i ${D}/etc/cinder/drivers/lvm_iscsi_setup.sh
+ mkdir -p ${D}/etc/tgt/
+ echo "include /etc/cinder/data/volumes/*" > ${D}/etc/tgt/targets.conf
+
+ # Create Cinder nfs_share config file with default nfs server
+ echo "${CINDER_NFS_VOLUME_SERVERS}" > ${D}/etc/cinder/nfs_shares
+ sed 's/\s\+/\n/g' -i ${D}/etc/cinder/nfs_shares
+ [ "x${CINDER_NFS_VOLUME_SERVERS}" = "x${CINDER_NFS_VOLUME_SERVERS_DEFAULT}" ] && is_default="1" || is_default="0"
+ sed -e "s:%IS_DEFAULT%:${is_default}:g" -i ${D}/etc/cinder/drivers/nfs_setup.sh
+
+ # Create Cinder glusterfs_share config file with default glusterfs server
+ echo "${CINDER_GLUSTERFS_VOLUME_SERVERS}" > ${D}/etc/cinder/glusterfs_shares
+ sed 's/\s\+/\n/g' -i ${D}/etc/cinder/glusterfs_shares
+ [ "x${CINDER_GLUSTERFS_VOLUME_SERVERS}" = "x${CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT}" ] && is_default="1" || is_default="0"
+ sed -e "s:%IS_DEFAULT%:${is_default}:g" -i ${D}/etc/cinder/drivers/glusterfs_setup.sh
+}
pkg_postinst_${SRCNAME}-setup () {
if [ "x$D" != "x" ]; then
@@ -100,31 +117,21 @@ pkg_postinst_${SRCNAME}-setup () {
sudo -u postgres createdb cinder
cinder-manage db sync
- #Create cinder volume group backing file
- sed 's/%CINDER_LVM_VOLUME_BACKING_FILE_SIZE%/${CINDER_LVM_VOLUME_BACKING_FILE_SIZE}/g' -i /etc/cinder/drivers/lvm_iscsi_setup.sh
- echo "include /etc/cinder/data/volumes/*" >> /etc/tgt/targets.conf
-
# Create Cinder nfs_share config file with default nfs server
if [ ! -f /etc/cinder/nfs_shares ]; then
- echo "${CINDER_NFS_VOLUME_SERVERS}" > /etc/cinder/nfs_shares
- sed 's/\s\+/\n/g' -i /etc/cinder/nfs_shares
- [[ "x${CINDER_NFS_VOLUME_SERVERS}" == "x${CINDER_NFS_VOLUME_SERVERS_DEFAULT}" ]] && is_default="1" || is_default="0"
- /bin/bash /etc/cinder/drivers/nfs_setup.sh ${is_default}
+ /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
- echo "${CINDER_GLUSTERFS_VOLUME_SERVERS}" > /etc/cinder/glusterfs_shares
- sed 's/\s\+/\n/g' -i /etc/cinder/glusterfs_shares
- [[ "x${CINDER_GLUSTERFS_VOLUME_SERVERS}" == "x${CINDER_GLUSTERFS_VOLUME_SERVERS_DEFAULT}" ]] && is_default="1" || is_default="0"
- /bin/bash /etc/cinder/drivers/glusterfs_setup.sh ${is_default}
+ /bin/bash /etc/cinder/drivers/glusterfs_setup.sh
fi
}
PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-api ${SRCNAME}-volume ${SRCNAME}-scheduler ${SRCNAME}-backup"
ALLOW_EMPTY_${SRCNAME}-setup = "1"
-FILES_${PN} = "${libdir}/*"
+FILES_${PN} = "${libdir}/* /etc/tgt"
FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/run_tests.sh \
${sysconfdir}/${SRCNAME}/tools"
diff --git a/meta-openstack/recipes-devtools/python/python-glance/glance.init b/meta-openstack/recipes-devtools/python/python-glance/glance.init
index cb94ed74..5b1bf749 100644
--- a/meta-openstack/recipes-devtools/python/python-glance/glance.init
+++ b/meta-openstack/recipes-devtools/python/python-glance/glance.init
@@ -70,6 +70,30 @@ status()
echo "$DESC is not running"
}
+reset()
+{
+ . /etc/nova/openrc
+
+ # Cleanup all glance images
+ simple_delete "glance image-list --all-tenant" "glance image-delete" 1 "glance image"
+
+ 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
+
+ [ ! -d /var/log/glance ] && mkdir /var/log/glance
+ sudo -u postgres dropdb glance
+ sudo -u postgres createdb glance
+ glance-manage db_sync
+
+ start
+}
+
case "$1" in
start)
start
@@ -84,8 +108,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-heat/heat.init b/meta-openstack/recipes-devtools/python/python-heat/heat.init
index 4d8c1809..5e0719fc 100644
--- a/meta-openstack/recipes-devtools/python/python-heat/heat.init
+++ b/meta-openstack/recipes-devtools/python/python-heat/heat.init
@@ -76,6 +76,25 @@ status()
echo "$DESC is not running"
}
+reset()
+{
+ 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 2
+ fi
+
+ [ ! -d /var/log/heat ] && mkdir /var/log/heat
+ sudo -u postgres dropdb heat
+ sudo -u postgres createdb heat
+ heat-manage db_sync
+
+ start
+}
+
case "$1" in
start)
start
@@ -90,8 +109,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-keystone/keystone b/meta-openstack/recipes-devtools/python/python-keystone/keystone
index d73bc751..6524fed3 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone/keystone
+++ b/meta-openstack/recipes-devtools/python/python-keystone/keystone
@@ -67,6 +67,40 @@ status()
echo "$DESC is not running"
}
+reset()
+{
+ # Cleanup keystone tenant
+ . /etc/nova/openrc
+ simple_delete "keystone user-list" "keystone user-delete" 1 "keystone user"
+ simple_delete "keystone tenant-list" "keystone tenant-delete" 1 "keystone tenant"
+ simple_delete "keystone role-list" "keystone role-delete" 1 "keystone role"
+ simple_delete "keystone endpoint-list" "keystone endpoint-delete" 1 "keystone endpoint"
+ simple_delete "keystone service-list" "keystone service-delete" 1 "keystone service"
+
+ 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 2
+ fi
+
+ sudo -u postgres dropdb keystone
+ sudo -u postgres createdb keystone
+ keystone-manage db_sync
+ keystone-manage pki_setup --keystone-user=root --keystone-group=root
+
+ start
+
+ sleep 2
+
+ ADMIN_PASSWORD=%ADMIN_PASSWORD% \
+ SERVICE_PASSWORD=%SERVICE_PASSWORD% \
+ SERVICE_TENANT_NAME=%SERVICE_TENANT_NAME% \
+ bash /etc/keystone/identity.sh
+}
+
case "$1" in
start)
start
@@ -81,8 +115,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-keystone_git.bb b/meta-openstack/recipes-devtools/python/python-keystone_git.bb
index 050549ca..df4b897b 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone_git.bb
+++ b/meta-openstack/recipes-devtools/python/python-keystone_git.bb
@@ -65,6 +65,10 @@ do_install_append() {
sed -e "s:%KEYSTONE_PACKAGE_DIR%:${PYTHON_SITEPACKAGES_DIR}/keystone:g" -i ${KEYSTONE_PACKAGE_DIR}/tests/test_overrides.conf
cp run_tests.sh ${KEYSTONE_CONF_DIR}
+
+ sed -e "s/%ADMIN_PASSWORD%/${ADMIN_PASSWORD}/g" -i ${D}${sysconfdir}/init.d/keystone
+ sed -e "s/%SERVICE_PASSWORD%/${SERVICE_PASSWORD}/g" -i ${D}${sysconfdir}/init.d/keystone
+ sed -e "s/%SERVICE_TENANT_NAME%/${SERVICE_TENANT_NAME}/g" -i ${D}${sysconfdir}/init.d/keystone
}
pkg_postinst_${SRCNAME}-setup () {
diff --git a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
index 8bd4c234..8b11a278 100644
--- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
+++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
@@ -75,7 +75,7 @@ case "$1" in
stop)
stop
;;
- restart|force-reload|reload)
+ restart|force-reload|reload|reset)
stop
start
;;
@@ -83,7 +83,7 @@ case "$1" in
status
;;
*)
- 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-neutron/neutron-server.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
index 63440e81..0c78de62 100644
--- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
+++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
@@ -71,6 +71,51 @@ status()
echo "$DESC is not running"
}
+reset()
+{
+ . /etc/nova/openrc
+
+ # Cleanup all neutron floating ip
+ simple_delete "neutron floatingip-list --all-tenant" "neutron floatingip-delete" 1 "neutron floatingip"
+
+ # Cleanup all neutron router
+ neutron router-list | while read line; do
+ router_id=`echo $line | get_field 1`
+ neutron router-port-list $router_id | while read line_port; do
+ port_id=`echo $line_port | get_field 1`
+ subnet_id=`echo $line_port | get_field 4 | cut -d ' ' -f 2 | cut -d '"' -f 2`
+ if [ ! -z "$router_id" ] && [ ! -z "$subnet_id" ] ; then
+ echo ">>> Delete router-port: router_id=$router_id, port_id=$port_id, subnet_id=$subnet_id"
+ neutron router-interface-delete $router_id $subnet_id > /dev/null 2>&1
+ fi
+ done
+ if [ ! -z "$router_id" ] ; then
+ echo ">>> Delete router: router_id=$router_id"
+ neutron router-delete $router_id > /dev/null 2>&1
+ fi
+ done
+
+ # Cleanup all neutron ports
+ simple_delete "neutron port-list --all-tenant" "neutron port-delete" 1 "neutron port"
+
+ # Cleanup all neutron net
+ simple_delete "neutron net-list --all-tenant" "neutron net-delete" 1 "neutron net"
+
+ 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 2
+ fi
+
+ sudo -u postgres dropdb ovs_neutron
+ sudo -u postgres createdb ovs_neutron
+
+ start
+}
+
case "$1" in
start)
start
@@ -85,8 +130,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/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
+}
diff --git a/meta-openstack/recipes-devtools/python/python-swift/swift.init b/meta-openstack/recipes-devtools/python/python-swift/swift.init
index cf120664..256e1d04 100644
--- a/meta-openstack/recipes-devtools/python/python-swift/swift.init
+++ b/meta-openstack/recipes-devtools/python/python-swift/swift.init
@@ -50,6 +50,30 @@ status ()
$SWIFT_INIT object-server status
}
+reset()
+{
+ stop
+
+ CLUSTER_CONF=/etc/swift/cluster.conf
+ SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
+
+ $SWIFT_SETUP clean
+
+ for i in `seq 1 3`; do
+ BACKING_FILE=/etc/swift/swift_backing_$i
+ if [ "x%SWIFT_BACKING_FILE_SIZE%" != "x0G" ]; then
+ truncate -s %SWIFT_BACKING_FILE_SIZE% $BACKING_FILE
+ fi
+ done
+
+ $SWIFT_SETUP createrings
+ $SWIFT_SETUP formatdevs
+ $SWIFT_SETUP mountdevs
+ $SWIFT_SETUP -i "%CONTROLLER_IP%" adddevs
+ $SWIFT_SETUP unmountdevs
+
+ start
+}
case "$1" in
start)
@@ -65,8 +89,11 @@ case "$1" in
status)
status
;;
+ reset)
+ reset
+ ;;
*)
- echo "Usage: swift {start|stop|force-reload|restart|status}"
+ echo "Usage: swift {start|stop|force-reload|restart|status|reset}"
exit 1
;;
esac
diff --git a/meta-openstack/recipes-devtools/python/python-swift_git.bb b/meta-openstack/recipes-devtools/python/python-swift_git.bb
index d1745170..19c056f8 100644
--- a/meta-openstack/recipes-devtools/python/python-swift_git.bb
+++ b/meta-openstack/recipes-devtools/python/python-swift_git.bb
@@ -84,6 +84,9 @@ do_install_append() {
cp -r test ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/
grep -rl '^from test' ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/test | xargs sed 's/^from test/from swift\.test/g' -i
+
+ sed "s/%SWIFT_BACKING_FILE_SIZE%/${SWIFT_BACKING_FILE_SIZE}/g" -i ${D}${sysconfdir}/init.d/swift
+ sed "s/%CONTROLLER_IP%/${CONTROLLER_IP}/g" -i ${D}${sysconfdir}/init.d/swift
}
pkg_postinst_${SRCNAME}-setup () {