blob: 395941ae21a07bebf073467f2c4451c15d9d305f [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
18# Load local configuration
19source $TOP_DIR/stackrc
20
21# Get the variables that are set in stack.sh
Dean Troyer58f9cf72013-06-04 12:51:54 -050022if [[ -r $TOP_DIR/.stackenv ]]; then
23 source $TOP_DIR/.stackenv
24fi
Dean Troyer995eb922013-03-07 16:11:40 -060025
26# Determine what system we are running on. This provides ``os_VENDOR``,
27# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
28# and ``DISTRO``
29GetDistro
30
31
32# Import database library
33source $TOP_DIR/lib/database
34source $TOP_DIR/lib/rpc_backend
35
Sean Dagued02287e2013-09-11 14:08:59 -040036source $TOP_DIR/lib/oslo
Dean Troyer995eb922013-03-07 16:11:40 -060037source $TOP_DIR/lib/tls
38source $TOP_DIR/lib/horizon
39source $TOP_DIR/lib/keystone
40source $TOP_DIR/lib/glance
41source $TOP_DIR/lib/nova
42source $TOP_DIR/lib/cinder
43source $TOP_DIR/lib/swift
44source $TOP_DIR/lib/ceilometer
45source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040046source $TOP_DIR/lib/neutron
Dean Troyer995eb922013-03-07 16:11:40 -060047source $TOP_DIR/lib/baremetal
48source $TOP_DIR/lib/ldap
49
Dean Troyercdf3d762013-10-15 09:42:43 -050050# Extras Source
51# --------------
52
53# Phase: source
54if [[ -d $TOP_DIR/extras.d ]]; then
55 for i in $TOP_DIR/extras.d/*.sh; do
56 [[ -r $i ]] && source $i source
57 done
58fi
Dean Troyer995eb922013-03-07 16:11:40 -060059
60# See if there is anything running...
61# need to adapt when run_service is merged
62SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
63if [[ -n "$SESSION" ]]; then
64 # Let unstack.sh do its thing first
65 $TOP_DIR/unstack.sh --all
66fi
67
Dean Troyercdf3d762013-10-15 09:42:43 -050068# Run extras
69# ==========
70
71# Phase: clean
72if [[ -d $TOP_DIR/extras.d ]]; then
73 for i in $TOP_DIR/extras.d/*.sh; do
74 [[ -r $i ]] && source $i clean
75 done
76fi
77
Dean Troyer995eb922013-03-07 16:11:40 -060078# Clean projects
Sean Daguedb5fadb2013-08-09 13:41:33 -040079cleanup_oslo
Dean Troyer995eb922013-03-07 16:11:40 -060080cleanup_cinder
81cleanup_glance
82cleanup_keystone
83cleanup_nova
Mark McClainb05c8762013-07-06 23:29:39 -040084cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060085cleanup_swift
86
Dean Troyer2aa2a892013-08-04 19:53:19 -050087# Do the hypervisor cleanup until this can be moved back into lib/nova
88if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
89 cleanup_nova_hypervisor
90fi
91
JordanP51c90b82013-05-23 10:27:51 +020092# cinder doesn't always clean up the volume group as it might be used elsewhere...
Dean Troyer995eb922013-03-07 16:11:40 -060093# clean it up if it is a loop device
94VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}')
95if [[ -n "$VG_DEV" ]]; then
96 sudo losetup -d $VG_DEV
97fi
98
99#if mount | grep $DATA_DIR/swift/drives; then
100# sudo umount $DATA_DIR/swift/drives/sdb1
101#fi
102
103
104# Clean out /etc
105sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift
106
107# Clean out tgt
108sudo rm /etc/tgt/conf.d/*
109
110# Clean up the message queue
111cleanup_rpc_backend
112cleanup_database
113
114# Clean up networking...
115# should this be in nova?
116# FIXED_IP_ADDR in br100
117
118# Clean up files
Dean Troyer58f9cf72013-06-04 12:51:54 -0500119rm -f $TOP_DIR/.stackenv