blob: d93b8353db45631de9bde850705e74aaf79cdbff [file] [log] [blame]
Sean Dague9a413ab2015-02-04 12:44:18 -05001#!/bin/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
Mike Chester8040e692016-02-17 10:52:33 -080012UNSTACK_ALL=${UNSTACK_ALL:-""}
Sean Dague53753292014-12-04 19:38:15 -050013
14while getopts ":a" opt; do
15 case $opt in
16 a)
Mike Chester8040e692016-02-17 10:52:33 -080017 UNSTACK_ALL="-1"
Sean Dague53753292014-12-04 19:38:15 -050018 ;;
19 esac
20done
21
Dean Troyerdc97cb72015-03-28 08:20:50 -050022# Keep track of the current DevStack directory.
Dean Troyerf4d23952012-03-28 11:19:24 -050023TOP_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
Wei Jiangangbe65c6f2015-09-14 18:52:47 +080048# Plugin Phase 0: override_defaults - allow plugins to override
Sean Dague6e275e12015-03-26 05:54:28 -040049# defaults before other services are run
50run_phase override_defaults
51
zhang-hared98a5d02013-06-21 18:18:02 +080052# Import apache functions
53source $TOP_DIR/lib/apache
54
Brant Knudson0049c0c2014-01-16 18:16:48 -060055# Import TLS functions
56source $TOP_DIR/lib/tls
57
58# Source project function libraries
59source $TOP_DIR/lib/infra
60source $TOP_DIR/lib/oslo
Daniel Genind4708672014-10-31 15:01:29 -040061source $TOP_DIR/lib/lvm
Brant Knudson0049c0c2014-01-16 18:16:48 -060062source $TOP_DIR/lib/horizon
Dean Troyer9fc87922013-05-22 17:19:06 -050063source $TOP_DIR/lib/keystone
64source $TOP_DIR/lib/glance
65source $TOP_DIR/lib/nova
Chris Dent4d601752016-07-12 19:34:09 +000066source $TOP_DIR/lib/placement
Brant Knudson0049c0c2014-01-16 18:16:48 -060067source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +010068source $TOP_DIR/lib/swift
Brant Knudson0049c0c2014-01-16 18:16:48 -060069source $TOP_DIR/lib/heat
Sean M. Collins2a242512016-05-03 09:03:09 -040070source $TOP_DIR/lib/neutron
Dean Troyer5a9739a2015-03-25 11:33:51 -050071source $TOP_DIR/lib/neutron-legacy
Brant Knudson0049c0c2014-01-16 18:16:48 -060072source $TOP_DIR/lib/ldap
Martin André48a75c12014-09-08 08:58:58 +000073source $TOP_DIR/lib/dstat
Sean Dague5cad4d32015-11-10 14:39:07 -050074source $TOP_DIR/lib/dlm
John Griffithd53bedc2012-09-11 14:15:54 -060075
Dean Troyercdf3d762013-10-15 09:42:43 -050076# Extras Source
77# --------------
78
79# Phase: source
80if [[ -d $TOP_DIR/extras.d ]]; then
81 for i in $TOP_DIR/extras.d/*.sh; do
82 [[ -r $i ]] && source $i source
83 done
84fi
85
Sean Dague2c65e712014-12-18 09:44:56 -050086load_plugin_settings
87
Dean Troyerf4d23952012-03-28 11:19:24 -050088# Determine what system we are running on. This provides ``os_VENDOR``,
Ian Wienand7710e7f2014-08-27 16:15:32 +100089# ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME``
Dean Troyerf4d23952012-03-28 11:19:24 -050090GetOSVersion
91
Sean Daguee73f88e2016-02-03 06:58:39 -050092set -o xtrace
93
Dean Troyer768295e2013-01-09 13:42:03 -060094# Run extras
95# ==========
96
Dean Troyercdf3d762013-10-15 09:42:43 -050097# Phase: unstack
Sean Dague2c65e712014-12-18 09:44:56 -050098run_phase unstack
Dean Troyer768295e2013-01-09 13:42:03 -060099
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800100if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
101 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -0400102 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800103fi
104
Dean Troyer9fc87922013-05-22 17:19:06 -0500105# Call service stop
Dean Troyerf4d23952012-03-28 11:19:24 -0500106
Dean Troyer9fc87922013-05-22 17:19:06 -0500107if is_service_enabled heat; then
108 stop_heat
109fi
110
Dean Troyer9fc87922013-05-22 17:19:06 -0500111if is_service_enabled nova; then
112 stop_nova
113fi
114
Chris Dent4d601752016-07-12 19:34:09 +0000115if is_service_enabled placement; then
116 stop_placement
117fi
118
Dean Troyere4fa7212014-01-15 15:04:49 -0600119if is_service_enabled glance; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500120 stop_glance
121fi
122
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600123if is_service_enabled keystone; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500124 stop_keystone
Dean Troyer2aa2a892013-08-04 19:53:19 -0500125fi
126
Dean Troyerf4d23952012-03-28 11:19:24 -0500127# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100128if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100129 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000130 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -0500131fi
132
133# Apache has the WSGI processes
134if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500135 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -0500136fi
137
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100138# Kill TLS proxies and cleanup certificates
Dean Troyerc83a7e12012-11-29 11:47:58 -0600139if is_service_enabled tls-proxy; then
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100140 stop_tls_proxy
141 cleanup_CA
Dean Troyerc83a7e12012-11-29 11:47:58 -0600142fi
Rob Crittendenebcb8492015-02-10 14:16:56 -0500143if [ "$USE_SSL" == "True" ]; then
144 cleanup_CA
145fi
Dean Troyerc83a7e12012-11-29 11:47:58 -0600146
John Griffithd53bedc2012-09-11 14:15:54 -0600147SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
148
Sean Dague9a413ab2015-02-04 12:44:18 -0500149# BUG: tgt likes to exit 1 on service stop if everything isn't
150# perfect, we should clean up cinder stop paths.
151
Dean Troyerf4d23952012-03-28 11:19:24 -0500152# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -0800153if is_service_enabled cinder; then
Sean Dague9a413ab2015-02-04 12:44:18 -0500154 stop_cinder || /bin/true
155 cleanup_cinder || /bin/true
Dean Troyerf4d23952012-03-28 11:19:24 -0500156fi
157
158if [[ -n "$UNSTACK_ALL" ]]; then
159 # Stop MySQL server
160 if is_service_enabled mysql; then
161 stop_service mysql
162 fi
Josh Kearney659eabf2012-09-06 13:47:06 -0500163
Terry Wilson428af5a2012-11-01 16:12:39 -0400164 if is_service_enabled postgresql; then
165 stop_service postgresql
166 fi
167
Josh Kearney659eabf2012-09-06 13:47:06 -0500168 # Stop rabbitmq-server
169 if is_service_enabled rabbit; then
170 stop_service rabbitmq-server
171 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500172fi
Gary Kotton722fe672012-07-18 07:43:01 -0400173
Mark McClainb05c8762013-07-06 23:29:39 -0400174if is_service_enabled neutron; then
175 stop_neutron
Mark McClainb05c8762013-07-06 23:29:39 -0400176 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400177fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000178
Mahito OGURAa519f422015-03-23 15:19:57 +0900179if is_service_enabled dstat; then
180 stop_dstat
181fi
Joe Gordone0b08d02014-08-20 00:34:55 -0700182
Dean Troyer9fc87922013-05-22 17:19:06 -0500183# Clean up the remainder of the screen processes
184SCREEN=$(which screen)
185if [[ -n "$SCREEN" ]]; then
Nikolay Fedotov7f665032016-02-24 16:07:18 +0000186 SESSION=$(screen -ls | awk "/[0-9]+.${SCREEN_NAME}/"'{ print $1 }')
Dean Troyer9fc87922013-05-22 17:19:06 -0500187 if [[ -n "$SESSION" ]]; then
188 screen -X -S $SESSION quit
189 fi
190fi
Daniel Genind4708672014-10-31 15:01:29 -0400191
Sean Dague9a413ab2015-02-04 12:44:18 -0500192# BUG: maybe it doesn't exist? We should isolate this further down.
Jordan Pittier23bf0452015-05-29 11:38:22 +0200193# NOTE: Cinder automatically installs the lvm2 package, independently of the
194# enabled backends. So if Cinder is enabled, we are sure lvm (lvremove,
195# /etc/lvm/lvm.conf, etc.) is here.
196if is_service_enabled cinder; then
197 clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME || /bin/true
198 clean_lvm_filter
199fi