Add clean.sh
clean.sh gets rid of all residue of running DevStack except installed
packages and pip modules.
And it eradicates rabbitmq-server and ts erlang dependencies as well as
the other RPC backends and databases.
Change-Id: I2b9a251a0a151c012bae85a5a2f9c2f72e7700be
diff --git a/lib/database b/lib/database
index ebab333..79b77a2 100644
--- a/lib/database
+++ b/lib/database
@@ -42,6 +42,11 @@
# This is not an error as multi-node installs will do this on the compute nodes
+# Get rid of everything enough to cleanly change database backends
+function cleanup_database {
+ cleanup_database_$DATABASE_TYPE
+}
+
# Set the database type based on the configuration
function initialize_database_backends {
for backend in $DATABASE_BACKENDS; do
diff --git a/lib/databases/mysql b/lib/databases/mysql
index ec65c36..0633ab0 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -10,6 +10,24 @@
register_database mysql
+# Get rid of everything enough to cleanly change database backends
+function cleanup_database_mysql {
+ if is_ubuntu; then
+ # Get ruthless with mysql
+ stop_service $MYSQL
+ sudo aptitude purge -y ~nmysql-server
+ sudo rm -rf /var/lib/mysql
+ return
+ elif is_fedora; then
+ MYSQL=mysqld
+ elif is_suse; then
+ MYSQL=mysql
+ else
+ return
+ fi
+ stop_service $MYSQL
+}
+
function recreate_database_mysql {
local db=$1
local charset=$2
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 7d4a6c5..efc206f 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -10,6 +10,20 @@
register_database postgresql
+# Get rid of everything enough to cleanly change database backends
+function cleanup_database_postgresql {
+ stop_service postgresql
+ if is_ubuntu; then
+ # Get ruthless with mysql
+ sudo aptitude purge -y ~npostgresql
+ return
+ elif is_fedora; then
+ uninstall_package postgresql-server
+ else
+ return
+ fi
+}
+
function recreate_database_postgresql {
local db=$1
local charset=$2
diff --git a/lib/glance b/lib/glance
index 9ec2112..edf6982 100644
--- a/lib/glance
+++ b/lib/glance
@@ -59,8 +59,7 @@
function cleanup_glance() {
# kill instances (nova)
# delete image files (glance)
- # This function intentionally left blank
- :
+ sudo rm -rf $GLANCE_CACHE_DIR $GLANCE_IMAGE_DIR $GLANCE_AUTH_CACHE_DIR
}
# configure_glanceclient() - Set config files, create data dirs, etc
diff --git a/lib/nova b/lib/nova
index 906a635..23346b7 100644
--- a/lib/nova
+++ b/lib/nova
@@ -106,6 +106,8 @@
# Clean out the instances directory.
sudo rm -rf $NOVA_INSTANCES_PATH/*
fi
+
+ sudo rm -rf $NOVA_STATE_PATH $NOVA_AUTH_CACHE_DIR
}
# configure_novaclient() - Set config files, create data dirs, etc
@@ -308,9 +310,6 @@
sudo chown -R $STACK_USER $NOVA_INSTANCES_PATH
fi
fi
-
- # Clean up old instances
- cleanup_nova
fi
}
diff --git a/lib/quantum b/lib/quantum
index 66360d4..862ba84 100644
--- a/lib/quantum
+++ b/lib/quantum
@@ -211,8 +211,6 @@
fi
_configure_quantum_debug_command
-
- _cleanup_quantum
}
function create_nova_conf_quantum() {
@@ -385,9 +383,9 @@
fi
}
-# _cleanup_quantum() - Remove residual data files, anything left over from previous
+# cleanup_quantum() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
-function _cleanup_quantum() {
+function cleanup_quantum() {
:
}
diff --git a/lib/rpc_backend b/lib/rpc_backend
index 02614ea..bbd51f0 100644
--- a/lib/rpc_backend
+++ b/lib/rpc_backend
@@ -43,6 +43,38 @@
fi
}
+# clean up after rpc backend - eradicate all traces so changing backends
+# produces a clean switch
+function cleanup_rpc_backend {
+ if is_service_enabled rabbit; then
+ # Obliterate rabbitmq-server
+ uninstall_package rabbitmq-server
+ sudo killall epmd
+ if is_ubuntu; then
+ # And the Erlang runtime too
+ sudo aptitude purge -y ~nerlang
+ fi
+ elif is_service_enabled qpid; then
+ if is_fedora; then
+ uninstall_package qpid-cpp-server-daemon
+ elif is_ubuntu; then
+ uninstall_package qpidd
+ else
+ exit_distro_not_supported "qpid installation"
+ fi
+ elif is_service_enabled zeromq; then
+ if is_fedora; then
+ uninstall_package zeromq python-zmq
+ elif is_ubuntu; then
+ uninstall_package libzmq1 python-zmq
+ elif is_suse; then
+ uninstall_package libzmq1 python-pyzmq
+ else
+ exit_distro_not_supported "zeromq installation"
+ fi
+ fi
+}
+
# install rpc backend
function install_rpc_backend() {
if is_service_enabled rabbit; then
diff --git a/lib/swift b/lib/swift
index 5c4ceab..04a54c3 100644
--- a/lib/swift
+++ b/lib/swift
@@ -388,9 +388,11 @@
# stop_swift() - Stop running processes (non-screen)
function stop_swift() {
# screen normally killed by unstack.sh
- if type -p swift-init >/dev/null;then
+ if type -p swift-init >/dev/null; then
swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
fi
+ # Dump the proxy server
+ sudo pkill -f swift-proxy-server
}
# Restore xtrace