blob: 05d9fb7c836d8b50b71763b1f8f4810881db3afe [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
zhang-hared98a5d02013-06-21 18:18:02 +080027# Import apache functions
28source $TOP_DIR/lib/apache
29
John Griffithd53bedc2012-09-11 14:15:54 -060030# Get project function libraries
Devananda van der Veen7611c892012-11-23 10:54:54 -080031source $TOP_DIR/lib/baremetal
John Griffithd53bedc2012-09-11 14:15:54 -060032source $TOP_DIR/lib/cinder
Sean Dagueb562e6a2012-11-19 16:00:01 -050033source $TOP_DIR/lib/horizon
Attila Fazekasece6a332012-11-29 14:19:41 +010034source $TOP_DIR/lib/swift
Mark McClainb05c8762013-07-06 23:29:39 -040035source $TOP_DIR/lib/neutron
Roman Prykhodchenkoce696b62013-08-09 10:40:45 +030036source $TOP_DIR/lib/ironic
Nikhil Manchanda0cccad42012-12-03 18:15:09 -070037source $TOP_DIR/lib/trove
John Griffithd53bedc2012-09-11 14:15:54 -060038
Dean Troyerf4d23952012-03-28 11:19:24 -050039# Determine what system we are running on. This provides ``os_VENDOR``,
40# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
41GetOSVersion
42
43if [[ "$1" == "--all" ]]; then
44 UNSTACK_ALL=${UNSTACK_ALL:-1}
45fi
46
Dean Troyer768295e2013-01-09 13:42:03 -060047# Run extras
48# ==========
49
50if [[ -d $TOP_DIR/extras.d ]]; then
51 for i in $TOP_DIR/extras.d/*.sh; do
52 [[ -r $i ]] && source $i unstack
53 done
54fi
55
Nachi Ueno8bc21f62012-11-19 22:04:28 -080056if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
57 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -040058 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080059fi
60
Dean Troyerf4d23952012-03-28 11:19:24 -050061# Shut down devstack's screen to get the bulk of OpenStack services in one shot
Dean Troyereeaf2662012-06-14 09:11:38 -050062SCREEN=$(which screen)
63if [[ -n "$SCREEN" ]]; then
64 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
65 if [[ -n "$SESSION" ]]; then
66 screen -X -S $SESSION quit
67 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050068fi
69
Dean Troyer2aa2a892013-08-04 19:53:19 -050070# Shut down Nova hypervisor plugins after Nova
71NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins
72if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
73 # Load plugin
74 source $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER
75 stop_nova_hypervisor
76fi
77
Dean Troyerf4d23952012-03-28 11:19:24 -050078# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010079if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +010080 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +000081 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -050082fi
83
Roman Prykhodchenkoce696b62013-08-09 10:40:45 +030084# Ironic runs daemons
85if is_service_enabled ir-api ir-cond; then
86 stop_ironic
87 cleanup_ironic
88fi
89
Dean Troyerf4d23952012-03-28 11:19:24 -050090# Apache has the WSGI processes
91if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -050092 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -050093fi
94
Dean Troyerc83a7e12012-11-29 11:47:58 -060095# Kill TLS proxies
96if is_service_enabled tls-proxy; then
97 killall stud
98fi
99
Devananda van der Veen7611c892012-11-23 10:54:54 -0800100# baremetal might have created a fake environment
101if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
102 cleanup_fake_baremetal_env
103fi
104
John Griffithd53bedc2012-09-11 14:15:54 -0600105SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
106
Dean Troyerf4d23952012-03-28 11:19:24 -0500107# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -0800108if is_service_enabled cinder; then
Sean Dague252f2f52012-12-20 16:41:57 -0500109 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -0500110fi
111
112if [[ -n "$UNSTACK_ALL" ]]; then
113 # Stop MySQL server
114 if is_service_enabled mysql; then
115 stop_service mysql
116 fi
Josh Kearney659eabf2012-09-06 13:47:06 -0500117
Terry Wilson428af5a2012-11-01 16:12:39 -0400118 if is_service_enabled postgresql; then
119 stop_service postgresql
120 fi
121
Josh Kearney659eabf2012-09-06 13:47:06 -0500122 # Stop rabbitmq-server
123 if is_service_enabled rabbit; then
124 stop_service rabbitmq-server
125 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500126fi
Gary Kotton722fe672012-07-18 07:43:01 -0400127
Mark McClainb05c8762013-07-06 23:29:39 -0400128if is_service_enabled neutron; then
129 stop_neutron
130 stop_neutron_third_party
131 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400132fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000133
Nikhil Manchanda0cccad42012-12-03 18:15:09 -0700134if is_service_enabled trove; then
135 cleanup_trove
136fi
137
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000138cleanup_tmp