blob: 465b304a173d913c364d44f5e024fc6138642b68 [file] [log] [blame]
Dean Troyer995eb922013-03-07 16:11:40 -06001#!/usr/bin/env bash
2
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
21source $TOP_DIR/stackrc
22
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``,
29# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
30# 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
43source $TOP_DIR/lib/oslo
Dean Troyer995eb922013-03-07 16:11:40 -060044source $TOP_DIR/lib/horizon
45source $TOP_DIR/lib/keystone
46source $TOP_DIR/lib/glance
47source $TOP_DIR/lib/nova
48source $TOP_DIR/lib/cinder
49source $TOP_DIR/lib/swift
50source $TOP_DIR/lib/ceilometer
51source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040052source $TOP_DIR/lib/neutron
Dean Troyer995eb922013-03-07 16:11:40 -060053source $TOP_DIR/lib/baremetal
Dean Troyer53ffc712013-12-17 11:13:40 -060054source $TOP_DIR/lib/ironic
55source $TOP_DIR/lib/trove
56
Dean Troyer995eb922013-03-07 16:11:40 -060057
Dean Troyercdf3d762013-10-15 09:42:43 -050058# Extras Source
59# --------------
60
61# Phase: source
62if [[ -d $TOP_DIR/extras.d ]]; then
63 for i in $TOP_DIR/extras.d/*.sh; do
64 [[ -r $i ]] && source $i source
65 done
66fi
Dean Troyer995eb922013-03-07 16:11:40 -060067
68# See if there is anything running...
69# need to adapt when run_service is merged
70SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
71if [[ -n "$SESSION" ]]; then
72 # Let unstack.sh do its thing first
73 $TOP_DIR/unstack.sh --all
74fi
75
Dean Troyercdf3d762013-10-15 09:42:43 -050076# Run extras
77# ==========
78
79# Phase: clean
80if [[ -d $TOP_DIR/extras.d ]]; then
81 for i in $TOP_DIR/extras.d/*.sh; do
82 [[ -r $i ]] && source $i clean
83 done
84fi
85
Dean Troyer995eb922013-03-07 16:11:40 -060086# Clean projects
Sean Daguedb5fadb2013-08-09 13:41:33 -040087cleanup_oslo
Dean Troyer995eb922013-03-07 16:11:40 -060088cleanup_cinder
89cleanup_glance
90cleanup_keystone
91cleanup_nova
Mark McClainb05c8762013-07-06 23:29:39 -040092cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060093cleanup_swift
94
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#if mount | grep $DATA_DIR/swift/drives; then
105# sudo umount $DATA_DIR/swift/drives/sdb1
106#fi
107
108
109# Clean out /etc
110sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift
111
112# Clean out tgt
Dean Troyer53ffc712013-12-17 11:13:40 -0600113sudo rm -f /etc/tgt/conf.d/*
Dean Troyer995eb922013-03-07 16:11:40 -0600114
115# Clean up the message queue
116cleanup_rpc_backend
117cleanup_database
118
Dean Troyer53ffc712013-12-17 11:13:40 -0600119# Clean out data, logs and status
120LOGDIR=$(dirname "$LOGFILE")
121sudo rm -rf $DATA_DIR $LOGDIR $DEST/status
122if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then
123 sudo rm -rf $SCREEN_LOGDIR
124fi
125
Dean Troyer995eb922013-03-07 16:11:40 -0600126# Clean up networking...
127# should this be in nova?
128# FIXED_IP_ADDR in br100
129
130# Clean up files
Sean Dague2e2b28b2014-02-19 09:02:02 -0500131
132FILES_TO_CLEAN=".localrc.auto docs-files docs/ shocco/ stack-screenrc test*.conf* test.ini*"
133FILES_TO_CLEAN+=".stackenv .prereqs"
134
135for file in FILES_TO_CLEAN; do
136 rm -f $TOP_DIR/$file
137done