clean.sh
9a413abc
 #!/bin/bash
995eb927
 
 # **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
 
b9e25135
 FILES=$TOP_DIR/files
 
995eb927
 # Load local configuration
53753293
 source $TOP_DIR/openrc
995eb927
 
 # Get the variables that are set in stack.sh
58f9cf76
 if [[ -r $TOP_DIR/.stackenv ]]; then
     source $TOP_DIR/.stackenv
 fi
995eb927
 
 # Determine what system we are running on.  This provides ``os_VENDOR``,
7710e7fc
 # ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME``
995eb927
 # and ``DISTRO``
 GetDistro
 
53ffc713
 # Import apache functions
 source $TOP_DIR/lib/apache
 source $TOP_DIR/lib/ldap
995eb927
 
 # Import database library
 source $TOP_DIR/lib/database
 source $TOP_DIR/lib/rpc_backend
 
 source $TOP_DIR/lib/tls
53ffc713
 
59d9cecb
 source $TOP_DIR/lib/oslo
67168e80
 source $TOP_DIR/lib/lvm
995eb927
 source $TOP_DIR/lib/horizon
 source $TOP_DIR/lib/keystone
 source $TOP_DIR/lib/glance
 source $TOP_DIR/lib/nova
4d601756
 source $TOP_DIR/lib/placement
995eb927
 source $TOP_DIR/lib/cinder
 source $TOP_DIR/lib/swift
2a242519
 source $TOP_DIR/lib/neutron
5a9739a4
 source $TOP_DIR/lib/neutron-legacy
53ffc713
 
e73f88e7
 set -o xtrace
995eb927
 
cdf3d766
 # 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
995eb927
 
eaadffe0
 # Let unstack.sh do its thing first
 $TOP_DIR/unstack.sh --all
995eb927
 
cdf3d766
 # Run extras
 # ==========
 
 # Phase: clean
e6843e5e
 load_plugin_settings
a1701fab
 run_phase clean
 
cdf3d766
 if [[ -d $TOP_DIR/extras.d ]]; then
     for i in $TOP_DIR/extras.d/*.sh; do
         [[ -r $i ]] && source $i clean
     done
 fi
 
995eb927
 # Clean projects
9a413abc
 
 # BUG: cinder tgt doesn't exit cleanly if it's not running.
 cleanup_cinder || /bin/true
 
995eb927
 cleanup_glance
 cleanup_keystone
 cleanup_nova
aa33c878
 cleanup_placement
b05c8769
 cleanup_neutron
995eb927
 cleanup_swift
5631ca5e
 cleanup_horizon
995eb927
 
b9e25135
 if is_service_enabled ldap; then
     cleanup_ldap
 fi
 
2aa2a89c
 # Do the hypervisor cleanup until this can be moved back into lib/nova
e4fa7213
 if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
2aa2a89c
     cleanup_nova_hypervisor
 fi
 
995eb927
 # Clean out /etc
8f985b6f
 sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/neutron /etc/openstack/
995eb927
 
 # Clean out tgt
53ffc713
 sudo rm -f /etc/tgt/conf.d/*
995eb927
 
 # Clean up the message queue
 cleanup_rpc_backend
 cleanup_database
 
93d09c24
 # Clean out data and status
 sudo rm -rf $DATA_DIR $DEST/status
 
 # Clean out the log file and log directories
 if [[ -n "$LOGFILE" ]] && [[ -f "$LOGFILE" ]]; then
     sudo rm -f $LOGFILE
 fi
 if [[ -n "$LOGDIR" ]] && [[ -d "$LOGDIR" ]]; then
     sudo rm -rf $LOGDIR
 fi
53ffc713
 
6808a346
 # Clean out the systemd unit files.
 sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete
 # Make systemd aware of the deletion.
 $SYSTEMCTL daemon-reload
15b0a5f1
 
b1d8e8e2
 # Clean up venvs
61045ca5
 DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]} .config/openstack"
b1d8e8e2
 rm -rf $DIRS_TO_CLEAN
 
995eb927
 # Clean up files
2e2b28b5
 
975f4209
 FILES_TO_CLEAN=".localrc.auto .localrc.password "
 FILES_TO_CLEAN+="docs/files docs/html shocco/ "
 FILES_TO_CLEAN+="stack-screenrc test*.conf* test.ini* "
0b4a009e
 FILES_TO_CLEAN+=".stackenv .prereqs"
2e2b28b5
 
cb415697
 for file in $FILES_TO_CLEAN; do
ecd05637
     rm -rf $TOP_DIR/$file
2e2b28b5
 done
0b4a009e
 
 rm -rf ~/.config/openstack
8f0e97c1
 
 # Clean up all *.pyc files
 if [[ -n "$DEST" ]] && [[ -d "$DEST" ]]; then
b612b628
     find_version=`find --version | awk '{ print $NF; exit}'`
     if vercmp "$find_version" "<" "4.2.3" ; then
         sudo find $DEST -name "*.pyc" -print0 | xargs -0 rm
     else
         sudo find $DEST -name "*.pyc" -delete
     fi
8f0e97c1
 fi