blob: 1e80bf35c76d0c3b2d69359690d0fd60ab9cd946 [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
27# Get project function libraries
Devananda van der Veen7611c892012-11-23 10:54:54 -080028source $TOP_DIR/lib/baremetal
John Griffithd53bedc2012-09-11 14:15:54 -060029source $TOP_DIR/lib/cinder
Sean Dagueb562e6a2012-11-19 16:00:01 -050030source $TOP_DIR/lib/horizon
Attila Fazekasece6a332012-11-29 14:19:41 +010031source $TOP_DIR/lib/swift
Mark McClainb05c8762013-07-06 23:29:39 -040032source $TOP_DIR/lib/neutron
John Griffithd53bedc2012-09-11 14:15:54 -060033
Dean Troyerf4d23952012-03-28 11:19:24 -050034# Determine what system we are running on. This provides ``os_VENDOR``,
35# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
36GetOSVersion
37
38if [[ "$1" == "--all" ]]; then
39 UNSTACK_ALL=${UNSTACK_ALL:-1}
40fi
41
Dean Troyer768295e2013-01-09 13:42:03 -060042# Run extras
43# ==========
44
45if [[ -d $TOP_DIR/extras.d ]]; then
46 for i in $TOP_DIR/extras.d/*.sh; do
47 [[ -r $i ]] && source $i unstack
48 done
49fi
50
Nachi Ueno8bc21f62012-11-19 22:04:28 -080051if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
52 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -040053 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080054fi
55
Dean Troyerf4d23952012-03-28 11:19:24 -050056# Shut down devstack's screen to get the bulk of OpenStack services in one shot
Dean Troyereeaf2662012-06-14 09:11:38 -050057SCREEN=$(which screen)
58if [[ -n "$SCREEN" ]]; then
59 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
60 if [[ -n "$SESSION" ]]; then
61 screen -X -S $SESSION quit
62 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050063fi
64
65# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010066if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +010067 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +000068 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -050069fi
70
71# Apache has the WSGI processes
72if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -050073 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -050074fi
75
Dean Troyerc83a7e12012-11-29 11:47:58 -060076# Kill TLS proxies
77if is_service_enabled tls-proxy; then
78 killall stud
79fi
80
Devananda van der Veen7611c892012-11-23 10:54:54 -080081# baremetal might have created a fake environment
82if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
83 cleanup_fake_baremetal_env
84fi
85
John Griffithd53bedc2012-09-11 14:15:54 -060086SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
87
Dean Troyerf4d23952012-03-28 11:19:24 -050088# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -080089if is_service_enabled cinder; then
Sean Dague252f2f52012-12-20 16:41:57 -050090 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -050091fi
92
93if [[ -n "$UNSTACK_ALL" ]]; then
94 # Stop MySQL server
95 if is_service_enabled mysql; then
96 stop_service mysql
97 fi
Josh Kearney659eabf2012-09-06 13:47:06 -050098
Terry Wilson428af5a2012-11-01 16:12:39 -040099 if is_service_enabled postgresql; then
100 stop_service postgresql
101 fi
102
Josh Kearney659eabf2012-09-06 13:47:06 -0500103 # Stop rabbitmq-server
104 if is_service_enabled rabbit; then
105 stop_service rabbitmq-server
106 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500107fi
Gary Kotton722fe672012-07-18 07:43:01 -0400108
Mark McClainb05c8762013-07-06 23:29:39 -0400109if is_service_enabled neutron; then
110 stop_neutron
111 stop_neutron_third_party
112 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400113fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000114
115cleanup_tmp