Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 3 | # lib/cinder |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 4 | # Install and start **Cinder** volume service |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 5 | |
| 6 | # Dependencies: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 7 | # |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 8 | # - functions |
Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 9 | # - DEST, DATA_DIR, STACK_USER must be defined |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 10 | # - SERVICE_{TENANT_NAME|PASSWORD} must be defined |
| 11 | # - ``KEYSTONE_TOKEN_FORMAT`` must be defined |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 12 | |
| 13 | # stack.sh |
| 14 | # --------- |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 15 | # - install_cinder |
| 16 | # - configure_cinder |
| 17 | # - init_cinder |
| 18 | # - start_cinder |
| 19 | # - stop_cinder |
| 20 | # - cleanup_cinder |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 21 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 22 | # Save trace setting |
| 23 | XTRACE=$(set +o | grep xtrace) |
| 24 | set +o xtrace |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 25 | |
| 26 | |
| 27 | # Defaults |
| 28 | # -------- |
| 29 | |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 30 | # set up default driver |
| 31 | CINDER_DRIVER=${CINDER_DRIVER:-default} |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 32 | CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 33 | CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 34 | |
| 35 | # grab plugin config if specified via cinder_driver |
| 36 | if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then |
| 37 | source $CINDER_PLUGINS/$CINDER_DRIVER |
| 38 | fi |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 39 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 40 | # set up default directories |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 41 | GITDIR["python-cinderclient"]=$DEST/python-cinderclient |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 42 | CINDER_DIR=$DEST/cinder |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 43 | |
| 44 | # Cinder virtual environment |
| 45 | if [[ ${USE_VENV} = True ]]; then |
| 46 | PROJECT_VENV["cinder"]=${CINDER_DIR}.venv |
| 47 | CINDER_BIN_DIR=${PROJECT_VENV["cinder"]}/bin |
| 48 | else |
| 49 | CINDER_BIN_DIR=$(get_python_exec_prefix) |
| 50 | fi |
| 51 | |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 52 | CINDER_STATE_PATH=${CINDER_STATE_PATH:=$DATA_DIR/cinder} |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 53 | CINDER_AUTH_CACHE_DIR=${CINDER_AUTH_CACHE_DIR:-/var/cache/cinder} |
| 54 | |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 55 | CINDER_CONF_DIR=/etc/cinder |
| 56 | CINDER_CONF=$CINDER_CONF_DIR/cinder.conf |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 57 | CINDER_API_PASTE_INI=$CINDER_CONF_DIR/api-paste.ini |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 58 | |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 59 | # Public facing bits |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 60 | if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then |
| 61 | CINDER_SERVICE_PROTOCOL="https" |
| 62 | fi |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 63 | CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST} |
| 64 | CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776} |
| 65 | CINDER_SERVICE_PORT_INT=${CINDER_SERVICE_PORT_INT:-18776} |
| 66 | CINDER_SERVICE_PROTOCOL=${CINDER_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} |
| 67 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 68 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 69 | # Default backends |
| 70 | # The backend format is type:name where type is one of the supported backend |
| 71 | # types (lvm, nfs, etc) and name is the identifier used in the Cinder |
| 72 | # configuration and for the volume type name. Multiple backends are |
| 73 | # comma-separated. |
Dean Troyer | 311f487 | 2014-12-18 16:31:34 -0600 | [diff] [blame] | 74 | # The old ``CINDER_MULTI_LVM_BACKEND=True`` setting had a default of: |
| 75 | # CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1,lvm:lvmdriver-2} |
| 76 | CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 77 | |
| 78 | |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 79 | # Should cinder perform secure deletion of volumes? |
| 80 | # Defaults to true, can be set to False to avoid this bug when testing: |
| 81 | # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1023755 |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 82 | CINDER_SECURE_DELETE=$(trueorfalse True CINDER_SECURE_DELETE) |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 83 | |
Sean Dague | f35ff72 | 2013-05-16 16:31:12 -0400 | [diff] [blame] | 84 | # Cinder reports allocations back to the scheduler on periodic intervals |
| 85 | # it turns out we can get an "out of space" issue when we run tests too |
| 86 | # quickly just because cinder didn't realize we'd freed up resources. |
| 87 | # Make this configurable so that devstack-gate/tempest can set it to |
| 88 | # less than the 60 second default |
| 89 | # https://bugs.launchpad.net/cinder/+bug/1180976 |
| 90 | CINDER_PERIODIC_INTERVAL=${CINDER_PERIODIC_INTERVAL:-60} |
| 91 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 92 | CINDER_ISCSI_HELPER=${CINDER_ISCSI_HELPER:-tgtadm} |
| 93 | |
Dean Troyer | 4237f59 | 2014-01-29 16:22:11 -0600 | [diff] [blame] | 94 | # Tell Tempest this project is present |
| 95 | TEMPEST_SERVICES+=,cinder |
| 96 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 97 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 98 | # Source the enabled backends |
| 99 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
| 100 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 101 | be_type=${be%%:*} |
| 102 | be_name=${be##*:} |
| 103 | if [[ -r $CINDER_BACKENDS/${be_type} ]]; then |
| 104 | source $CINDER_BACKENDS/${be_type} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 105 | fi |
| 106 | done |
| 107 | fi |
| 108 | |
git-harry | afc1423 | 2015-01-08 17:37:40 +0000 | [diff] [blame] | 109 | # Change the default nova_catalog_info and nova_catalog_admin_info values in |
| 110 | # cinder so that the service name cinder is searching for matches that set for |
| 111 | # nova in keystone. |
| 112 | CINDER_NOVA_CATALOG_INFO=${CINDER_NOVA_CATALOG_INFO:-compute:nova:publicURL} |
| 113 | CINDER_NOVA_CATALOG_ADMIN_INFO=${CINDER_NOVA_CATALOG_ADMIN_INFO:-compute:nova:adminURL} |
| 114 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 115 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 116 | # Functions |
| 117 | # --------- |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 118 | |
| 119 | # Test if any Cinder services are enabled |
| 120 | # is_cinder_enabled |
| 121 | function is_cinder_enabled { |
| 122 | [[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0 |
| 123 | return 1 |
| 124 | } |
| 125 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 126 | # cleanup_cinder() - Remove residual data files, anything left over from previous |
| 127 | # runs that a clean run would need to clean up |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 128 | function cleanup_cinder { |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 129 | # ensure the volume group is cleared up because fails might |
| 130 | # leave dead volumes in the group |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 131 | if [ "$CINDER_ISCSI_HELPER" = "tgtadm" ]; then |
| 132 | local targets=$(sudo tgtadm --op show --mode target) |
| 133 | if [ $? -ne 0 ]; then |
| 134 | # If tgt driver isn't running this won't work obviously |
| 135 | # So check the response and restart if need be |
| 136 | echo "tgtd seems to be in a bad state, restarting..." |
| 137 | if is_ubuntu; then |
| 138 | restart_service tgt |
| 139 | else |
| 140 | restart_service tgtd |
| 141 | fi |
| 142 | targets=$(sudo tgtadm --op show --mode target) |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 143 | fi |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 144 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 145 | if [[ -n "$targets" ]]; then |
| 146 | local iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') ) |
| 147 | for i in "${iqn_list[@]}"; do |
| 148 | echo removing iSCSI target: $i |
| 149 | sudo tgt-admin --delete $i |
| 150 | done |
| 151 | fi |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 152 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 153 | if is_ubuntu; then |
| 154 | stop_service tgt |
| 155 | else |
| 156 | stop_service tgtd |
| 157 | fi |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 158 | else |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 159 | sudo cinder-rtstool get-targets | sudo xargs -rn 1 cinder-rtstool delete |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 160 | fi |
| 161 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 162 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 163 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 164 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 165 | be_type=${be%%:*} |
| 166 | be_name=${be##*:} |
| 167 | if type cleanup_cinder_backend_${be_type} >/dev/null 2>&1; then |
| 168 | cleanup_cinder_backend_${be_type} ${be_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 169 | fi |
| 170 | done |
Jérôme Gallard | dda2b7a | 2013-02-22 17:28:10 +0100 | [diff] [blame] | 171 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 172 | } |
| 173 | |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 174 | # Deploy new rootwrap filters files and configure sudo |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 175 | # configure_cinder_rootwrap() - configure Cinder's rootwrap |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 176 | function configure_cinder_rootwrap { |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 177 | local cinder_rootwrap=$CINDER_BIN_DIR/cinder-rootwrap |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 178 | |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 179 | # Wipe any existing rootwrap.d files first |
| 180 | if [[ -d $CINDER_CONF_DIR/rootwrap.d ]]; then |
| 181 | sudo rm -rf $CINDER_CONF_DIR/rootwrap.d |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 182 | fi |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 183 | |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 184 | # Deploy filters to /etc/cinder/rootwrap.d |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 185 | sudo install -d -o root -g root -m 755 $CINDER_CONF_DIR/rootwrap.d |
| 186 | sudo install -o root -g root -m 644 $CINDER_DIR/etc/cinder/rootwrap.d/*.filters $CINDER_CONF_DIR/rootwrap.d |
| 187 | |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 188 | # Set up rootwrap.conf, pointing to /etc/cinder/rootwrap.d |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 189 | sudo install -o root -g root -m 644 $CINDER_DIR/etc/cinder/rootwrap.conf $CINDER_CONF_DIR |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 190 | sudo sed -e "s:^filters_path=.*$:filters_path=$CINDER_CONF_DIR/rootwrap.d:" -i $CINDER_CONF_DIR/rootwrap.conf |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 191 | |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 192 | # Specify rootwrap.conf as first parameter to rootwrap |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 193 | ROOTWRAP_CSUDOER_CMD="$cinder_rootwrap $CINDER_CONF_DIR/rootwrap.conf *" |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 194 | |
Thierry Carrez | d5d4974 | 2014-02-06 16:00:08 +0100 | [diff] [blame] | 195 | # Set up the rootwrap sudoers for cinder |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 196 | local tempfile=`mktemp` |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 197 | echo "Defaults:$STACK_USER secure_path=$CINDER_BIN_DIR:/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >$tempfile |
| 198 | echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_CSUDOER_CMD" >>$tempfile |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 199 | chmod 0440 $tempfile |
| 200 | sudo chown root:root $tempfile |
| 201 | sudo mv $tempfile /etc/sudoers.d/cinder-rootwrap |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 202 | |
| 203 | # So rootwrap and PATH are broken beyond belief. WTF relies on a SECURE operation |
| 204 | # to blindly follow PATH??? We learned that was a bad idea in the 80's! |
| 205 | # So to fix this in a venv, we must exploit the very hole we want to close by dropping |
| 206 | # a copy of the venv rootwrap binary into /usr/local/bin. |
| 207 | #sudo cp -p $cinder_rootwrap /usr/local/bin |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | # configure_cinder() - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 211 | function configure_cinder { |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 212 | sudo install -d -o $STACK_USER -m 755 $CINDER_CONF_DIR |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 213 | |
| 214 | cp -p $CINDER_DIR/etc/cinder/policy.json $CINDER_CONF_DIR |
| 215 | |
Yalei Wang | cecbd1f | 2015-01-05 17:05:47 +0800 | [diff] [blame] | 216 | rm -f $CINDER_CONF |
| 217 | |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 218 | configure_cinder_rootwrap |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 219 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 220 | cp $CINDER_DIR/etc/cinder/api-paste.ini $CINDER_API_PASTE_INI |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 221 | |
| 222 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_host |
| 223 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_port |
| 224 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_protocol |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 225 | inicomment $CINDER_API_PASTE_INI filter:authtoken cafile |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 226 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_tenant_name |
| 227 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_user |
| 228 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_password |
| 229 | inicomment $CINDER_API_PASTE_INI filter:authtoken signing_dir |
Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 230 | |
Brant Knudson | 0595237 | 2014-09-19 17:22:22 -0500 | [diff] [blame] | 231 | configure_auth_token_middleware $CINDER_CONF cinder $CINDER_AUTH_CACHE_DIR |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 232 | |
git-harry | afc1423 | 2015-01-08 17:37:40 +0000 | [diff] [blame] | 233 | iniset $CINDER_CONF DEFAULT nova_catalog_info $CINDER_NOVA_CATALOG_INFO |
| 234 | iniset $CINDER_CONF DEFAULT nova_catalog_admin_info $CINDER_NOVA_CATALOG_ADMIN_INFO |
| 235 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 236 | iniset $CINDER_CONF DEFAULT auth_strategy keystone |
Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 237 | iniset $CINDER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 238 | iniset $CINDER_CONF DEFAULT verbose True |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 239 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 240 | iniset $CINDER_CONF DEFAULT iscsi_helper "$CINDER_ISCSI_HELPER" |
Joe Gordon | 23d6d50 | 2015-03-06 15:24:22 -0800 | [diff] [blame] | 241 | iniset $CINDER_CONF database connection `database_connection_url cinder` |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 242 | iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI |
Joe Gordon | a58382a | 2013-02-20 12:45:02 -0800 | [diff] [blame] | 243 | iniset $CINDER_CONF DEFAULT rootwrap_config "$CINDER_CONF_DIR/rootwrap.conf" |
Dan Prince | 9f22f07 | 2013-01-28 09:53:38 -0500 | [diff] [blame] | 244 | iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 245 | iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH |
Joe Gordon | 23d6d50 | 2015-03-06 15:24:22 -0800 | [diff] [blame] | 246 | iniset $CINDER_CONF oslo_concurrency lock_path $CINDER_STATE_PATH |
Sean Dague | f35ff72 | 2013-05-16 16:31:12 -0400 | [diff] [blame] | 247 | iniset $CINDER_CONF DEFAULT periodic_interval $CINDER_PERIODIC_INTERVAL |
Mike Perez | f64f43b | 2014-06-25 08:51:31 -0700 | [diff] [blame] | 248 | # NOTE(thingee): Cinder V1 API is deprecated and defaults to off as of |
| 249 | # Juno. Keep it enabled so we can continue testing while it's still |
| 250 | # supported. |
| 251 | iniset $CINDER_CONF DEFAULT enable_v1_api true |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 252 | |
Ethan Lynn | 679f395 | 2015-03-09 23:45:18 +0800 | [diff] [blame] | 253 | iniset $CINDER_CONF DEFAULT os_region_name "$REGION_NAME" |
| 254 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 255 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 256 | local enabled_backends="" |
| 257 | local default_name="" |
| 258 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 259 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 260 | be_type=${be%%:*} |
| 261 | be_name=${be##*:} |
| 262 | if type configure_cinder_backend_${be_type} >/dev/null 2>&1; then |
| 263 | configure_cinder_backend_${be_type} ${be_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 264 | fi |
Dean Troyer | a25922b | 2014-08-28 09:29:47 -0500 | [diff] [blame] | 265 | if [[ -z "$default_name" ]]; then |
| 266 | default_name=$be_name |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 267 | fi |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 268 | enabled_backends+=$be_name, |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 269 | done |
| 270 | iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*} |
Matt Riedemann | 6a4aa78 | 2014-07-25 13:35:53 -0700 | [diff] [blame] | 271 | if [[ -n "$default_name" ]]; then |
| 272 | iniset $CINDER_CONF DEFAULT default_volume_type ${default_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 273 | fi |
| 274 | fi |
| 275 | |
Attila Fazekas | 2983474 | 2014-03-09 18:36:42 +0100 | [diff] [blame] | 276 | if is_service_enabled swift; then |
Rob Crittenden | 7d0a0f7 | 2014-11-17 00:03:47 -0500 | [diff] [blame] | 277 | iniset $CINDER_CONF DEFAULT backup_swift_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:8080/v1/AUTH_" |
Attila Fazekas | 2983474 | 2014-03-09 18:36:42 +0100 | [diff] [blame] | 278 | fi |
| 279 | |
Gordon Chung | 2bfbc77 | 2013-08-09 10:55:12 -0400 | [diff] [blame] | 280 | if is_service_enabled ceilometer; then |
Mark McLoughlin | dc0938e | 2014-06-17 06:37:43 +0100 | [diff] [blame] | 281 | iniset $CINDER_CONF DEFAULT notification_driver "messaging" |
Gordon Chung | 2bfbc77 | 2013-08-09 10:55:12 -0400 | [diff] [blame] | 282 | fi |
| 283 | |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 284 | if is_service_enabled tls-proxy; then |
| 285 | # Set the service port for a proxy to take the original |
| 286 | iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT |
| 287 | fi |
| 288 | |
Dean Troyer | 4d3049e | 2012-11-06 20:38:14 -0600 | [diff] [blame] | 289 | if [ "$SYSLOG" != "False" ]; then |
| 290 | iniset $CINDER_CONF DEFAULT use_syslog True |
| 291 | fi |
| 292 | |
Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 293 | iniset_rpc_backend cinder $CINDER_CONF |
Gary Kotton | f71bf19 | 2012-08-06 11:15:36 -0400 | [diff] [blame] | 294 | |
James E. Blair | 213c416 | 2012-11-06 09:38:36 +0100 | [diff] [blame] | 295 | if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then |
| 296 | iniset $CINDER_CONF DEFAULT secure_delete False |
Pádraig Brady | eac9370 | 2013-01-02 16:02:54 +0000 | [diff] [blame] | 297 | iniset $CINDER_CONF DEFAULT volume_clear none |
James E. Blair | 213c416 | 2012-11-06 09:38:36 +0100 | [diff] [blame] | 298 | fi |
| 299 | |
Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 300 | # Format logging |
Chmouel Boudjnah | 1057bff | 2012-08-03 11:42:51 +0000 | [diff] [blame] | 301 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 302 | setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id" |
Chmouel Boudjnah | 1057bff | 2012-08-03 11:42:51 +0000 | [diff] [blame] | 303 | fi |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 304 | |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 305 | if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then |
| 306 | configure_cinder_driver |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 307 | fi |
Ian Wienand | 0db1713 | 2013-06-26 22:31:48 +1000 | [diff] [blame] | 308 | |
Dean Troyer | 05bd7b8 | 2014-09-16 17:25:33 -0500 | [diff] [blame] | 309 | iniset $CINDER_CONF DEFAULT osapi_volume_workers "$API_WORKERS" |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 310 | |
| 311 | iniset $CINDER_CONF DEFAULT glance_api_servers "${GLANCE_SERVICE_PROTOCOL}://${GLANCE_HOSTPORT}" |
| 312 | if is_ssl_enabled_service glance || is_service_enabled tls-proxy; then |
| 313 | iniset $CINDER_CONF DEFAULT glance_protocol https |
Rob Crittenden | 4b10929 | 2014-10-21 18:17:48 -0400 | [diff] [blame] | 314 | iniset $CINDER_CONF DEFAULT glance_ca_certificates_file $SSL_BUNDLE_FILE |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 315 | fi |
| 316 | |
| 317 | # Register SSL certificates if provided |
| 318 | if is_ssl_enabled_service cinder; then |
| 319 | ensure_certificates CINDER |
| 320 | |
| 321 | iniset $CINDER_CONF DEFAULT ssl_cert_file "$CINDER_SSL_CERT" |
| 322 | iniset $CINDER_CONF DEFAULT ssl_key_file "$CINDER_SSL_KEY" |
| 323 | fi |
| 324 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 325 | } |
| 326 | |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 327 | # create_cinder_accounts() - Set up common required cinder accounts |
| 328 | |
| 329 | # Tenant User Roles |
| 330 | # ------------------------------------------------------------------ |
| 331 | # service cinder admin # if enabled |
| 332 | |
| 333 | # Migrated from keystone_data.sh |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 334 | function create_cinder_accounts { |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 335 | |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 336 | # Cinder |
| 337 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 338 | |
Jamie Lennox | e8bc2b8 | 2015-02-10 20:38:56 +1100 | [diff] [blame] | 339 | create_service_user "cinder" |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 340 | |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 341 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 342 | |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 343 | local cinder_service=$(get_or_create_service "cinder" \ |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 344 | "volume" "Cinder Volume Service") |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 345 | get_or_create_endpoint $cinder_service "$REGION_NAME" \ |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 346 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \ |
| 347 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \ |
| 348 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" |
| 349 | |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 350 | local cinder_v2_service=$(get_or_create_service "cinderv2" \ |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 351 | "volumev2" "Cinder Volume Service V2") |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 352 | get_or_create_endpoint $cinder_v2_service "$REGION_NAME" \ |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 353 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \ |
| 354 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \ |
| 355 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 356 | fi |
| 357 | fi |
| 358 | } |
| 359 | |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 360 | # create_cinder_cache_dir() - Part of the init_cinder() process |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 361 | function create_cinder_cache_dir { |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 362 | # Create cache dir |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 363 | sudo install -d -o $STACK_USER $CINDER_AUTH_CACHE_DIR |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 364 | rm -f $CINDER_AUTH_CACHE_DIR/* |
| 365 | } |
| 366 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 367 | # init_cinder() - Initialize database and volume group |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 368 | # Uses global ``NOVA_ENABLED_APIS`` |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 369 | function init_cinder { |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 370 | # Force nova volumes off |
| 371 | NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/osapi_volume,//") |
| 372 | |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 373 | if is_service_enabled $DATABASE_BACKENDS; then |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 374 | # (Re)create cinder database |
Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 375 | recreate_database cinder |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 376 | |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 377 | # Migrate cinder database |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 378 | $CINDER_BIN_DIR/cinder-manage db sync |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 379 | fi |
| 380 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 381 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 382 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 383 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 384 | be_type=${be%%:*} |
| 385 | be_name=${be##*:} |
| 386 | if type init_cinder_backend_${be_type} >/dev/null 2>&1; then |
Maru Newby | c070a3d | 2015-01-27 17:44:44 +0000 | [diff] [blame] | 387 | # Always init the default volume group for lvm. |
| 388 | if [[ "$be_type" == "lvm" ]]; then |
| 389 | init_default_lvm_volume_group |
| 390 | fi |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 391 | init_cinder_backend_${be_type} ${be_name} |
Vincent Untz | 0230aa8 | 2012-06-14 08:51:01 +0200 | [diff] [blame] | 392 | fi |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 393 | done |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 394 | fi |
Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 395 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 396 | mkdir -p $CINDER_STATE_PATH/volumes |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 397 | create_cinder_cache_dir |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | # install_cinder() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 401 | function install_cinder { |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 402 | git_clone $CINDER_REPO $CINDER_DIR $CINDER_BRANCH |
Sean Dague | 4bf9d7a | 2013-04-01 16:41:39 -0400 | [diff] [blame] | 403 | setup_develop $CINDER_DIR |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 404 | if [ "$CINDER_ISCSI_HELPER" = "tgtadm" ]; then |
| 405 | if is_fedora; then |
| 406 | install_package scsi-target-utils |
| 407 | else |
| 408 | install_package tgt |
| 409 | fi |
| 410 | fi |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 411 | } |
Sean Dague | 4bf9d7a | 2013-04-01 16:41:39 -0400 | [diff] [blame] | 412 | |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 413 | # install_cinderclient() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 414 | function install_cinderclient { |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 415 | if use_library_from_git "python-cinderclient"; then |
| 416 | git_clone_by_name "python-cinderclient" |
| 417 | setup_dev_lib "python-cinderclient" |
| 418 | sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-cinderclient"]}/tools/,/etc/bash_completion.d/}cinder.bash_completion |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 419 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 420 | } |
| 421 | |
Steve Baker | 18225d9 | 2013-04-14 12:48:41 -0700 | [diff] [blame] | 422 | # apply config.d approach for cinder volumes directory |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 423 | function _configure_tgt_for_config_d { |
Steve Baker | 18225d9 | 2013-04-14 12:48:41 -0700 | [diff] [blame] | 424 | if [[ ! -d /etc/tgt/stack.d/ ]]; then |
| 425 | sudo ln -sf $CINDER_STATE_PATH/volumes /etc/tgt/stack.d |
| 426 | echo "include /etc/tgt/stack.d/*" | sudo tee -a /etc/tgt/targets.conf |
Mate Lakat | a39caac | 2012-09-03 15:45:53 +0100 | [diff] [blame] | 427 | fi |
| 428 | } |
| 429 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 430 | # start_cinder() - Start running processes, including screen |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 431 | function start_cinder { |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 432 | local service_port=$CINDER_SERVICE_PORT |
| 433 | local service_protocol=$CINDER_SERVICE_PROTOCOL |
| 434 | if is_service_enabled tls-proxy; then |
| 435 | service_port=$CINDER_SERVICE_PORT_INT |
| 436 | service_protocol="http" |
| 437 | fi |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 438 | if [ "$CINDER_ISCSI_HELPER" = "tgtadm" ]; then |
| 439 | if is_service_enabled c-vol; then |
| 440 | # Delete any old stack.conf |
| 441 | sudo rm -f /etc/tgt/conf.d/stack.conf |
| 442 | _configure_tgt_for_config_d |
| 443 | if is_ubuntu; then |
| 444 | sudo service tgt restart |
| 445 | elif is_fedora || is_suse; then |
| 446 | restart_service tgtd |
| 447 | else |
| 448 | # note for other distros: unstack.sh also uses the tgt/tgtd service |
| 449 | # name, and would need to be adjusted too |
| 450 | exit_distro_not_supported "restarting tgt" |
| 451 | fi |
| 452 | # NOTE(gfidente): ensure tgtd is running in debug mode |
| 453 | sudo tgtadm --mode system --op update --name debug --value on |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 454 | fi |
| 455 | fi |
| 456 | |
Dean Troyer | 3159a82 | 2014-08-27 14:13:58 -0500 | [diff] [blame] | 457 | run_process c-api "$CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF" |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 458 | echo "Waiting for Cinder API to start..." |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 459 | if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$CINDER_SERVICE_HOST:$service_port; then |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 460 | die $LINENO "c-api did not start" |
| 461 | fi |
| 462 | |
Dean Troyer | 3159a82 | 2014-08-27 14:13:58 -0500 | [diff] [blame] | 463 | run_process c-sch "$CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF" |
| 464 | run_process c-bak "$CINDER_BIN_DIR/cinder-backup --config-file $CINDER_CONF" |
| 465 | run_process c-vol "$CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF" |
John Griffith | e6d4fe5 | 2013-07-15 17:35:54 -0600 | [diff] [blame] | 466 | |
| 467 | # NOTE(jdg): For cinder, startup order matters. To ensure that repor_capabilities is received |
| 468 | # by the scheduler start the cinder-volume service last (or restart it) after the scheduler |
| 469 | # has started. This is a quick fix for lp bug/1189595 |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 470 | |
| 471 | # Start proxies if enabled |
| 472 | if is_service_enabled c-api && is_service_enabled tls-proxy; then |
| 473 | start_tls_proxy '*' $CINDER_SERVICE_PORT $CINDER_SERVICE_HOST $CINDER_SERVICE_PORT_INT & |
| 474 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 475 | } |
| 476 | |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 477 | # stop_cinder() - Stop running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 478 | function stop_cinder { |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 479 | # Kill the cinder screen windows |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 480 | local serv |
Stephen Mulcahy | 67068ef | 2013-02-21 11:20:58 +0000 | [diff] [blame] | 481 | for serv in c-api c-bak c-sch c-vol; do |
Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 482 | stop_process $serv |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 483 | done |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 484 | } |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 485 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 486 | # create_volume_types() - Create Cinder's configured volume types |
| 487 | function create_volume_types { |
| 488 | # Create volume types |
| 489 | if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 490 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 491 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 492 | be_type=${be%%:*} |
| 493 | be_name=${be##*:} |
| 494 | # openstack volume type create --property volume_backend_name="${be_type}" ${be_name} |
| 495 | cinder type-create ${be_name} && \ |
| 496 | cinder type-key ${be_name} set volume_backend_name="${be_name}" |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 497 | done |
| 498 | fi |
| 499 | } |
| 500 | |
| 501 | # Compatibility for Grenade |
| 502 | |
| 503 | function create_cinder_volume_group { |
| 504 | # During a transition period Grenade needs to have this function defined |
| 505 | # It is effectively a no-op in the Grenade 'target' use case |
| 506 | : |
| 507 | } |
| 508 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 509 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 510 | # Restore xtrace |
| 511 | $XTRACE |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 512 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 513 | # Tell emacs to use shell-script-mode |
| 514 | ## Local variables: |
| 515 | ## mode: shell-script |
| 516 | ## End: |