2013-03-07 22:11:40 +00:00
|
|
|
#!/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
|
|
|
|
|
2013-10-01 19:45:04 +00:00
|
|
|
FILES=$TOP_DIR/files
|
|
|
|
|
2013-03-07 22:11:40 +00:00
|
|
|
# Load local configuration
|
|
|
|
source $TOP_DIR/stackrc
|
|
|
|
|
|
|
|
# Get the variables that are set in stack.sh
|
2013-06-04 17:51:54 +00:00
|
|
|
if [[ -r $TOP_DIR/.stackenv ]]; then
|
|
|
|
source $TOP_DIR/.stackenv
|
|
|
|
fi
|
2013-03-07 22:11:40 +00:00
|
|
|
|
|
|
|
# Determine what system we are running on. This provides ``os_VENDOR``,
|
|
|
|
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
|
|
|
# and ``DISTRO``
|
|
|
|
GetDistro
|
|
|
|
|
2013-12-17 17:13:40 +00:00
|
|
|
# Import apache functions
|
|
|
|
source $TOP_DIR/lib/apache
|
|
|
|
source $TOP_DIR/lib/ldap
|
2013-03-07 22:11:40 +00:00
|
|
|
|
|
|
|
# Import database library
|
|
|
|
source $TOP_DIR/lib/database
|
|
|
|
source $TOP_DIR/lib/rpc_backend
|
|
|
|
|
|
|
|
source $TOP_DIR/lib/tls
|
2013-12-17 17:13:40 +00:00
|
|
|
|
2014-04-02 22:43:42 +00:00
|
|
|
source $TOP_DIR/lib/oslo
|
2013-03-07 22:11:40 +00:00
|
|
|
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
|
2013-07-07 03:29:39 +00:00
|
|
|
source $TOP_DIR/lib/neutron
|
2013-03-07 22:11:40 +00:00
|
|
|
source $TOP_DIR/lib/baremetal
|
2013-12-17 17:13:40 +00:00
|
|
|
source $TOP_DIR/lib/ironic
|
|
|
|
source $TOP_DIR/lib/trove
|
|
|
|
|
2013-03-07 22:11:40 +00:00
|
|
|
|
2013-10-15 14:42:43 +00:00
|
|
|
# Extras Source
|
|
|
|
# --------------
|
|
|
|
|
|
|
|
# Phase: source
|
|
|
|
if [[ -d $TOP_DIR/extras.d ]]; then
|
|
|
|
for i in $TOP_DIR/extras.d/*.sh; do
|
|
|
|
[[ -r $i ]] && source $i source
|
|
|
|
done
|
|
|
|
fi
|
2013-03-07 22:11:40 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2013-10-15 14:42:43 +00:00
|
|
|
# Run extras
|
|
|
|
# ==========
|
|
|
|
|
|
|
|
# Phase: clean
|
|
|
|
if [[ -d $TOP_DIR/extras.d ]]; then
|
|
|
|
for i in $TOP_DIR/extras.d/*.sh; do
|
|
|
|
[[ -r $i ]] && source $i clean
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-03-07 22:11:40 +00:00
|
|
|
# Clean projects
|
2014-04-02 22:43:42 +00:00
|
|
|
cleanup_oslo
|
2013-03-07 22:11:40 +00:00
|
|
|
cleanup_cinder
|
|
|
|
cleanup_glance
|
|
|
|
cleanup_keystone
|
|
|
|
cleanup_nova
|
2013-07-07 03:29:39 +00:00
|
|
|
cleanup_neutron
|
2013-03-07 22:11:40 +00:00
|
|
|
cleanup_swift
|
|
|
|
|
2013-10-01 19:45:04 +00:00
|
|
|
if is_service_enabled ldap; then
|
|
|
|
cleanup_ldap
|
|
|
|
fi
|
|
|
|
|
2013-08-05 00:53:19 +00:00
|
|
|
# Do the hypervisor cleanup until this can be moved back into lib/nova
|
2014-01-15 21:04:49 +00:00
|
|
|
if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
|
2013-08-05 00:53:19 +00:00
|
|
|
cleanup_nova_hypervisor
|
|
|
|
fi
|
|
|
|
|
2013-03-07 22:11:40 +00:00
|
|
|
# Clean out /etc
|
2014-05-01 12:16:59 +00:00
|
|
|
sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/heat /etc/neutron
|
2013-03-07 22:11:40 +00:00
|
|
|
|
|
|
|
# Clean out tgt
|
2013-12-17 17:13:40 +00:00
|
|
|
sudo rm -f /etc/tgt/conf.d/*
|
2013-03-07 22:11:40 +00:00
|
|
|
|
|
|
|
# Clean up the message queue
|
|
|
|
cleanup_rpc_backend
|
|
|
|
cleanup_database
|
|
|
|
|
2013-12-17 17:13:40 +00:00
|
|
|
# Clean out data, logs and status
|
|
|
|
LOGDIR=$(dirname "$LOGFILE")
|
|
|
|
sudo rm -rf $DATA_DIR $LOGDIR $DEST/status
|
|
|
|
if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then
|
|
|
|
sudo rm -rf $SCREEN_LOGDIR
|
|
|
|
fi
|
|
|
|
|
2013-03-07 22:11:40 +00:00
|
|
|
# Clean up files
|
2014-02-19 14:02:02 +00:00
|
|
|
|
2014-06-28 08:50:22 +00:00
|
|
|
FILES_TO_CLEAN=".localrc.auto docs/files docs/html shocco/ stack-screenrc test*.conf* test.ini*"
|
2014-02-19 14:02:02 +00:00
|
|
|
FILES_TO_CLEAN+=".stackenv .prereqs"
|
|
|
|
|
2014-02-28 00:46:43 +00:00
|
|
|
for file in $FILES_TO_CLEAN; do
|
2014-06-28 08:50:22 +00:00
|
|
|
rm -rf $TOP_DIR/$file
|
2014-02-19 14:02:02 +00:00
|
|
|
done
|