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
This commit is contained in:
parent
08fd641a19
commit
995eb927f7
91
clean.sh
Executable file
91
clean.sh
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# **clean.sh**
|
||||
|
||||
# ``clean.sh`` does its best to eradicate traces of a Grenade
|
||||
# run except for the following:
|
||||
# - both base and target code repos are left alone
|
||||
# - packages (system and pip) are left alone
|
||||
|
||||
# This means that all data files are removed. More??
|
||||
|
||||
# Keep track of the current devstack directory.
|
||||
TOP_DIR=$(cd $(dirname "$0") && pwd)
|
||||
|
||||
# Import common functions
|
||||
source $TOP_DIR/functions
|
||||
|
||||
# Load local configuration
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
# Get the variables that are set in stack.sh
|
||||
source $TOP_DIR/.stackenv
|
||||
|
||||
# Determine what system we are running on. This provides ``os_VENDOR``,
|
||||
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
||||
# and ``DISTRO``
|
||||
GetDistro
|
||||
|
||||
|
||||
# Import database library
|
||||
source $TOP_DIR/lib/database
|
||||
source $TOP_DIR/lib/rpc_backend
|
||||
|
||||
source $TOP_DIR/lib/tls
|
||||
source $TOP_DIR/lib/horizon
|
||||
source $TOP_DIR/lib/keystone
|
||||
source $TOP_DIR/lib/glance
|
||||
source $TOP_DIR/lib/nova
|
||||
source $TOP_DIR/lib/cinder
|
||||
source $TOP_DIR/lib/swift
|
||||
source $TOP_DIR/lib/ceilometer
|
||||
source $TOP_DIR/lib/heat
|
||||
source $TOP_DIR/lib/quantum
|
||||
source $TOP_DIR/lib/baremetal
|
||||
source $TOP_DIR/lib/ldap
|
||||
|
||||
|
||||
# See if there is anything running...
|
||||
# need to adapt when run_service is merged
|
||||
SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
|
||||
if [[ -n "$SESSION" ]]; then
|
||||
# Let unstack.sh do its thing first
|
||||
$TOP_DIR/unstack.sh --all
|
||||
fi
|
||||
|
||||
# Clean projects
|
||||
cleanup_cinder
|
||||
cleanup_glance
|
||||
cleanup_keystone
|
||||
cleanup_nova
|
||||
cleanup_quantum
|
||||
cleanup_swift
|
||||
|
||||
# cinder doesn't clean up the volume group as it might be used elsewhere...
|
||||
# clean it up if it is a loop device
|
||||
VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}')
|
||||
if [[ -n "$VG_DEV" ]]; then
|
||||
sudo losetup -d $VG_DEV
|
||||
fi
|
||||
|
||||
#if mount | grep $DATA_DIR/swift/drives; then
|
||||
# sudo umount $DATA_DIR/swift/drives/sdb1
|
||||
#fi
|
||||
|
||||
|
||||
# Clean out /etc
|
||||
sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift
|
||||
|
||||
# Clean out tgt
|
||||
sudo rm /etc/tgt/conf.d/*
|
||||
|
||||
# Clean up the message queue
|
||||
cleanup_rpc_backend
|
||||
cleanup_database
|
||||
|
||||
# Clean up networking...
|
||||
# should this be in nova?
|
||||
# FIXED_IP_ADDR in br100
|
||||
|
||||
# Clean up files
|
||||
#rm -f .stackenv
|
15
functions
15
functions
@ -775,6 +775,21 @@ function install_package() {
|
||||
}
|
||||
|
||||
|
||||
# Distro-agnostic package uninstaller
|
||||
# uninstall_package package [package ...]
|
||||
function uninstall_package() {
|
||||
if is_ubuntu; then
|
||||
apt_get purge "$@"
|
||||
elif is_fedora; then
|
||||
yum remove -y "$@"
|
||||
elif is_suse; then
|
||||
rpm -e "$@"
|
||||
else
|
||||
exit_distro_not_supported "uninstalling packages"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Distro-agnostic function to tell if a package is installed
|
||||
# is_package_installed package [package ...]
|
||||
function is_package_installed() {
|
||||
|
@ -42,6 +42,11 @@ done
|
||||
# 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
|
||||
|
@ -10,6 +10,24 @@ set +o xtrace
|
||||
|
||||
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
|
||||
|
@ -10,6 +10,20 @@ set +o xtrace
|
||||
|
||||
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
|
||||
|
@ -59,8 +59,7 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}
|
||||
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
|
||||
|
5
lib/nova
5
lib/nova
@ -106,6 +106,8 @@ function cleanup_nova() {
|
||||
# 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 @@ EOF"
|
||||
sudo chown -R $STACK_USER $NOVA_INSTANCES_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
# Clean up old instances
|
||||
cleanup_nova
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,6 @@ function configure_quantum() {
|
||||
fi
|
||||
|
||||
_configure_quantum_debug_command
|
||||
|
||||
_cleanup_quantum
|
||||
}
|
||||
|
||||
function create_nova_conf_quantum() {
|
||||
@ -385,9 +383,9 @@ function stop_quantum() {
|
||||
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() {
|
||||
:
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,38 @@ function check_rpc_backend() {
|
||||
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
|
||||
|
@ -391,6 +391,8 @@ function stop_swift() {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user