blob: 092f557a88be8110c361272d7c875a73f8d849cb [file] [log] [blame]
Sean Dague9a413ab2015-02-04 12:44:18 -05001#!/bin/bash
Dean Troyer995eb922013-03-07 16:11:40 -06002
3# **clean.sh**
4
5# ``clean.sh`` does its best to eradicate traces of a Grenade
6# run except for the following:
7# - both base and target code repos are left alone
8# - packages (system and pip) are left alone
9
10# This means that all data files are removed. More??
11
12# Keep track of the current devstack directory.
13TOP_DIR=$(cd $(dirname "$0") && pwd)
14
15# Import common functions
16source $TOP_DIR/functions
17
Dean Troyerb9e25132013-10-01 14:45:04 -050018FILES=$TOP_DIR/files
19
Dean Troyer995eb922013-03-07 16:11:40 -060020# Load local configuration
Sean Dague53753292014-12-04 19:38:15 -050021source $TOP_DIR/openrc
Dean Troyer995eb922013-03-07 16:11:40 -060022
23# Get the variables that are set in stack.sh
Dean Troyer58f9cf72013-06-04 12:51:54 -050024if [[ -r $TOP_DIR/.stackenv ]]; then
25 source $TOP_DIR/.stackenv
26fi
Dean Troyer995eb922013-03-07 16:11:40 -060027
28# Determine what system we are running on. This provides ``os_VENDOR``,
Ian Wienand7710e7f2014-08-27 16:15:32 +100029# ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME``
Dean Troyer995eb922013-03-07 16:11:40 -060030# and ``DISTRO``
31GetDistro
32
Dean Troyer53ffc712013-12-17 11:13:40 -060033# Import apache functions
34source $TOP_DIR/lib/apache
35source $TOP_DIR/lib/ldap
Dean Troyer995eb922013-03-07 16:11:40 -060036
37# Import database library
38source $TOP_DIR/lib/database
39source $TOP_DIR/lib/rpc_backend
40
41source $TOP_DIR/lib/tls
Dean Troyer53ffc712013-12-17 11:13:40 -060042
Takashi Kajinamief63c692024-11-24 22:48:08 +090043source $TOP_DIR/lib/libraries
Mahito67168e82015-08-18 23:59:29 -070044source $TOP_DIR/lib/lvm
Dean Troyer995eb922013-03-07 16:11:40 -060045source $TOP_DIR/lib/horizon
46source $TOP_DIR/lib/keystone
47source $TOP_DIR/lib/glance
48source $TOP_DIR/lib/nova
Chris Dent4d601752016-07-12 19:34:09 +000049source $TOP_DIR/lib/placement
Dean Troyer995eb922013-03-07 16:11:40 -060050source $TOP_DIR/lib/cinder
51source $TOP_DIR/lib/swift
Sean M. Collins2a242512016-05-03 09:03:09 -040052source $TOP_DIR/lib/neutron
Dean Troyer53ffc712013-12-17 11:13:40 -060053
Sean Daguee73f88e2016-02-03 06:58:39 -050054set -o xtrace
Dean Troyer995eb922013-03-07 16:11:40 -060055
Dean Troyercdf3d762013-10-15 09:42:43 -050056# Extras Source
57# --------------
58
59# Phase: source
60if [[ -d $TOP_DIR/extras.d ]]; then
61 for i in $TOP_DIR/extras.d/*.sh; do
62 [[ -r $i ]] && source $i source
63 done
64fi
Dean Troyer995eb922013-03-07 16:11:40 -060065
Sean Dagueeaadffe2017-05-04 16:05:19 -040066# Let unstack.sh do its thing first
67$TOP_DIR/unstack.sh --all
Dean Troyer995eb922013-03-07 16:11:40 -060068
Dean Troyercdf3d762013-10-15 09:42:43 -050069# Run extras
70# ==========
71
72# Phase: clean
ajmillere6843e52015-04-11 09:52:48 -070073load_plugin_settings
Al Millera1701fa2015-02-20 08:10:41 -080074run_phase clean
75
Dean Troyercdf3d762013-10-15 09:42:43 -050076if [[ -d $TOP_DIR/extras.d ]]; then
77 for i in $TOP_DIR/extras.d/*.sh; do
78 [[ -r $i ]] && source $i clean
79 done
80fi
81
Dean Troyer995eb922013-03-07 16:11:40 -060082# Clean projects
Sean Dague9a413ab2015-02-04 12:44:18 -050083
84# BUG: cinder tgt doesn't exit cleanly if it's not running.
85cleanup_cinder || /bin/true
86
Dean Troyer995eb922013-03-07 16:11:40 -060087cleanup_glance
88cleanup_keystone
89cleanup_nova
Davanum Srinivasaa33c872017-08-16 22:51:07 -040090cleanup_placement
Mark McClainb05c8762013-07-06 23:29:39 -040091cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060092cleanup_swift
Rob Crittenden5631ca52016-08-02 13:19:14 -040093cleanup_horizon
Dean Troyer995eb922013-03-07 16:11:40 -060094
Dean Troyerb9e25132013-10-01 14:45:04 -050095if is_service_enabled ldap; then
96 cleanup_ldap
97fi
98
Dean Troyer2aa2a892013-08-04 19:53:19 -050099# Do the hypervisor cleanup until this can be moved back into lib/nova
Dean Troyere4fa7212014-01-15 15:04:49 -0600100if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
Dean Troyer2aa2a892013-08-04 19:53:19 -0500101 cleanup_nova_hypervisor
102fi
103
Dean Troyer995eb922013-03-07 16:11:40 -0600104# Clean out /etc
xiaolihope8f985b62016-05-18 00:32:08 +0800105sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/neutron /etc/openstack/
Dean Troyer995eb922013-03-07 16:11:40 -0600106
107# Clean out tgt
Dean Troyer53ffc712013-12-17 11:13:40 -0600108sudo rm -f /etc/tgt/conf.d/*
Dean Troyer995eb922013-03-07 16:11:40 -0600109
110# Clean up the message queue
111cleanup_rpc_backend
112cleanup_database
113
Davanum Srinivas93d09c22015-04-11 18:45:09 -0400114# Clean out data and status
Dan Smith30d9bf92021-01-19 12:10:52 -0800115sudo rm -rf $DATA_DIR $DEST/status $DEST/async
Davanum Srinivas93d09c22015-04-11 18:45:09 -0400116
117# Clean out the log file and log directories
118if [[ -n "$LOGFILE" ]] && [[ -f "$LOGFILE" ]]; then
119 sudo rm -f $LOGFILE
120fi
121if [[ -n "$LOGDIR" ]] && [[ -d "$LOGDIR" ]]; then
122 sudo rm -rf $LOGDIR
123fi
Dean Troyer53ffc712013-12-17 11:13:40 -0600124
Dr. Jens Harbott6808a342020-01-20 15:52:33 +0000125# Clean out the systemd unit files.
126sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete
127# Make systemd aware of the deletion.
128$SYSTEMCTL daemon-reload
Markus Zoeller15b0a5f2017-05-31 11:21:22 +0200129
Dean Troyerb1d8e8e2015-02-16 13:58:35 -0600130# Clean up venvs
Monty Taylor61045ca2015-05-14 11:20:39 -0400131DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]} .config/openstack"
Dean Troyerb1d8e8e2015-02-16 13:58:35 -0600132rm -rf $DIRS_TO_CLEAN
133
Dean Troyer995eb922013-03-07 16:11:40 -0600134# Clean up files
Sean Dague2e2b28b2014-02-19 09:02:02 -0500135
Ian Wienand975f4202015-10-14 15:12:32 +1100136FILES_TO_CLEAN=".localrc.auto .localrc.password "
137FILES_TO_CLEAN+="docs/files docs/html shocco/ "
138FILES_TO_CLEAN+="stack-screenrc test*.conf* test.ini* "
ZhiQiang Fan0b4a0092016-04-12 20:26:33 +0800139FILES_TO_CLEAN+=".stackenv .prereqs"
Sean Dague2e2b28b2014-02-19 09:02:02 -0500140
Shashank Hegdecb415692014-02-27 16:46:43 -0800141for file in $FILES_TO_CLEAN; do
ZhiQiang Fanecd05632014-06-28 16:50:22 +0800142 rm -rf $TOP_DIR/$file
Sean Dague2e2b28b2014-02-19 09:02:02 -0500143done
ZhiQiang Fan0b4a0092016-04-12 20:26:33 +0800144
145rm -rf ~/.config/openstack
WenyanZhang8f0e97c2016-07-07 18:57:32 +0800146
Dan Smith6766f712020-07-24 15:44:34 -0700147# Clear any fstab entries made
148sudo sed -i '/.*comment=devstack-.*/ d' /etc/fstab