Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2 | |
| 3 | # **unstack.sh** |
| 4 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 5 | # 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 Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 9 | # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all`` |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 10 | # on the command line |
| 11 | |
| 12 | # Keep track of the current devstack directory. |
| 13 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 14 | |
| 15 | # Import common functions |
| 16 | source $TOP_DIR/functions |
| 17 | |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 18 | # Import database library |
| 19 | source $TOP_DIR/lib/database |
| 20 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 21 | # Load local configuration |
| 22 | source $TOP_DIR/stackrc |
| 23 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 24 | # Destination path for service data |
| 25 | DATA_DIR=${DATA_DIR:-${DEST}/data} |
| 26 | |
| 27 | # Get project function libraries |
Devananda van der Veen | 7611c89 | 2012-11-23 10:54:54 -0800 | [diff] [blame] | 28 | source $TOP_DIR/lib/baremetal |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 29 | source $TOP_DIR/lib/cinder |
Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 30 | source $TOP_DIR/lib/horizon |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 31 | source $TOP_DIR/lib/swift |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 32 | source $TOP_DIR/lib/quantum |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 33 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 34 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 35 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 36 | GetOSVersion |
| 37 | |
| 38 | if [[ "$1" == "--all" ]]; then |
| 39 | UNSTACK_ALL=${UNSTACK_ALL:-1} |
| 40 | fi |
| 41 | |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 42 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then |
| 43 | source $TOP_DIR/openrc |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 44 | teardown_quantum_debug |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 45 | fi |
| 46 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 47 | # Shut down devstack's screen to get the bulk of OpenStack services in one shot |
Dean Troyer | eeaf266 | 2012-06-14 09:11:38 -0500 | [diff] [blame] | 48 | SCREEN=$(which screen) |
| 49 | if [[ -n "$SCREEN" ]]; then |
| 50 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') |
| 51 | if [[ -n "$SESSION" ]]; then |
| 52 | screen -X -S $SESSION quit |
| 53 | fi |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 54 | fi |
| 55 | |
| 56 | # Swift runs daemons |
| 57 | if is_service_enabled swift; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 58 | stop_swift |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 59 | fi |
| 60 | |
| 61 | # Apache has the WSGI processes |
| 62 | if is_service_enabled horizon; then |
Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 63 | stop_horizon |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 64 | fi |
| 65 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 66 | # Kill TLS proxies |
| 67 | if is_service_enabled tls-proxy; then |
| 68 | killall stud |
| 69 | fi |
| 70 | |
Devananda van der Veen | 7611c89 | 2012-11-23 10:54:54 -0800 | [diff] [blame] | 71 | # baremetal might have created a fake environment |
| 72 | if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then |
| 73 | cleanup_fake_baremetal_env |
| 74 | fi |
| 75 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 76 | SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |
| 77 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 78 | # Get the iSCSI volumes |
Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 79 | if is_service_enabled cinder; then |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 80 | cleanup_cinder |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 81 | fi |
| 82 | |
| 83 | if [[ -n "$UNSTACK_ALL" ]]; then |
| 84 | # Stop MySQL server |
| 85 | if is_service_enabled mysql; then |
| 86 | stop_service mysql |
| 87 | fi |
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 88 | |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 89 | if is_service_enabled postgresql; then |
| 90 | stop_service postgresql |
| 91 | fi |
| 92 | |
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 93 | # Stop rabbitmq-server |
| 94 | if is_service_enabled rabbit; then |
| 95 | stop_service rabbitmq-server |
| 96 | fi |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 97 | fi |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 98 | |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 99 | if is_service_enabled quantum; then |
| 100 | stop_quantum |
| 101 | stop_quantum_third_party |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 102 | fi |