2014-12-05 14:25:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-05-02 11:48:15 -05:00
|
|
|
# lib/cinder
|
2012-12-21 11:03:37 -06:00
|
|
|
# Install and start **Cinder** volume service
|
2012-05-02 11:48:15 -05:00
|
|
|
|
|
|
|
# Dependencies:
|
2013-10-24 11:27:02 +01:00
|
|
|
#
|
2012-05-02 11:48:15 -05:00
|
|
|
# - functions
|
2013-01-06 22:40:09 +01:00
|
|
|
# - DEST, DATA_DIR, STACK_USER must be defined
|
2013-10-24 11:27:02 +01:00
|
|
|
# - SERVICE_{TENANT_NAME|PASSWORD} must be defined
|
|
|
|
# - ``KEYSTONE_TOKEN_FORMAT`` must be defined
|
2012-05-02 11:48:15 -05:00
|
|
|
|
|
|
|
# stack.sh
|
|
|
|
# ---------
|
2013-10-24 11:27:02 +01:00
|
|
|
# - install_cinder
|
|
|
|
# - configure_cinder
|
|
|
|
# - init_cinder
|
|
|
|
# - start_cinder
|
|
|
|
# - stop_cinder
|
|
|
|
# - cleanup_cinder
|
2012-05-02 11:48:15 -05:00
|
|
|
|
2012-09-13 17:16:12 -05:00
|
|
|
# Save trace setting
|
|
|
|
XTRACE=$(set +o | grep xtrace)
|
|
|
|
set +o xtrace
|
2012-05-02 11:48:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Defaults
|
|
|
|
# --------
|
|
|
|
|
2012-11-20 15:52:21 +00:00
|
|
|
# set up default driver
|
|
|
|
CINDER_DRIVER=${CINDER_DRIVER:-default}
|
2014-01-23 11:31:10 -07:00
|
|
|
CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins
|
2014-07-03 10:46:57 -05:00
|
|
|
CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends
|
2014-01-23 11:31:10 -07:00
|
|
|
|
|
|
|
# grab plugin config if specified via cinder_driver
|
|
|
|
if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
|
|
|
|
source $CINDER_PLUGINS/$CINDER_DRIVER
|
|
|
|
fi
|
2012-11-20 15:52:21 +00:00
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
# set up default directories
|
2014-11-13 17:09:28 -05:00
|
|
|
GITDIR["python-cinderclient"]=$DEST/python-cinderclient
|
2014-11-01 01:37:45 +01:00
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
CINDER_DIR=$DEST/cinder
|
2012-09-13 14:02:01 -05:00
|
|
|
CINDER_STATE_PATH=${CINDER_STATE_PATH:=$DATA_DIR/cinder}
|
2012-12-13 16:22:38 -06:00
|
|
|
CINDER_AUTH_CACHE_DIR=${CINDER_AUTH_CACHE_DIR:-/var/cache/cinder}
|
|
|
|
|
2012-09-13 14:02:01 -05:00
|
|
|
CINDER_CONF_DIR=/etc/cinder
|
|
|
|
CINDER_CONF=$CINDER_CONF_DIR/cinder.conf
|
2012-12-13 16:22:38 -06:00
|
|
|
CINDER_API_PASTE_INI=$CINDER_CONF_DIR/api-paste.ini
|
2012-09-13 14:02:01 -05:00
|
|
|
|
2012-12-13 17:05:24 -06:00
|
|
|
# Public facing bits
|
2014-03-19 17:47:42 -04:00
|
|
|
if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then
|
|
|
|
CINDER_SERVICE_PROTOCOL="https"
|
|
|
|
fi
|
2012-12-13 17:05:24 -06:00
|
|
|
CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST}
|
|
|
|
CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776}
|
|
|
|
CINDER_SERVICE_PORT_INT=${CINDER_SERVICE_PORT_INT:-18776}
|
|
|
|
CINDER_SERVICE_PROTOCOL=${CINDER_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
|
|
|
|
2012-09-13 14:02:01 -05:00
|
|
|
# Support entry points installation of console scripts
|
|
|
|
if [[ -d $CINDER_DIR/bin ]]; then
|
2012-08-17 12:52:27 -04:00
|
|
|
CINDER_BIN_DIR=$CINDER_DIR/bin
|
|
|
|
else
|
2013-01-30 15:35:54 +01:00
|
|
|
CINDER_BIN_DIR=$(get_python_exec_prefix)
|
2012-08-17 12:52:27 -04:00
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
|
|
|
|
# Default backends
|
|
|
|
# The backend format is type:name where type is one of the supported backend
|
|
|
|
# types (lvm, nfs, etc) and name is the identifier used in the Cinder
|
|
|
|
# configuration and for the volume type name. Multiple backends are
|
|
|
|
# comma-separated.
|
2014-12-18 16:31:34 -06:00
|
|
|
# The old ``CINDER_MULTI_LVM_BACKEND=True`` setting had a default of:
|
|
|
|
# CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1,lvm:lvmdriver-2}
|
|
|
|
CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1}
|
2014-07-03 10:46:57 -05:00
|
|
|
|
|
|
|
|
2013-03-18 16:07:56 -05:00
|
|
|
# Should cinder perform secure deletion of volumes?
|
|
|
|
# Defaults to true, can be set to False to avoid this bug when testing:
|
|
|
|
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1023755
|
2014-12-04 19:38:15 -05:00
|
|
|
CINDER_SECURE_DELETE=$(trueorfalse True CINDER_SECURE_DELETE)
|
2013-03-18 16:07:56 -05:00
|
|
|
|
2013-05-16 16:31:12 -04:00
|
|
|
# Cinder reports allocations back to the scheduler on periodic intervals
|
|
|
|
# it turns out we can get an "out of space" issue when we run tests too
|
|
|
|
# quickly just because cinder didn't realize we'd freed up resources.
|
|
|
|
# Make this configurable so that devstack-gate/tempest can set it to
|
|
|
|
# less than the 60 second default
|
|
|
|
# https://bugs.launchpad.net/cinder/+bug/1180976
|
|
|
|
CINDER_PERIODIC_INTERVAL=${CINDER_PERIODIC_INTERVAL:-60}
|
|
|
|
|
2014-01-29 16:22:11 -06:00
|
|
|
# Tell Tempest this project is present
|
|
|
|
TEMPEST_SERVICES+=,cinder
|
|
|
|
|
2013-04-08 15:38:03 -05:00
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
# Source the enabled backends
|
|
|
|
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
|
|
|
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
2014-07-25 12:37:41 -05:00
|
|
|
be_type=${be%%:*}
|
|
|
|
be_name=${be##*:}
|
|
|
|
if [[ -r $CINDER_BACKENDS/${be_type} ]]; then
|
|
|
|
source $CINDER_BACKENDS/${be_type}
|
2014-07-03 10:46:57 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2015-01-08 17:37:40 +00:00
|
|
|
# Change the default nova_catalog_info and nova_catalog_admin_info values in
|
|
|
|
# cinder so that the service name cinder is searching for matches that set for
|
|
|
|
# nova in keystone.
|
|
|
|
CINDER_NOVA_CATALOG_INFO=${CINDER_NOVA_CATALOG_INFO:-compute:nova:publicURL}
|
|
|
|
CINDER_NOVA_CATALOG_ADMIN_INFO=${CINDER_NOVA_CATALOG_ADMIN_INFO:-compute:nova:adminURL}
|
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
|
2013-04-08 15:38:03 -05:00
|
|
|
# Functions
|
|
|
|
# ---------
|
2014-01-15 15:04:49 -06:00
|
|
|
|
|
|
|
# Test if any Cinder services are enabled
|
|
|
|
# is_cinder_enabled
|
|
|
|
function is_cinder_enabled {
|
|
|
|
[[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
# cleanup_cinder() - Remove residual data files, anything left over from previous
|
|
|
|
# runs that a clean run would need to clean up
|
2014-02-21 15:35:08 +11:00
|
|
|
function cleanup_cinder {
|
2012-12-20 16:41:57 -05:00
|
|
|
# ensure the volume group is cleared up because fails might
|
|
|
|
# leave dead volumes in the group
|
2014-07-25 12:37:41 -05:00
|
|
|
local targets=$(sudo tgtadm --op show --mode target)
|
2012-12-20 16:41:57 -05:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
# If tgt driver isn't running this won't work obviously
|
|
|
|
# So check the response and restart if need be
|
|
|
|
echo "tgtd seems to be in a bad state, restarting..."
|
|
|
|
if is_ubuntu; then
|
|
|
|
restart_service tgt
|
|
|
|
else
|
|
|
|
restart_service tgtd
|
|
|
|
fi
|
2014-07-25 12:37:41 -05:00
|
|
|
targets=$(sudo tgtadm --op show --mode target)
|
2012-12-20 16:41:57 -05:00
|
|
|
fi
|
|
|
|
|
2014-07-25 12:37:41 -05:00
|
|
|
if [[ -n "$targets" ]]; then
|
|
|
|
local iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
|
2012-12-20 16:41:57 -05:00
|
|
|
for i in "${iqn_list[@]}"; do
|
|
|
|
echo removing iSCSI target: $i
|
|
|
|
sudo tgt-admin --delete $i
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if is_ubuntu; then
|
|
|
|
stop_service tgt
|
|
|
|
else
|
|
|
|
stop_service tgtd
|
|
|
|
fi
|
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
2014-07-25 12:37:41 -05:00
|
|
|
local be be_name be_type
|
2014-07-03 10:46:57 -05:00
|
|
|
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
2014-07-25 12:37:41 -05:00
|
|
|
be_type=${be%%:*}
|
|
|
|
be_name=${be##*:}
|
|
|
|
if type cleanup_cinder_backend_${be_type} >/dev/null 2>&1; then
|
|
|
|
cleanup_cinder_backend_${be_type} ${be_name}
|
2014-07-03 10:46:57 -05:00
|
|
|
fi
|
|
|
|
done
|
2013-02-22 17:28:10 +01:00
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
}
|
|
|
|
|
2014-01-10 14:23:03 +01:00
|
|
|
# configure_cinder_rootwrap() - configure Cinder's rootwrap
|
2014-02-21 15:35:08 +11:00
|
|
|
function configure_cinder_rootwrap {
|
2012-07-20 13:18:17 -06:00
|
|
|
# Set the paths of certain binaries
|
2014-07-25 12:37:41 -05:00
|
|
|
local cinder_rootwrap=$(get_rootwrap_location cinder)
|
2012-07-20 13:18:17 -06:00
|
|
|
|
2014-02-06 16:00:08 +01:00
|
|
|
# Deploy new rootwrap filters files (owned by root).
|
|
|
|
# Wipe any existing rootwrap.d files first
|
|
|
|
if [[ -d $CINDER_CONF_DIR/rootwrap.d ]]; then
|
|
|
|
sudo rm -rf $CINDER_CONF_DIR/rootwrap.d
|
2012-07-20 13:18:17 -06:00
|
|
|
fi
|
2014-02-06 16:00:08 +01:00
|
|
|
# Deploy filters to /etc/cinder/rootwrap.d
|
|
|
|
sudo mkdir -m 755 $CINDER_CONF_DIR/rootwrap.d
|
|
|
|
sudo cp $CINDER_DIR/etc/cinder/rootwrap.d/*.filters $CINDER_CONF_DIR/rootwrap.d
|
|
|
|
sudo chown -R root:root $CINDER_CONF_DIR/rootwrap.d
|
|
|
|
sudo chmod 644 $CINDER_CONF_DIR/rootwrap.d/*
|
|
|
|
# Set up rootwrap.conf, pointing to /etc/cinder/rootwrap.d
|
|
|
|
sudo cp $CINDER_DIR/etc/cinder/rootwrap.conf $CINDER_CONF_DIR/
|
|
|
|
sudo sed -e "s:^filters_path=.*$:filters_path=$CINDER_CONF_DIR/rootwrap.d:" -i $CINDER_CONF_DIR/rootwrap.conf
|
|
|
|
sudo chown root:root $CINDER_CONF_DIR/rootwrap.conf
|
|
|
|
sudo chmod 0644 $CINDER_CONF_DIR/rootwrap.conf
|
|
|
|
# Specify rootwrap.conf as first parameter to rootwrap
|
2014-07-25 12:37:41 -05:00
|
|
|
ROOTWRAP_CSUDOER_CMD="$cinder_rootwrap $CINDER_CONF_DIR/rootwrap.conf *"
|
2014-02-06 16:00:08 +01:00
|
|
|
|
|
|
|
# Set up the rootwrap sudoers for cinder
|
2014-07-25 12:37:41 -05:00
|
|
|
local tempfile=`mktemp`
|
|
|
|
echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_CSUDOER_CMD" >$tempfile
|
|
|
|
chmod 0440 $tempfile
|
|
|
|
sudo chown root:root $tempfile
|
|
|
|
sudo mv $tempfile /etc/sudoers.d/cinder-rootwrap
|
2014-01-10 14:23:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# configure_cinder() - Set config files, create data dirs, etc
|
2014-02-21 15:35:08 +11:00
|
|
|
function configure_cinder {
|
2014-01-10 14:23:03 +01:00
|
|
|
if [[ ! -d $CINDER_CONF_DIR ]]; then
|
|
|
|
sudo mkdir -p $CINDER_CONF_DIR
|
|
|
|
fi
|
|
|
|
sudo chown $STACK_USER $CINDER_CONF_DIR
|
|
|
|
|
|
|
|
cp -p $CINDER_DIR/etc/cinder/policy.json $CINDER_CONF_DIR
|
|
|
|
|
2015-01-05 17:05:47 +08:00
|
|
|
rm -f $CINDER_CONF
|
|
|
|
|
2014-01-10 14:23:03 +01:00
|
|
|
configure_cinder_rootwrap
|
2012-07-20 13:18:17 -06:00
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
cp $CINDER_DIR/etc/cinder/api-paste.ini $CINDER_API_PASTE_INI
|
2013-10-16 18:57:15 -04:00
|
|
|
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken auth_host
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken auth_port
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken auth_protocol
|
2013-09-20 16:26:42 +10:00
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken cafile
|
2013-10-16 18:57:15 -04:00
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken admin_tenant_name
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken admin_user
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken admin_password
|
|
|
|
inicomment $CINDER_API_PASTE_INI filter:authtoken signing_dir
|
2012-10-01 14:06:44 -05:00
|
|
|
|
2014-09-19 17:22:22 -05:00
|
|
|
configure_auth_token_middleware $CINDER_CONF cinder $CINDER_AUTH_CACHE_DIR
|
2013-10-16 18:57:15 -04:00
|
|
|
|
2015-01-08 17:37:40 +00:00
|
|
|
iniset $CINDER_CONF DEFAULT nova_catalog_info $CINDER_NOVA_CATALOG_INFO
|
|
|
|
iniset $CINDER_CONF DEFAULT nova_catalog_admin_info $CINDER_NOVA_CATALOG_ADMIN_INFO
|
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT auth_strategy keystone
|
2013-08-10 09:56:16 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
2012-05-02 11:48:15 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT verbose True
|
2014-07-03 10:46:57 -05:00
|
|
|
|
2013-08-30 21:59:15 +04:00
|
|
|
iniset $CINDER_CONF DEFAULT my_ip "$CINDER_SERVICE_HOST"
|
2012-05-02 11:48:15 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT iscsi_helper tgtadm
|
2013-03-03 12:23:04 +01:00
|
|
|
iniset $CINDER_CONF DEFAULT sql_connection `database_connection_url cinder`
|
2012-05-02 11:48:15 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI
|
2013-02-20 12:45:02 -08:00
|
|
|
iniset $CINDER_CONF DEFAULT rootwrap_config "$CINDER_CONF_DIR/rootwrap.conf"
|
2013-01-28 09:53:38 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions
|
2012-09-13 14:02:01 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH
|
2013-10-10 09:08:48 -04:00
|
|
|
iniset $CINDER_CONF DEFAULT lock_path $CINDER_STATE_PATH
|
2013-05-16 16:31:12 -04:00
|
|
|
iniset $CINDER_CONF DEFAULT periodic_interval $CINDER_PERIODIC_INTERVAL
|
2014-06-25 08:51:31 -07:00
|
|
|
# NOTE(thingee): Cinder V1 API is deprecated and defaults to off as of
|
|
|
|
# Juno. Keep it enabled so we can continue testing while it's still
|
|
|
|
# supported.
|
|
|
|
iniset $CINDER_CONF DEFAULT enable_v1_api true
|
2012-07-20 13:18:17 -06:00
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
2014-07-25 12:37:41 -05:00
|
|
|
local enabled_backends=""
|
|
|
|
local default_name=""
|
|
|
|
local be be_name be_type
|
2014-07-03 10:46:57 -05:00
|
|
|
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
2014-07-25 12:37:41 -05:00
|
|
|
be_type=${be%%:*}
|
|
|
|
be_name=${be##*:}
|
|
|
|
if type configure_cinder_backend_${be_type} >/dev/null 2>&1; then
|
|
|
|
configure_cinder_backend_${be_type} ${be_name}
|
2014-07-03 10:46:57 -05:00
|
|
|
fi
|
2014-08-28 09:29:47 -05:00
|
|
|
if [[ -z "$default_name" ]]; then
|
|
|
|
default_name=$be_name
|
2014-07-03 10:46:57 -05:00
|
|
|
fi
|
2014-07-25 12:37:41 -05:00
|
|
|
enabled_backends+=$be_name,
|
2014-07-03 10:46:57 -05:00
|
|
|
done
|
|
|
|
iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*}
|
2014-07-25 13:35:53 -07:00
|
|
|
if [[ -n "$default_name" ]]; then
|
|
|
|
iniset $CINDER_CONF DEFAULT default_volume_type ${default_name}
|
2014-07-03 10:46:57 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-03-09 18:36:42 +01:00
|
|
|
if is_service_enabled swift; then
|
2014-11-17 00:03:47 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT backup_swift_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:8080/v1/AUTH_"
|
2014-03-09 18:36:42 +01:00
|
|
|
fi
|
|
|
|
|
2013-08-09 10:55:12 -04:00
|
|
|
if is_service_enabled ceilometer; then
|
2014-06-17 06:37:43 +01:00
|
|
|
iniset $CINDER_CONF DEFAULT notification_driver "messaging"
|
2013-08-09 10:55:12 -04:00
|
|
|
fi
|
|
|
|
|
2012-12-13 17:05:24 -06:00
|
|
|
if is_service_enabled tls-proxy; then
|
|
|
|
# Set the service port for a proxy to take the original
|
|
|
|
iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT
|
|
|
|
fi
|
|
|
|
|
2012-11-06 20:38:14 -06:00
|
|
|
if [ "$SYSLOG" != "False" ]; then
|
|
|
|
iniset $CINDER_CONF DEFAULT use_syslog True
|
|
|
|
fi
|
|
|
|
|
2013-01-13 17:58:12 +09:00
|
|
|
iniset_rpc_backend cinder $CINDER_CONF DEFAULT
|
2012-08-06 11:15:36 -04:00
|
|
|
|
2012-11-06 09:38:36 +01:00
|
|
|
if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then
|
|
|
|
iniset $CINDER_CONF DEFAULT secure_delete False
|
2013-01-02 16:02:54 +00:00
|
|
|
iniset $CINDER_CONF DEFAULT volume_clear none
|
2012-11-06 09:38:36 +01:00
|
|
|
fi
|
|
|
|
|
2013-08-20 14:51:08 -07:00
|
|
|
# Format logging
|
2012-08-03 11:42:51 +00:00
|
|
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
2013-08-20 14:51:08 -07:00
|
|
|
setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id"
|
2012-08-03 11:42:51 +00:00
|
|
|
fi
|
2012-11-20 15:52:21 +00:00
|
|
|
|
2014-01-23 11:31:10 -07:00
|
|
|
if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
|
|
|
|
configure_cinder_driver
|
2012-11-20 15:52:21 +00:00
|
|
|
fi
|
2013-06-26 22:31:48 +10:00
|
|
|
|
2014-09-16 17:25:33 -05:00
|
|
|
iniset $CINDER_CONF DEFAULT osapi_volume_workers "$API_WORKERS"
|
2014-03-19 17:47:42 -04:00
|
|
|
|
|
|
|
iniset $CINDER_CONF DEFAULT glance_api_servers "${GLANCE_SERVICE_PROTOCOL}://${GLANCE_HOSTPORT}"
|
|
|
|
if is_ssl_enabled_service glance || is_service_enabled tls-proxy; then
|
|
|
|
iniset $CINDER_CONF DEFAULT glance_protocol https
|
2014-10-21 18:17:48 -04:00
|
|
|
iniset $CINDER_CONF DEFAULT glance_ca_certificates_file $SSL_BUNDLE_FILE
|
2014-03-19 17:47:42 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Register SSL certificates if provided
|
|
|
|
if is_ssl_enabled_service cinder; then
|
|
|
|
ensure_certificates CINDER
|
|
|
|
|
|
|
|
iniset $CINDER_CONF DEFAULT ssl_cert_file "$CINDER_SSL_CERT"
|
|
|
|
iniset $CINDER_CONF DEFAULT ssl_key_file "$CINDER_SSL_KEY"
|
|
|
|
fi
|
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
}
|
|
|
|
|
2012-12-13 16:22:38 -06:00
|
|
|
# create_cinder_accounts() - Set up common required cinder accounts
|
|
|
|
|
|
|
|
# Tenant User Roles
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
# service cinder admin # if enabled
|
|
|
|
|
|
|
|
# Migrated from keystone_data.sh
|
2014-02-21 15:35:08 +11:00
|
|
|
function create_cinder_accounts {
|
2012-12-13 16:22:38 -06:00
|
|
|
|
|
|
|
# Cinder
|
|
|
|
if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2015-02-10 20:38:56 +11:00
|
|
|
create_service_user "cinder"
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2012-12-13 16:22:38 -06:00
|
|
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2014-07-25 12:37:41 -05:00
|
|
|
local cinder_service=$(get_or_create_service "cinder" \
|
2014-02-28 14:15:19 +01:00
|
|
|
"volume" "Cinder Volume Service")
|
2014-07-25 12:37:41 -05:00
|
|
|
get_or_create_endpoint $cinder_service "$REGION_NAME" \
|
2014-02-28 14:15:19 +01:00
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \
|
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \
|
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s"
|
|
|
|
|
2014-07-25 12:37:41 -05:00
|
|
|
local cinder_v2_service=$(get_or_create_service "cinderv2" \
|
2014-02-28 14:15:19 +01:00
|
|
|
"volumev2" "Cinder Volume Service V2")
|
2014-07-25 12:37:41 -05:00
|
|
|
get_or_create_endpoint $cinder_v2_service "$REGION_NAME" \
|
2014-02-28 14:15:19 +01:00
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \
|
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \
|
|
|
|
"$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s"
|
2012-12-13 16:22:38 -06:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
# create_cinder_cache_dir() - Part of the init_cinder() process
|
2014-02-21 15:35:08 +11:00
|
|
|
function create_cinder_cache_dir {
|
2013-02-12 10:58:28 -06:00
|
|
|
# Create cache dir
|
|
|
|
sudo mkdir -p $CINDER_AUTH_CACHE_DIR
|
|
|
|
sudo chown $STACK_USER $CINDER_AUTH_CACHE_DIR
|
|
|
|
rm -f $CINDER_AUTH_CACHE_DIR/*
|
|
|
|
}
|
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
# init_cinder() - Initialize database and volume group
|
2014-07-25 12:37:41 -05:00
|
|
|
# Uses global ``NOVA_ENABLED_APIS``
|
2014-02-21 15:35:08 +11:00
|
|
|
function init_cinder {
|
2012-05-02 11:48:15 -05:00
|
|
|
# Force nova volumes off
|
|
|
|
NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/osapi_volume,//")
|
|
|
|
|
2012-11-01 16:12:39 -04:00
|
|
|
if is_service_enabled $DATABASE_BACKENDS; then
|
2013-02-12 10:58:28 -06:00
|
|
|
# (Re)create cinder database
|
2014-10-06 13:29:39 +02:00
|
|
|
recreate_database cinder
|
2012-05-02 11:48:15 -05:00
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
# Migrate cinder database
|
2012-08-17 12:52:27 -04:00
|
|
|
$CINDER_BIN_DIR/cinder-manage db sync
|
2012-05-02 11:48:15 -05:00
|
|
|
fi
|
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
2014-07-25 12:37:41 -05:00
|
|
|
local be be_name be_type
|
2015-01-21 13:46:59 -07:00
|
|
|
local has_lvm=0
|
2014-07-03 10:46:57 -05:00
|
|
|
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
2014-07-25 12:37:41 -05:00
|
|
|
be_type=${be%%:*}
|
|
|
|
be_name=${be##*:}
|
2015-01-21 13:46:59 -07:00
|
|
|
|
|
|
|
if [[ $be_type == 'lvm' ]]; then
|
|
|
|
has_lvm=1
|
|
|
|
fi
|
|
|
|
|
2014-07-25 12:37:41 -05:00
|
|
|
if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
|
2015-01-27 17:44:44 +00:00
|
|
|
# Always init the default volume group for lvm.
|
|
|
|
if [[ "$be_type" == "lvm" ]]; then
|
|
|
|
init_default_lvm_volume_group
|
|
|
|
fi
|
2014-07-25 12:37:41 -05:00
|
|
|
init_cinder_backend_${be_type} ${be_name}
|
2012-06-14 08:51:01 +02:00
|
|
|
fi
|
2014-07-03 10:46:57 -05:00
|
|
|
done
|
2012-05-02 11:48:15 -05:00
|
|
|
fi
|
2012-10-01 14:06:44 -05:00
|
|
|
|
2015-01-21 13:46:59 -07:00
|
|
|
# Keep it simple, set a marker if there's an LVM backend
|
|
|
|
# use the created VG's to setup lvm filters
|
|
|
|
if [[ $has_lvm == 1 ]]; then
|
|
|
|
# Order matters here, not only obviously to make
|
|
|
|
# sure the VG's are created, but also some distros
|
|
|
|
# do some customizations to lvm.conf on init, we
|
|
|
|
# want to make sure we copy those over
|
|
|
|
sudo cp /etc/lvm/lvm.conf /etc/cinder/lvm.conf
|
|
|
|
configure_cinder_backend_conf_lvm
|
|
|
|
fi
|
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
mkdir -p $CINDER_STATE_PATH/volumes
|
2013-02-12 10:58:28 -06:00
|
|
|
create_cinder_cache_dir
|
2012-05-02 11:48:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# install_cinder() - Collect source and prepare
|
2014-02-21 15:35:08 +11:00
|
|
|
function install_cinder {
|
2012-05-02 11:48:15 -05:00
|
|
|
git_clone $CINDER_REPO $CINDER_DIR $CINDER_BRANCH
|
2013-04-01 16:41:39 -04:00
|
|
|
setup_develop $CINDER_DIR
|
2013-04-01 18:23:22 -05:00
|
|
|
}
|
2013-04-01 16:41:39 -04:00
|
|
|
|
2013-04-01 18:23:22 -05:00
|
|
|
# install_cinderclient() - Collect source and prepare
|
2014-02-21 15:35:08 +11:00
|
|
|
function install_cinderclient {
|
2014-11-13 17:09:28 -05:00
|
|
|
if use_library_from_git "python-cinderclient"; then
|
|
|
|
git_clone_by_name "python-cinderclient"
|
|
|
|
setup_dev_lib "python-cinderclient"
|
|
|
|
sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-cinderclient"]}/tools/,/etc/bash_completion.d/}cinder.bash_completion
|
2014-11-01 01:37:45 +01:00
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
}
|
|
|
|
|
2013-04-14 12:48:41 -07:00
|
|
|
# apply config.d approach for cinder volumes directory
|
2014-02-21 15:35:08 +11:00
|
|
|
function _configure_tgt_for_config_d {
|
2013-04-14 12:48:41 -07:00
|
|
|
if [[ ! -d /etc/tgt/stack.d/ ]]; then
|
|
|
|
sudo ln -sf $CINDER_STATE_PATH/volumes /etc/tgt/stack.d
|
|
|
|
echo "include /etc/tgt/stack.d/*" | sudo tee -a /etc/tgt/targets.conf
|
2012-09-03 15:45:53 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-05-02 11:48:15 -05:00
|
|
|
# start_cinder() - Start running processes, including screen
|
2014-02-21 15:35:08 +11:00
|
|
|
function start_cinder {
|
2014-03-19 17:47:42 -04:00
|
|
|
local service_port=$CINDER_SERVICE_PORT
|
|
|
|
local service_protocol=$CINDER_SERVICE_PROTOCOL
|
|
|
|
if is_service_enabled tls-proxy; then
|
|
|
|
service_port=$CINDER_SERVICE_PORT_INT
|
|
|
|
service_protocol="http"
|
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
if is_service_enabled c-vol; then
|
2013-04-14 12:48:41 -07:00
|
|
|
# Delete any old stack.conf
|
|
|
|
sudo rm -f /etc/tgt/conf.d/stack.conf
|
2012-12-01 10:42:46 +01:00
|
|
|
_configure_tgt_for_config_d
|
2012-12-04 12:36:34 +01:00
|
|
|
if is_ubuntu; then
|
2014-03-04 09:23:07 -05:00
|
|
|
sudo service tgt restart
|
2015-01-29 11:16:00 +01:00
|
|
|
elif is_fedora || is_suse; then
|
2012-12-06 09:56:32 +01:00
|
|
|
restart_service tgtd
|
|
|
|
else
|
|
|
|
# note for other distros: unstack.sh also uses the tgt/tgtd service
|
|
|
|
# name, and would need to be adjusted too
|
|
|
|
exit_distro_not_supported "restarting tgt"
|
2012-05-02 11:48:15 -05:00
|
|
|
fi
|
2013-09-27 13:17:34 +02:00
|
|
|
# NOTE(gfidente): ensure tgtd is running in debug mode
|
|
|
|
sudo tgtadm --mode system --op update --name debug --value on
|
2012-05-02 11:48:15 -05:00
|
|
|
fi
|
|
|
|
|
2014-08-27 14:13:58 -05:00
|
|
|
run_process c-api "$CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF"
|
2014-07-03 10:46:57 -05:00
|
|
|
echo "Waiting for Cinder API to start..."
|
2014-03-19 17:47:42 -04:00
|
|
|
if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$CINDER_SERVICE_HOST:$service_port; then
|
2014-07-03 10:46:57 -05:00
|
|
|
die $LINENO "c-api did not start"
|
|
|
|
fi
|
|
|
|
|
2014-08-27 14:13:58 -05:00
|
|
|
run_process c-sch "$CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF"
|
|
|
|
run_process c-bak "$CINDER_BIN_DIR/cinder-backup --config-file $CINDER_CONF"
|
|
|
|
run_process c-vol "$CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF"
|
2013-07-15 17:35:54 -06:00
|
|
|
|
|
|
|
# NOTE(jdg): For cinder, startup order matters. To ensure that repor_capabilities is received
|
|
|
|
# by the scheduler start the cinder-volume service last (or restart it) after the scheduler
|
|
|
|
# has started. This is a quick fix for lp bug/1189595
|
2012-12-13 17:05:24 -06:00
|
|
|
|
|
|
|
# Start proxies if enabled
|
|
|
|
if is_service_enabled c-api && is_service_enabled tls-proxy; then
|
|
|
|
start_tls_proxy '*' $CINDER_SERVICE_PORT $CINDER_SERVICE_HOST $CINDER_SERVICE_PORT_INT &
|
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
}
|
|
|
|
|
2012-09-10 14:10:27 -05:00
|
|
|
# stop_cinder() - Stop running processes
|
2014-02-21 15:35:08 +11:00
|
|
|
function stop_cinder {
|
2012-09-10 14:10:27 -05:00
|
|
|
# Kill the cinder screen windows
|
2014-07-25 12:37:41 -05:00
|
|
|
local serv
|
2013-02-21 11:20:58 +00:00
|
|
|
for serv in c-api c-bak c-sch c-vol; do
|
2014-09-09 13:46:02 +01:00
|
|
|
stop_process $serv
|
2012-09-10 14:10:27 -05:00
|
|
|
done
|
2012-05-02 11:48:15 -05:00
|
|
|
|
|
|
|
if is_service_enabled c-vol; then
|
2012-12-13 08:59:57 +01:00
|
|
|
if is_ubuntu; then
|
|
|
|
stop_service tgt
|
|
|
|
else
|
|
|
|
stop_service tgtd
|
|
|
|
fi
|
2012-05-02 11:48:15 -05:00
|
|
|
fi
|
|
|
|
}
|
2012-09-13 17:16:12 -05:00
|
|
|
|
2014-07-03 10:46:57 -05:00
|
|
|
# create_volume_types() - Create Cinder's configured volume types
|
|
|
|
function create_volume_types {
|
|
|
|
# Create volume types
|
|
|
|
if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
2014-07-25 12:37:41 -05:00
|
|
|
local be be_name be_type
|
2014-07-03 10:46:57 -05:00
|
|
|
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
2014-07-25 12:37:41 -05:00
|
|
|
be_type=${be%%:*}
|
|
|
|
be_name=${be##*:}
|
|
|
|
# openstack volume type create --property volume_backend_name="${be_type}" ${be_name}
|
|
|
|
cinder type-create ${be_name} && \
|
|
|
|
cinder type-key ${be_name} set volume_backend_name="${be_name}"
|
2014-07-03 10:46:57 -05:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compatibility for Grenade
|
|
|
|
|
|
|
|
function create_cinder_volume_group {
|
|
|
|
# During a transition period Grenade needs to have this function defined
|
|
|
|
# It is effectively a no-op in the Grenade 'target' use case
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
2013-04-08 15:38:03 -05:00
|
|
|
|
2012-09-13 17:16:12 -05:00
|
|
|
# Restore xtrace
|
|
|
|
$XTRACE
|
2013-03-29 14:34:53 -04:00
|
|
|
|
2013-10-24 11:27:02 +01:00
|
|
|
# Tell emacs to use shell-script-mode
|
|
|
|
## Local variables:
|
|
|
|
## mode: shell-script
|
|
|
|
## End:
|