blob: 480a81214f9c199c64d4872a50ab62119b382a3e [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
33
34# Import database library
35source $TOP_DIR/lib/database
36source $TOP_DIR/lib/rpc_backend
37
Sean Dagued02287e2013-09-11 14:08:59 -040038source $TOP_DIR/lib/oslo
Dean Troyer995eb922013-03-07 16:11:40 -060039source $TOP_DIR/lib/tls
40source $TOP_DIR/lib/horizon
41source $TOP_DIR/lib/keystone
42source $TOP_DIR/lib/glance
43source $TOP_DIR/lib/nova
44source $TOP_DIR/lib/cinder
45source $TOP_DIR/lib/swift
46source $TOP_DIR/lib/ceilometer
47source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040048source $TOP_DIR/lib/neutron
Dean Troyer995eb922013-03-07 16:11:40 -060049source $TOP_DIR/lib/baremetal
50source $TOP_DIR/lib/ldap
51
Dean Troyercdf3d762013-10-15 09:42:43 -050052# Extras Source
53# --------------
54
55# Phase: source
56if [[ -d $TOP_DIR/extras.d ]]; then
57 for i in $TOP_DIR/extras.d/*.sh; do
58 [[ -r $i ]] && source $i source
59 done
60fi
Dean Troyer995eb922013-03-07 16:11:40 -060061
62# See if there is anything running...
63# need to adapt when run_service is merged
64SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
65if [[ -n "$SESSION" ]]; then
66 # Let unstack.sh do its thing first
67 $TOP_DIR/unstack.sh --all
68fi
69
Dean Troyercdf3d762013-10-15 09:42:43 -050070# Run extras
71# ==========
72
73# Phase: clean
74if [[ -d $TOP_DIR/extras.d ]]; then
75 for i in $TOP_DIR/extras.d/*.sh; do
76 [[ -r $i ]] && source $i clean
77 done
78fi
79
Dean Troyer995eb922013-03-07 16:11:40 -060080# Clean projects
Sean Daguedb5fadb2013-08-09 13:41:33 -040081cleanup_oslo
Dean Troyer995eb922013-03-07 16:11:40 -060082cleanup_cinder
83cleanup_glance
84cleanup_keystone
85cleanup_nova
Mark McClainb05c8762013-07-06 23:29:39 -040086cleanup_neutron
Dean Troyer995eb922013-03-07 16:11:40 -060087cleanup_swift
88
Dean Troyerb9e25132013-10-01 14:45:04 -050089if is_service_enabled ldap; then
90 cleanup_ldap
91fi
92
Dean Troyer2aa2a892013-08-04 19:53:19 -050093# Do the hypervisor cleanup until this can be moved back into lib/nova
94if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
95 cleanup_nova_hypervisor
96fi
97
JordanP51c90b82013-05-23 10:27:51 +020098# cinder doesn't always clean up the volume group as it might be used elsewhere...
Dean Troyer995eb922013-03-07 16:11:40 -060099# clean it up if it is a loop device
100VG_DEV=$(sudo losetup -j $DATA_DIR/${VOLUME_GROUP}-backing-file | awk -F':' '/backing-file/ { print $1}')
101if [[ -n "$VG_DEV" ]]; then
102 sudo losetup -d $VG_DEV
103fi
104
105#if mount | grep $DATA_DIR/swift/drives; then
106# sudo umount $DATA_DIR/swift/drives/sdb1
107#fi
108
109
110# Clean out /etc
111sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift
112
113# Clean out tgt
114sudo rm /etc/tgt/conf.d/*
115
116# Clean up the message queue
117cleanup_rpc_backend
118cleanup_database
119
120# Clean up networking...
121# should this be in nova?
122# FIXED_IP_ADDR in br100
123
124# Clean up files
Dean Troyer58f9cf72013-06-04 12:51:54 -0500125rm -f $TOP_DIR/.stackenv