Enhance devstack plugin
Add several features: - possibility to set any opt to any group - possibility to configure and enable any set of share backends Details: 1) It is possible to set any custom opt to any config group using following: $ export MANILA_OPTGROUP_foo_bar=value where 'foo' is name of config group and 'bar' is name of option. 2) 'MANILA_CONFIGURE_GROUPS' contains list of config group names used to create config groups, but 'MANILA_ENABLED_BACKENDS' is used to set config groups as Manila share back ends. Both can be set like following: $ export MANILA_ENABLED_BACKENDS=foo,bar where 'foo' and 'bar' are names of config groups with opts for some share drivers. By default they are equal. Also be attentive, if you modify both, make sure 'MANILA_CONFIGURE_GROUPS' contains all values from 'MANILA_ENABLED_BACKENDS'. 3) Two default backends are used for compatibility with previous approach. Two defaults backends have same configuration except name of backend. Both use generic driver. They can be enabled by adding values of following env vars: 'MANILA_BACKEND1_CONFIG_GROUP_NAME' and 'MANILA_BACKEND2_CONFIG_GROUP_NAME' to the env var 'MANILA_ENABLED_BACKENDS' or will be enabled if 'MANILA_ENABLED_BACKENDS' is empty. Implements bp enhance-devstack-plugin Change-Id: I910e87f00e4d309419f81469da27e70c069e6ada
This commit is contained in:
parent
542b83dafe
commit
1a2ec3da9b
@ -16,31 +16,51 @@
|
||||
# stop_manila #
|
||||
# cleanup_manila #
|
||||
|
||||
# Setting configuration file for Manila services
|
||||
# ----------------------------------------------
|
||||
# 1) It is possible to set any custom opt to any config group using following:
|
||||
# $ export MANILA_OPTGROUP_foo_bar=value
|
||||
# where 'foo' is name of config group and 'bar' is name of option.
|
||||
#
|
||||
# 2) 'MANILA_CONFIGURE_GROUPS' contains list of config group names used to create
|
||||
# config groups, but 'MANILA_ENABLED_BACKENDS' is used to set config groups as
|
||||
# Manila share back ends. Both can be set like following:
|
||||
# $ export MANILA_ENABLED_BACKENDS=foo,bar
|
||||
# where 'foo' and 'bar' are names of config groups with opts for some share
|
||||
# drivers. By default they are equal. Also be attentive, if you modify both,
|
||||
# make sure 'MANILA_CONFIGURE_GROUPS' contains all values from
|
||||
# 'MANILA_ENABLED_BACKENDS'.
|
||||
#
|
||||
# 3) Two default backends are used for compatibility with previous approach.
|
||||
# They have same configuration except name of backend. Both use generic driver.
|
||||
# They can be enabled by adding values of following env vars:
|
||||
# 'MANILA_BACKEND1_CONFIG_GROUP_NAME' and 'MANILA_BACKEND2_CONFIG_GROUP_NAME'
|
||||
# to the env var 'MANILA_ENABLED_BACKENDS' or will be enabled
|
||||
# if 'MANILA_ENABLED_BACKENDS' is empty.
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
|
||||
MANILA_REPO_ROOT=openstack
|
||||
MANILA_GIT_BASE=${MANILA_GIT_BASE:-https://github.com}
|
||||
MANILA_REPO_ROOT=${MANILA_REPO_ROOT:-openstack}
|
||||
MANILA_REPO=${MANILA_GIT_BASE}/${MANILA_REPO_ROOT}/manila.git
|
||||
MANILA_BRANCH=master
|
||||
MANILA_BRANCH=${MANILA_BRANCH:-master}
|
||||
|
||||
MANILACLIENT_REPO=${MANILA_GIT_BASE}/${MANILA_REPO_ROOT}/python-manilaclient.git
|
||||
MANILACLIENT_BRANCH=master
|
||||
MANILACLIENT_BRANCH=${MANILACLIENT_BRANCH:-master}
|
||||
|
||||
# set up default directories
|
||||
MANILA_DIR=${MANILA_DIR:=$DEST/manila}
|
||||
MANILA_LOCK_PATH=${MANILA_LOCK_PATH:=$MANILA_DIR/manila_locks}
|
||||
MANILACLIENT_DIR=${MANILACLIENT_DIR:=$DEST/python-manilaclient}
|
||||
MANILA_STATE_PATH=${MANILA_STATE_PATH:=$DATA_DIR/manila}
|
||||
MANILA_MNT_DIR=${MANILA_MNT_DIR:=$MANILA_STATE_PATH/mnt}
|
||||
MANILA_AUTH_CACHE_DIR=${MANILA_AUTH_CACHE_DIR:-/var/cache/manila}
|
||||
|
||||
MANILA_CONF_DIR=/etc/manila
|
||||
MANILA_CONF_DIR=${MANILA_CONF_DIR:-/etc/manila}
|
||||
MANILA_CONF=$MANILA_CONF_DIR/manila.conf
|
||||
MANILA_API_PASTE_INI=$MANILA_CONF_DIR/api-paste.ini
|
||||
|
||||
@ -57,37 +77,46 @@ else
|
||||
MANILA_BIN_DIR=$(get_python_exec_prefix)
|
||||
fi
|
||||
|
||||
# Support for multi backend configuration (default is no support)
|
||||
MANILA_MULTI_BACKEND=$(trueorfalse False $MANILA_MULTI_BACKEND)
|
||||
|
||||
# First share backend data, that will be used in any installation
|
||||
MANILA_BACKEND1_CONFIG_GROUP_NAME=${MANILA_BACKEND1_CONFIG_GROUP_NAME:-backend1}
|
||||
MANILA_SHARE_BACKEND1_NAME=${MANILA_SHARE_BACKEND1_NAME:-BACKEND1}
|
||||
|
||||
# Second share backend data, that will be used only with MANILA_MULTI_BACKEND=True
|
||||
MANILA_BACKEND2_CONFIG_GROUP_NAME=${MANILA_BACKEND2_CONFIG_GROUP_NAME:-backend2}
|
||||
MANILA_SHARE_BACKEND2_NAME=${MANILA_SHARE_BACKEND2_NAME:-BACKEND2}
|
||||
|
||||
# Common opts
|
||||
SHARE_NAME_PREFIX=${SHARE_NAME_PREFIX:-share-}
|
||||
SHARE_DRIVER=${SHARE_DRIVER:-manila.share.drivers.generic.GenericShareDriver}
|
||||
|
||||
MANILA_SCHEDULER_DRIVER=${MANILA_SCHEDULER_DRIVER:-manila.scheduler.filter_scheduler.FilterScheduler}
|
||||
|
||||
eval USER_HOME=~
|
||||
# Common info for Generic driver(s)
|
||||
SHARE_DRIVER=${SHARE_DRIVER:-manila.share.drivers.generic.GenericShareDriver}
|
||||
|
||||
# These are used by generic driver
|
||||
eval USER_HOME=~
|
||||
MANILA_PATH_TO_PUBLIC_KEY=${MANILA_PATH_TO_PUBLIC_KEY:-"$USER_HOME/.ssh/id_rsa.pub"}
|
||||
MANILA_PATH_TO_PRIVATE_KEY=${MANILA_PATH_TO_PRIVATE_KEY:-"$USER_HOME/.ssh/id_rsa"}
|
||||
|
||||
MANILA_SERVICE_INSTANCE_USER=${MANILA_SERVICE_INSTANCE_USER:-"ubuntu"}
|
||||
MANILA_SERVICE_INSTANCE_PASSWORD=${MANILA_SERVICE_INSTANCE_PASSWORD:-"ubuntu"}
|
||||
MANILA_SERVICE_IMAGE_URL=${MANILA_SERVICE_IMAGE_URL:-"https://www.dropbox.com/s/vi5oeh10q1qkckh/ubuntu_1204_nfs_cifs.qcow2"}
|
||||
MANILA_SERVICE_IMAGE_NAME=${MANILA_SERVICE_IMAGE_NAME:-"ubuntu_1204_nfs_cifs"}
|
||||
|
||||
MANILA_SERVICE_VM_FLAVOR_REF=${MANILA_SERVICE_VM_FLAVOR_REF:-100}
|
||||
MANILA_SERVICE_VM_FLAVOR_NAME=${MANILA_SERVICE_VM_FLAVOR_NAME:-"manila-service-flavor"}
|
||||
MANILA_SERVICE_VM_FLAVOR_RAM=${MANILA_SERVICE_VM_FLAVOR_RAM:-64}
|
||||
MANILA_SERVICE_VM_FLAVOR_DISK=${MANILA_SERVICE_VM_FLAVOR_DISK:-0}
|
||||
MANILA_SERVICE_VM_FLAVOR_VCPUS=${MANILA_SERVICE_VM_FLAVOR_VCPUS:-1}
|
||||
|
||||
# Support for multi backend configuration (default is no support)
|
||||
MANILA_MULTI_BACKEND=$(trueorfalse False $MANILA_MULTI_BACKEND)
|
||||
DEPRECATED_TEXT="$DEPRECATED_TEXT\n'MANILA_MULTI_BACKEND' is deprecated,
|
||||
it makes influence only when is set to True and 'MANILA_ENABLED_BACKENDS' is not set.
|
||||
Use 'MANILA_ENABLED_BACKENDS' instead if you want to use custom setting.
|
||||
Set there a list of back end names to be enabled.\n
|
||||
To configure custom back ends use (any opt in any group can be set in this way) following:
|
||||
MANILA_OPTGROUP_foo_bar=value
|
||||
where 'foo' is name of config group and 'bar' is name of option.\n"
|
||||
|
||||
# First share backend data, that will be used in any installation
|
||||
MANILA_BACKEND1_CONFIG_GROUP_NAME=${MANILA_BACKEND1_CONFIG_GROUP_NAME:-generic1} # deprecated
|
||||
MANILA_SHARE_BACKEND1_NAME=${MANILA_SHARE_BACKEND1_NAME:-GENERIC1} # deprecated
|
||||
|
||||
# Second share backend data, that will be used only with MANILA_MULTI_BACKEND=True
|
||||
MANILA_BACKEND2_CONFIG_GROUP_NAME=${MANILA_BACKEND2_CONFIG_GROUP_NAME:-generic2} # deprecated
|
||||
MANILA_SHARE_BACKEND2_NAME=${MANILA_SHARE_BACKEND2_NAME:-GENERIC2} # deprecated
|
||||
|
||||
# cleanup_manila - Remove residual data files, anything left over from previous
|
||||
# runs that a clean run would need to clean up
|
||||
function cleanup_manila {
|
||||
@ -96,17 +125,22 @@ function cleanup_manila {
|
||||
:
|
||||
}
|
||||
|
||||
function add_share_backend {
|
||||
# Expects two args:
|
||||
# 1: config group name
|
||||
# 2: share_backend_name
|
||||
iniset $MANILA_CONF $1 share_driver $SHARE_DRIVER
|
||||
iniset $MANILA_CONF $1 share_backend_name $2
|
||||
iniset $MANILA_CONF $1 path_to_public_key $MANILA_PATH_TO_PUBLIC_KEY
|
||||
iniset $MANILA_CONF $1 path_to_private_key $MANILA_PATH_TO_PRIVATE_KEY
|
||||
iniset $MANILA_CONF $1 service_image_name $MANILA_SERVICE_IMAGE_NAME
|
||||
iniset $MANILA_CONF $1 service_instance_user $MANILA_SERVICE_INSTANCE_USER
|
||||
iniset $MANILA_CONF $1 service_instance_password $MANILA_SERVICE_INSTANCE_PASSWORD
|
||||
function configure_default_backends {
|
||||
# Configure two default backends with generic drivers onboard
|
||||
for group_name in $MANILA_BACKEND1_CONFIG_GROUP_NAME $MANILA_BACKEND2_CONFIG_GROUP_NAME
|
||||
do
|
||||
iniset $MANILA_CONF $group_name share_driver $SHARE_DRIVER
|
||||
if [ "$MANILA_BACKEND1_CONFIG_GROUP_NAME" == "$group_name" ]; then
|
||||
iniset $MANILA_CONF $group_name share_backend_name $MANILA_SHARE_BACKEND1_NAME
|
||||
else
|
||||
iniset $MANILA_CONF $group_name share_backend_name $MANILA_SHARE_BACKEND2_NAME
|
||||
fi
|
||||
iniset $MANILA_CONF $group_name path_to_public_key $MANILA_PATH_TO_PUBLIC_KEY
|
||||
iniset $MANILA_CONF $group_name path_to_private_key $MANILA_PATH_TO_PRIVATE_KEY
|
||||
iniset $MANILA_CONF $group_name service_image_name $MANILA_SERVICE_IMAGE_NAME
|
||||
iniset $MANILA_CONF $group_name service_instance_user $MANILA_SERVICE_INSTANCE_USER
|
||||
iniset $MANILA_CONF $group_name service_instance_password $MANILA_SERVICE_INSTANCE_PASSWORD
|
||||
done
|
||||
}
|
||||
|
||||
# configure_manila - Set config files, create data dirs, etc
|
||||
@ -183,14 +217,18 @@ function configure_manila {
|
||||
|
||||
iniset $MANILA_CONF DEFAULT lock_path $MANILA_LOCK_PATH
|
||||
|
||||
add_share_backend $MANILA_BACKEND1_CONFIG_GROUP_NAME $MANILA_SHARE_BACKEND1_NAME
|
||||
enabled_backends=$MANILA_BACKEND1_CONFIG_GROUP_NAME
|
||||
|
||||
# Note: set up config group does not mean that this backend will be enabled.
|
||||
# To enable it, specify its name explicitly using "enabled_share_backends" opt.
|
||||
configure_default_backends
|
||||
default_backends=$MANILA_BACKEND1_CONFIG_GROUP_NAME
|
||||
if [ "$MANILA_MULTI_BACKEND" = "True" ]; then
|
||||
add_share_backend $MANILA_BACKEND2_CONFIG_GROUP_NAME $MANILA_SHARE_BACKEND2_NAME
|
||||
enabled_backends+=,$MANILA_BACKEND2_CONFIG_GROUP_NAME
|
||||
default_backends+=,$MANILA_BACKEND2_CONFIG_GROUP_NAME
|
||||
fi
|
||||
iniset $MANILA_CONF DEFAULT enabled_share_backends $enabled_backends
|
||||
if [ ! $MANILA_ENABLED_BACKENDS ]; then
|
||||
# If $MANILA_ENABLED_BACKENDS is not set, use configured backends by default
|
||||
MANILA_ENABLED_BACKENDS=$default_backends
|
||||
fi
|
||||
iniset $MANILA_CONF DEFAULT enabled_share_backends $MANILA_ENABLED_BACKENDS
|
||||
|
||||
if [ ! -f $MANILA_PATH_TO_PRIVATE_KEY ];
|
||||
then ssh-keygen -N "" -t rsa -f $MANILA_PATH_TO_PRIVATE_KEY;
|
||||
@ -215,6 +253,20 @@ function configure_manila {
|
||||
iniset $MANILA_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)d TRACE %(name)s [01;35m%(instance)s[00m"
|
||||
fi
|
||||
|
||||
MANILA_CONFIGURE_GROUPS=${MANILA_CONFIGURE_GROUPS:-"$MANILA_ENABLED_BACKENDS"}
|
||||
if [[ -n "$MANILA_CONFIGURE_GROUPS" ]]; then
|
||||
for be in ${MANILA_CONFIGURE_GROUPS//,/ }; do
|
||||
# get backend_specific opt values
|
||||
prefix=MANILA_OPTGROUP_$be\_
|
||||
compgen -v | grep $prefix | while read -r line ; do
|
||||
# parse it to opt names and values
|
||||
opt=${line#$prefix}
|
||||
opt_name=${opt%%=*}
|
||||
opt_value=${opt##*=}
|
||||
iniset $MANILA_CONF $be $opt_name $opt_value
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function create_manila_service_flavor {
|
||||
|
Loading…
Reference in New Issue
Block a user