blob: 6ceb5a493381f3cdf6b93bb3b088c27ed608ff6c [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
50
51# See if there is anything running...
52# need to adapt when run_service is merged
53SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
54if [[ -n "$SESSION" ]]; then
55 # Let unstack.sh do its thing first
56 $TOP_DIR/unstack.sh --all
57fi
58
59# Clean projects
Sean Daguedb5fadb2013-08-09 13:41:33 -040060cleanup_oslo
Dean Troyer995eb922013-03-07 16:11:40 -060061cleanup_cinder
62cleanup_glance
63cleanup_keystone
64cleanup_nova
Mark McClainb05c8762013-07-06 23:29:39 -040065cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060066cleanup_swift
67
Dean Troyer2aa2a892013-08-04 19:53:19 -050068# Do the hypervisor cleanup until this can be moved back into lib/nova
69if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
70 cleanup_nova_hypervisor
71fi
72
JordanP51c90b82013-05-23 10:27:51 +020073# cinder doesn't always clean up the volume group as it might be used elsewhere...
Dean Troyer995eb922013-03-07 16:11:40 -060074# clean it up if it is a loop device
75VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}')
76if [[ -n "$VG_DEV" ]]; then
77 sudo losetup -d $VG_DEV
78fi
79
80#if mount | grep $DATA_DIR/swift/drives; then
81# sudo umount $DATA_DIR/swift/drives/sdb1
82#fi
83
84
85# Clean out /etc
86sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift
87
88# Clean out tgt
89sudo rm /etc/tgt/conf.d/*
90
91# Clean up the message queue
92cleanup_rpc_backend
93cleanup_database
94
95# Clean up networking...
96# should this be in nova?
97# FIXED_IP_ADDR in br100
98
99# Clean up files
Dean Troyer58f9cf72013-06-04 12:51:54 -0500100rm -f $TOP_DIR/.stackenv