|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Stops that which is started by ``stack.sh`` (mostly) |
| 4 | +# mysql and rabbit are left running as OpenStack code refreshes |
| 5 | +# do not require them to be restarted. |
| 6 | +# |
| 7 | +# Stop all processes by setting UNSTACK_ALL or specifying ``--all`` |
| 8 | +# on the command line |
| 9 | + |
| 10 | +# Keep track of the current devstack directory. |
| 11 | +TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 12 | + |
| 13 | +# Import common functions |
| 14 | +source $TOP_DIR/functions |
| 15 | + |
| 16 | +# Load local configuration |
| 17 | +source $TOP_DIR/stackrc |
| 18 | + |
| 19 | +# Determine what system we are running on. This provides ``os_VENDOR``, |
| 20 | +# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 21 | +GetOSVersion |
| 22 | + |
| 23 | +if [[ "$1" == "--all" ]]; then |
| 24 | + UNSTACK_ALL=${UNSTACK_ALL:-1} |
| 25 | +fi |
| 26 | + |
| 27 | +# Shut down devstack's screen to get the bulk of OpenStack services in one shot |
| 28 | +SESSION=$(screen -ls | grep "[0-9].stack" | awk '{ print $1 }') |
| 29 | +if [[ -n "$SESSION" ]]; then |
| 30 | + screen -X -S $SESSION quit |
| 31 | +fi |
| 32 | + |
| 33 | +# Swift runs daemons |
| 34 | +if is_service_enabled swift; then |
| 35 | + swift-init all stop |
| 36 | +fi |
| 37 | + |
| 38 | +# Apache has the WSGI processes |
| 39 | +if is_service_enabled horizon; then |
| 40 | + stop_service apache2 |
| 41 | +fi |
| 42 | + |
| 43 | +# Get the iSCSI volumes |
| 44 | +if is_service_enabled n-vol; then |
| 45 | + TARGETS=$(sudo tgtadm --op show --mode target) |
| 46 | + if [[ -n "$TARGETS" ]]; then |
| 47 | + # FIXME(dtroyer): this could very well require more here to |
| 48 | + # clean up left-over volumes |
| 49 | + echo "iSCSI target cleanup needed:" |
| 50 | + echo "$TARGETS" |
| 51 | + fi |
| 52 | + sudo stop tgt |
| 53 | +fi |
| 54 | + |
| 55 | +if [[ -n "$UNSTACK_ALL" ]]; then |
| 56 | + # Stop MySQL server |
| 57 | + if is_service_enabled mysql; then |
| 58 | + stop_service mysql |
| 59 | + fi |
| 60 | +fi |
0 commit comments