| 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 | # | ||||
| Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 9 | # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``-a`` |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 10 | # on the command line |
| 11 | |||||
| Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 12 | UNSTACK_ALL="" |
| 13 | |||||
| 14 | while getopts ":a" opt; do | ||||
| 15 | case $opt in | ||||
| 16 | a) | ||||
| 17 | UNSTACK_ALL="" | ||||
| 18 | ;; | ||||
| 19 | esac | ||||
| 20 | done | ||||
| 21 | |||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 22 | # Keep track of the current devstack directory. |
| 23 | TOP_DIR=$(cd $(dirname "$0") && pwd) | ||||
| Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 24 | FILES=$TOP_DIR/files |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 25 | |
| 26 | # Import common functions | ||||
| 27 | source $TOP_DIR/functions | ||||
| 28 | |||||
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 29 | # Import database library |
| 30 | source $TOP_DIR/lib/database | ||||
| 31 | |||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 32 | # Load local configuration |
| Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 33 | source $TOP_DIR/openrc |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 34 | |
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 35 | # Destination path for service data |
| 36 | DATA_DIR=${DATA_DIR:-${DEST}/data} | ||||
| 37 | |||||
| Dean Troyer | 23f69d8 | 2013-10-04 12:35:24 -0500 | [diff] [blame] | 38 | if [[ $EUID -eq 0 ]]; then |
| 39 | echo "You are running this script as root." | ||||
| 40 | echo "It might work but you will have a better day running it as $STACK_USER" | ||||
| 41 | exit 1 | ||||
| 42 | fi | ||||
| 43 | |||||
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 44 | |
| 45 | # Configure Projects | ||||
| 46 | # ================== | ||||
| 47 | |||||
| zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 48 | # Import apache functions |
| 49 | source $TOP_DIR/lib/apache | ||||
| 50 | |||||
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 51 | # Import TLS functions |
| 52 | source $TOP_DIR/lib/tls | ||||
| 53 | |||||
| 54 | # Source project function libraries | ||||
| 55 | source $TOP_DIR/lib/infra | ||||
| 56 | source $TOP_DIR/lib/oslo | ||||
| 57 | source $TOP_DIR/lib/stackforge | ||||
| Daniel Genin | d470867 | 2014-10-31 15:01:29 -0400 | [diff] [blame] | 58 | source $TOP_DIR/lib/lvm |
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 59 | source $TOP_DIR/lib/horizon |
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 60 | source $TOP_DIR/lib/keystone |
| 61 | source $TOP_DIR/lib/glance | ||||
| 62 | source $TOP_DIR/lib/nova | ||||
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 63 | source $TOP_DIR/lib/cinder |
| Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 64 | source $TOP_DIR/lib/swift |
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 65 | source $TOP_DIR/lib/ceilometer |
| 66 | source $TOP_DIR/lib/heat | ||||
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 67 | source $TOP_DIR/lib/neutron |
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 68 | source $TOP_DIR/lib/ldap |
| Martin André | 48a75c1 | 2014-09-08 08:58:58 +0000 | [diff] [blame] | 69 | source $TOP_DIR/lib/dstat |
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 70 | |
| Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 71 | # Extras Source |
| 72 | # -------------- | ||||
| 73 | |||||
| 74 | # Phase: source | ||||
| 75 | if [[ -d $TOP_DIR/extras.d ]]; then | ||||
| 76 | for i in $TOP_DIR/extras.d/*.sh; do | ||||
| 77 | [[ -r $i ]] && source $i source | ||||
| 78 | done | ||||
| 79 | fi | ||||
| 80 | |||||
| Sean Dague | 2c65e71 | 2014-12-18 09:44:56 -0500 | [diff] [blame] | 81 | load_plugin_settings |
| 82 | |||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 83 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 84 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` | ||||
| 85 | GetOSVersion | ||||
| 86 | |||||
| Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 87 | # Run extras |
| 88 | # ========== | ||||
| 89 | |||||
| Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 90 | # Phase: unstack |
| Sean Dague | 2c65e71 | 2014-12-18 09:44:56 -0500 | [diff] [blame] | 91 | run_phase unstack |
| Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 92 | |
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 93 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then |
| 94 | source $TOP_DIR/openrc | ||||
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 95 | teardown_neutron_debug |
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 96 | fi |
| 97 | |||||
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 98 | # Call service stop |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 99 | |
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 100 | if is_service_enabled heat; then |
| 101 | stop_heat | ||||
| 102 | fi | ||||
| 103 | |||||
| 104 | if is_service_enabled ceilometer; then | ||||
| 105 | stop_ceilometer | ||||
| 106 | fi | ||||
| 107 | |||||
| 108 | if is_service_enabled nova; then | ||||
| 109 | stop_nova | ||||
| 110 | fi | ||||
| 111 | |||||
| Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 112 | if is_service_enabled glance; then |
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 113 | stop_glance |
| 114 | fi | ||||
| 115 | |||||
| 116 | if is_service_enabled key; then | ||||
| 117 | stop_keystone | ||||
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 118 | fi |
| 119 | |||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 120 | # Swift runs daemons |
| Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 121 | if is_service_enabled s-proxy; then |
| Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 122 | stop_swift |
| Chmouel Boudjnah | 43eb0b3 | 2013-01-12 20:10:34 +0000 | [diff] [blame] | 123 | cleanup_swift |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 124 | fi |
| 125 | |||||
| 126 | # Apache has the WSGI processes | ||||
| 127 | if is_service_enabled horizon; then | ||||
| Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 128 | stop_horizon |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 129 | fi |
| 130 | |||||
| Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 131 | # Kill TLS proxies and cleanup certificates |
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 132 | if is_service_enabled tls-proxy; then |
| Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 133 | stop_tls_proxy |
| 134 | cleanup_CA | ||||
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 135 | fi |
| 136 | |||||
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 137 | SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |
| 138 | |||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 139 | # Get the iSCSI volumes |
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 140 | if is_service_enabled cinder; then |
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 141 | stop_cinder |
| Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 142 | cleanup_cinder |
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 143 | fi |
| 144 | |||||
| 145 | if [[ -n "$UNSTACK_ALL" ]]; then | ||||
| 146 | # Stop MySQL server | ||||
| 147 | if is_service_enabled mysql; then | ||||
| 148 | stop_service mysql | ||||
| 149 | fi | ||||
| Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 150 | |
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 151 | if is_service_enabled postgresql; then |
| 152 | stop_service postgresql | ||||
| 153 | fi | ||||
| 154 | |||||
| Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 155 | # Stop rabbitmq-server |
| 156 | if is_service_enabled rabbit; then | ||||
| 157 | stop_service rabbitmq-server | ||||
| 158 | fi | ||||
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 159 | fi |
| Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 160 | |
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 161 | if is_service_enabled neutron; then |
| 162 | stop_neutron | ||||
| 163 | stop_neutron_third_party | ||||
| 164 | cleanup_neutron | ||||
| Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 165 | fi |
| Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 166 | |
| Nikhil Manchanda | 0cccad4 | 2012-12-03 18:15:09 -0700 | [diff] [blame] | 167 | if is_service_enabled trove; then |
| 168 | cleanup_trove | ||||
| 169 | fi | ||||
| 170 | |||||
| Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 171 | stop_dstat |
| 172 | |||||
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 173 | # Clean up the remainder of the screen processes |
| 174 | SCREEN=$(which screen) | ||||
| 175 | if [[ -n "$SCREEN" ]]; then | ||||
| 176 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') | ||||
| 177 | if [[ -n "$SESSION" ]]; then | ||||
| 178 | screen -X -S $SESSION quit | ||||
| 179 | fi | ||||
| 180 | fi | ||||
| Daniel Genin | d470867 | 2014-10-31 15:01:29 -0400 | [diff] [blame] | 181 | |
| 182 | clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME | ||||