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 | |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 27 | # Import apache functions |
| 28 | source $TOP_DIR/lib/apache |
| 29 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 30 | # Get project function libraries |
Devananda van der Veen | 7611c89 | 2012-11-23 10:54:54 -0800 | [diff] [blame] | 31 | source $TOP_DIR/lib/baremetal |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 32 | source $TOP_DIR/lib/cinder |
Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 33 | source $TOP_DIR/lib/horizon |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 34 | source $TOP_DIR/lib/swift |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 35 | source $TOP_DIR/lib/neutron |
Roman Prykhodchenko | ce696b6 | 2013-08-09 10:40:45 +0300 | [diff] [blame] | 36 | source $TOP_DIR/lib/ironic |
Nikhil Manchanda | 0cccad4 | 2012-12-03 18:15:09 -0700 | [diff] [blame^] | 37 | source $TOP_DIR/lib/trove |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 38 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 39 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 40 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 41 | GetOSVersion |
| 42 | |
| 43 | if [[ "$1" == "--all" ]]; then |
| 44 | UNSTACK_ALL=${UNSTACK_ALL:-1} |
| 45 | fi |
| 46 | |
Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 47 | # Run extras |
| 48 | # ========== |
| 49 | |
| 50 | if [[ -d $TOP_DIR/extras.d ]]; then |
| 51 | for i in $TOP_DIR/extras.d/*.sh; do |
| 52 | [[ -r $i ]] && source $i unstack |
| 53 | done |
| 54 | fi |
| 55 | |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 56 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then |
| 57 | source $TOP_DIR/openrc |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 58 | teardown_neutron_debug |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 59 | fi |
| 60 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 61 | # 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] | 62 | SCREEN=$(which screen) |
| 63 | if [[ -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 Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 68 | fi |
| 69 | |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 70 | # Shut down Nova hypervisor plugins after Nova |
| 71 | NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins |
| 72 | if 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 |
| 76 | fi |
| 77 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 78 | # Swift runs daemons |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 79 | if is_service_enabled s-proxy; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 80 | stop_swift |
Chmouel Boudjnah | 43eb0b3 | 2013-01-12 20:10:34 +0000 | [diff] [blame] | 81 | cleanup_swift |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 82 | fi |
| 83 | |
Roman Prykhodchenko | ce696b6 | 2013-08-09 10:40:45 +0300 | [diff] [blame] | 84 | # Ironic runs daemons |
| 85 | if is_service_enabled ir-api ir-cond; then |
| 86 | stop_ironic |
| 87 | cleanup_ironic |
| 88 | fi |
| 89 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 90 | # Apache has the WSGI processes |
| 91 | if is_service_enabled horizon; then |
Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 92 | stop_horizon |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 93 | fi |
| 94 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 95 | # Kill TLS proxies |
| 96 | if is_service_enabled tls-proxy; then |
| 97 | killall stud |
| 98 | fi |
| 99 | |
Devananda van der Veen | 7611c89 | 2012-11-23 10:54:54 -0800 | [diff] [blame] | 100 | # baremetal might have created a fake environment |
| 101 | if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then |
| 102 | cleanup_fake_baremetal_env |
| 103 | fi |
| 104 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 105 | SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |
| 106 | |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 107 | # Get the iSCSI volumes |
Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 108 | if is_service_enabled cinder; then |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 109 | cleanup_cinder |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 110 | fi |
| 111 | |
| 112 | if [[ -n "$UNSTACK_ALL" ]]; then |
| 113 | # Stop MySQL server |
| 114 | if is_service_enabled mysql; then |
| 115 | stop_service mysql |
| 116 | fi |
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 117 | |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 118 | if is_service_enabled postgresql; then |
| 119 | stop_service postgresql |
| 120 | fi |
| 121 | |
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 122 | # Stop rabbitmq-server |
| 123 | if is_service_enabled rabbit; then |
| 124 | stop_service rabbitmq-server |
| 125 | fi |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 126 | fi |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 127 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 128 | if is_service_enabled neutron; then |
| 129 | stop_neutron |
| 130 | stop_neutron_third_party |
| 131 | cleanup_neutron |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 132 | fi |
Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 133 | |
Nikhil Manchanda | 0cccad4 | 2012-12-03 18:15:09 -0700 | [diff] [blame^] | 134 | if is_service_enabled trove; then |
| 135 | cleanup_trove |
| 136 | fi |
| 137 | |
Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 138 | cleanup_tmp |