blob: b8b7f4a130059c20fec8d6b90bb6acf9a3f1d8ee [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#
Sean Dague53753292014-12-04 19:38:15 -05009# Stop all processes by setting ``UNSTACK_ALL`` or specifying ``-a``
Dean Troyerf4d23952012-03-28 11:19:24 -050010# on the command line
11
Sean Dague53753292014-12-04 19:38:15 -050012UNSTACK_ALL=""
13
14while getopts ":a" opt; do
15 case $opt in
16 a)
17 UNSTACK_ALL=""
18 ;;
19 esac
20done
21
Dean Troyerf4d23952012-03-28 11:19:24 -050022# Keep track of the current devstack directory.
23TOP_DIR=$(cd $(dirname "$0") && pwd)
Sean Dague53753292014-12-04 19:38:15 -050024FILES=$TOP_DIR/files
Dean Troyerf4d23952012-03-28 11:19:24 -050025
26# Import common functions
27source $TOP_DIR/functions
28
Terry Wilson428af5a2012-11-01 16:12:39 -040029# Import database library
30source $TOP_DIR/lib/database
31
Dean Troyerf4d23952012-03-28 11:19:24 -050032# Load local configuration
Sean Dague53753292014-12-04 19:38:15 -050033source $TOP_DIR/openrc
Dean Troyerf4d23952012-03-28 11:19:24 -050034
John Griffithd53bedc2012-09-11 14:15:54 -060035# Destination path for service data
36DATA_DIR=${DATA_DIR:-${DEST}/data}
37
Dean Troyer23f69d82013-10-04 12:35:24 -050038if [[ $EUID -eq 0 ]]; then
39 echo "You are running this script as root."
40 echo "It might work but you will have a better day running it as $STACK_USER"
41 exit 1
42fi
43
Brant Knudson0049c0c2014-01-16 18:16:48 -060044
45# Configure Projects
46# ==================
47
zhang-hared98a5d02013-06-21 18:18:02 +080048# Import apache functions
49source $TOP_DIR/lib/apache
50
Brant Knudson0049c0c2014-01-16 18:16:48 -060051# Import TLS functions
52source $TOP_DIR/lib/tls
53
54# Source project function libraries
55source $TOP_DIR/lib/infra
56source $TOP_DIR/lib/oslo
57source $TOP_DIR/lib/stackforge
Daniel Genind4708672014-10-31 15:01:29 -040058source $TOP_DIR/lib/lvm
Brant Knudson0049c0c2014-01-16 18:16:48 -060059source $TOP_DIR/lib/horizon
Dean Troyer9fc87922013-05-22 17:19:06 -050060source $TOP_DIR/lib/keystone
61source $TOP_DIR/lib/glance
62source $TOP_DIR/lib/nova
Brant Knudson0049c0c2014-01-16 18:16:48 -060063source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +010064source $TOP_DIR/lib/swift
Brant Knudson0049c0c2014-01-16 18:16:48 -060065source $TOP_DIR/lib/ceilometer
66source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040067source $TOP_DIR/lib/neutron
Brant Knudson0049c0c2014-01-16 18:16:48 -060068source $TOP_DIR/lib/ldap
Martin André48a75c12014-09-08 08:58:58 +000069source $TOP_DIR/lib/dstat
John Griffithd53bedc2012-09-11 14:15:54 -060070
Dean Troyercdf3d762013-10-15 09:42:43 -050071# Extras Source
72# --------------
73
74# Phase: source
75if [[ -d $TOP_DIR/extras.d ]]; then
76 for i in $TOP_DIR/extras.d/*.sh; do
77 [[ -r $i ]] && source $i source
78 done
79fi
80
Sean Dague2c65e712014-12-18 09:44:56 -050081load_plugin_settings
82
Dean Troyerf4d23952012-03-28 11:19:24 -050083# Determine what system we are running on. This provides ``os_VENDOR``,
84# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
85GetOSVersion
86
Dean Troyer768295e2013-01-09 13:42:03 -060087# Run extras
88# ==========
89
Dean Troyercdf3d762013-10-15 09:42:43 -050090# Phase: unstack
Sean Dague2c65e712014-12-18 09:44:56 -050091run_phase unstack
Dean Troyer768295e2013-01-09 13:42:03 -060092
Nachi Ueno8bc21f62012-11-19 22:04:28 -080093if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
94 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -040095 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080096fi
97
Dean Troyer9fc87922013-05-22 17:19:06 -050098# Call service stop
Dean Troyerf4d23952012-03-28 11:19:24 -050099
Dean Troyer9fc87922013-05-22 17:19:06 -0500100if is_service_enabled heat; then
101 stop_heat
102fi
103
104if is_service_enabled ceilometer; then
105 stop_ceilometer
106fi
107
108if is_service_enabled nova; then
109 stop_nova
110fi
111
Dean Troyere4fa7212014-01-15 15:04:49 -0600112if is_service_enabled glance; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500113 stop_glance
114fi
115
116if is_service_enabled key; then
117 stop_keystone
Dean Troyer2aa2a892013-08-04 19:53:19 -0500118fi
119
Dean Troyerf4d23952012-03-28 11:19:24 -0500120# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100121if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100122 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000123 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -0500124fi
125
126# Apache has the WSGI processes
127if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500128 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -0500129fi
130
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100131# Kill TLS proxies and cleanup certificates
Dean Troyerc83a7e12012-11-29 11:47:58 -0600132if is_service_enabled tls-proxy; then
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100133 stop_tls_proxy
134 cleanup_CA
Dean Troyerc83a7e12012-11-29 11:47:58 -0600135fi
136
John Griffithd53bedc2012-09-11 14:15:54 -0600137SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
138
Dean Troyerf4d23952012-03-28 11:19:24 -0500139# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -0800140if is_service_enabled cinder; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500141 stop_cinder
Sean Dague252f2f52012-12-20 16:41:57 -0500142 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -0500143fi
144
145if [[ -n "$UNSTACK_ALL" ]]; then
146 # Stop MySQL server
147 if is_service_enabled mysql; then
148 stop_service mysql
149 fi
Josh Kearney659eabf2012-09-06 13:47:06 -0500150
Terry Wilson428af5a2012-11-01 16:12:39 -0400151 if is_service_enabled postgresql; then
152 stop_service postgresql
153 fi
154
Josh Kearney659eabf2012-09-06 13:47:06 -0500155 # Stop rabbitmq-server
156 if is_service_enabled rabbit; then
157 stop_service rabbitmq-server
158 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500159fi
Gary Kotton722fe672012-07-18 07:43:01 -0400160
Mark McClainb05c8762013-07-06 23:29:39 -0400161if is_service_enabled neutron; then
162 stop_neutron
163 stop_neutron_third_party
164 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400165fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000166
Nikhil Manchanda0cccad42012-12-03 18:15:09 -0700167if is_service_enabled trove; then
168 cleanup_trove
169fi
170
Joe Gordone0b08d02014-08-20 00:34:55 -0700171stop_dstat
172
Dean Troyer9fc87922013-05-22 17:19:06 -0500173# Clean up the remainder of the screen processes
174SCREEN=$(which screen)
175if [[ -n "$SCREEN" ]]; then
176 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
177 if [[ -n "$SESSION" ]]; then
178 screen -X -S $SESSION quit
179 fi
180fi
Daniel Genind4708672014-10-31 15:01:29 -0400181
182clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME