blob: 31f6f01c8f62ef60f32d9db6bf46d2ac47968aad [file] [log] [blame]
Dean Troyerf4d23952012-03-28 11:19:24 -05001#!/usr/bin/env bash
Dean Troyer7d28a0e2012-06-27 17:55:52 -05002
3# **unstack.sh**
4
Dean Troyerf4d23952012-03-28 11:19:24 -05005# Stops that which is started by ``stack.sh`` (mostly)
6# mysql and rabbit are left running as OpenStack code refreshes
7# do not require them to be restarted.
8#
Dean Troyer4a43b7b2012-08-28 17:43:40 -05009# Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all``
Dean Troyerf4d23952012-03-28 11:19:24 -050010# on the command line
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
Terry Wilson428af5a2012-11-01 16:12:39 -040018# Import database library
19source $TOP_DIR/lib/database
20
Dean Troyerf4d23952012-03-28 11:19:24 -050021# Load local configuration
22source $TOP_DIR/stackrc
23
John Griffithd53bedc2012-09-11 14:15:54 -060024# Destination path for service data
25DATA_DIR=${DATA_DIR:-${DEST}/data}
26
Dean Troyer23f69d82013-10-04 12:35:24 -050027if [[ $EUID -eq 0 ]]; then
28 echo "You are running this script as root."
29 echo "It might work but you will have a better day running it as $STACK_USER"
30 exit 1
31fi
32
Brant Knudson0049c0c2014-01-16 18:16:48 -060033
34# Configure Projects
35# ==================
36
zhang-hared98a5d02013-06-21 18:18:02 +080037# Import apache functions
38source $TOP_DIR/lib/apache
39
Brant Knudson0049c0c2014-01-16 18:16:48 -060040# Import TLS functions
41source $TOP_DIR/lib/tls
42
43# Source project function libraries
44source $TOP_DIR/lib/infra
45source $TOP_DIR/lib/oslo
46source $TOP_DIR/lib/stackforge
47source $TOP_DIR/lib/horizon
Dean Troyer9fc87922013-05-22 17:19:06 -050048source $TOP_DIR/lib/keystone
49source $TOP_DIR/lib/glance
50source $TOP_DIR/lib/nova
Brant Knudson0049c0c2014-01-16 18:16:48 -060051source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +010052source $TOP_DIR/lib/swift
Brant Knudson0049c0c2014-01-16 18:16:48 -060053source $TOP_DIR/lib/ceilometer
54source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040055source $TOP_DIR/lib/neutron
Brant Knudson0049c0c2014-01-16 18:16:48 -060056source $TOP_DIR/lib/baremetal
57source $TOP_DIR/lib/ldap
Roman Prykhodchenkoce696b62013-08-09 10:40:45 +030058source $TOP_DIR/lib/ironic
Nikhil Manchanda0cccad42012-12-03 18:15:09 -070059source $TOP_DIR/lib/trove
John Griffithd53bedc2012-09-11 14:15:54 -060060
Dean Troyercdf3d762013-10-15 09:42:43 -050061# Extras Source
62# --------------
63
64# Phase: source
65if [[ -d $TOP_DIR/extras.d ]]; then
66 for i in $TOP_DIR/extras.d/*.sh; do
67 [[ -r $i ]] && source $i source
68 done
69fi
70
Dean Troyerf4d23952012-03-28 11:19:24 -050071# Determine what system we are running on. This provides ``os_VENDOR``,
72# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
73GetOSVersion
74
75if [[ "$1" == "--all" ]]; then
76 UNSTACK_ALL=${UNSTACK_ALL:-1}
77fi
78
Dean Troyer768295e2013-01-09 13:42:03 -060079# Run extras
80# ==========
81
Dean Troyercdf3d762013-10-15 09:42:43 -050082# Phase: unstack
Dean Troyer768295e2013-01-09 13:42:03 -060083if [[ -d $TOP_DIR/extras.d ]]; then
84 for i in $TOP_DIR/extras.d/*.sh; do
85 [[ -r $i ]] && source $i unstack
86 done
87fi
88
Nachi Ueno8bc21f62012-11-19 22:04:28 -080089if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
90 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -040091 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080092fi
93
Dean Troyer9fc87922013-05-22 17:19:06 -050094# Call service stop
95if is_service_enabled trove; then
96 stop_trove
Dean Troyerf4d23952012-03-28 11:19:24 -050097fi
98
Dean Troyer9fc87922013-05-22 17:19:06 -050099if is_service_enabled heat; then
100 stop_heat
101fi
102
103if is_service_enabled ceilometer; then
104 stop_ceilometer
105fi
106
107if is_service_enabled nova; then
108 stop_nova
109fi
110
111if is_service_enabled g-api g-reg; then
112 stop_glance
113fi
114
115if is_service_enabled key; then
116 stop_keystone
Dean Troyer2aa2a892013-08-04 19:53:19 -0500117fi
118
Dean Troyerf4d23952012-03-28 11:19:24 -0500119# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100120if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100121 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000122 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -0500123fi
124
Roman Prykhodchenkoce696b62013-08-09 10:40:45 +0300125# Ironic runs daemons
126if is_service_enabled ir-api ir-cond; then
127 stop_ironic
128 cleanup_ironic
129fi
130
Dean Troyerf4d23952012-03-28 11:19:24 -0500131# Apache has the WSGI processes
132if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500133 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -0500134fi
135
Dean Troyerc83a7e12012-11-29 11:47:58 -0600136# Kill TLS proxies
137if is_service_enabled tls-proxy; then
138 killall stud
139fi
140
Devananda van der Veen7611c892012-11-23 10:54:54 -0800141# baremetal might have created a fake environment
142if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
143 cleanup_fake_baremetal_env
144fi
145
John Griffithd53bedc2012-09-11 14:15:54 -0600146SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
147
Dean Troyerf4d23952012-03-28 11:19:24 -0500148# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -0800149if is_service_enabled cinder; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500150 stop_cinder
Sean Dague252f2f52012-12-20 16:41:57 -0500151 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -0500152fi
153
154if [[ -n "$UNSTACK_ALL" ]]; then
155 # Stop MySQL server
156 if is_service_enabled mysql; then
157 stop_service mysql
158 fi
Josh Kearney659eabf2012-09-06 13:47:06 -0500159
Terry Wilson428af5a2012-11-01 16:12:39 -0400160 if is_service_enabled postgresql; then
161 stop_service postgresql
162 fi
163
Josh Kearney659eabf2012-09-06 13:47:06 -0500164 # Stop rabbitmq-server
165 if is_service_enabled rabbit; then
166 stop_service rabbitmq-server
167 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500168fi
Gary Kotton722fe672012-07-18 07:43:01 -0400169
Mark McClainb05c8762013-07-06 23:29:39 -0400170if is_service_enabled neutron; then
171 stop_neutron
172 stop_neutron_third_party
173 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400174fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000175
Nikhil Manchanda0cccad42012-12-03 18:15:09 -0700176if is_service_enabled trove; then
177 cleanup_trove
178fi
179
Dean Troyer9fc87922013-05-22 17:19:06 -0500180# Clean up the remainder of the screen processes
181SCREEN=$(which screen)
182if [[ -n "$SCREEN" ]]; then
183 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
184 if [[ -n "$SESSION" ]]; then
185 screen -X -S $SESSION quit
186 fi
187fi
188
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000189cleanup_tmp