2014-12-05 14:25:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-09-17 11:22:21 -05:00
|
|
|
# lib/glance
|
2012-12-21 11:03:37 -06:00
|
|
|
# Functions to control the configuration and operation of the **Glance** service
|
2012-09-17 11:22:21 -05:00
|
|
|
|
|
|
|
# Dependencies:
|
2013-10-24 11:27:02 +01:00
|
|
|
#
|
|
|
|
# - ``functions`` file
|
|
|
|
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
|
|
|
|
# - ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
|
|
|
|
# - ``SERVICE_HOST``
|
|
|
|
# - ``KEYSTONE_TOKEN_FORMAT`` must be defined
|
2012-09-17 11:22:21 -05:00
|
|
|
|
|
|
|
# ``stack.sh`` calls the entry points in this order:
|
|
|
|
#
|
2013-10-24 11:27:02 +01:00
|
|
|
# - install_glance
|
|
|
|
# - configure_glance
|
|
|
|
# - init_glance
|
|
|
|
# - start_glance
|
|
|
|
# - stop_glance
|
|
|
|
# - cleanup_glance
|
2012-09-17 11:22:21 -05:00
|
|
|
|
|
|
|
# Save trace setting
|
2015-10-13 11:03:03 +11:00
|
|
|
_XTRACE_GLANCE=$(set +o | grep xtrace)
|
2012-09-17 11:22:21 -05:00
|
|
|
set +o xtrace
|
|
|
|
|
|
|
|
|
|
|
|
# Defaults
|
|
|
|
# --------
|
|
|
|
|
|
|
|
# Set up default directories
|
2014-11-13 17:09:28 -05:00
|
|
|
GITDIR["python-glanceclient"]=$DEST/python-glanceclient
|
2014-11-19 15:19:51 -05:00
|
|
|
GITDIR["glance_store"]=$DEST/glance_store
|
2012-09-17 11:22:21 -05:00
|
|
|
GLANCE_DIR=$DEST/glance
|
2015-02-17 15:38:16 -06:00
|
|
|
|
|
|
|
# Glance virtual environment
|
|
|
|
if [[ ${USE_VENV} = True ]]; then
|
|
|
|
PROJECT_VENV["glance"]=${GLANCE_DIR}.venv
|
|
|
|
GLANCE_BIN_DIR=${PROJECT_VENV["glance"]}/bin
|
|
|
|
else
|
|
|
|
GLANCE_BIN_DIR=$(get_python_exec_prefix)
|
|
|
|
fi
|
|
|
|
|
2019-10-17 09:02:41 +00:00
|
|
|
# Glance multi-store configuration
|
|
|
|
# Boolean flag to enable multiple store configuration for glance
|
|
|
|
GLANCE_ENABLE_MULTIPLE_STORES=$(trueorfalse False GLANCE_ENABLE_MULTIPLE_STORES)
|
|
|
|
|
|
|
|
# Comma separated list for configuring multiple file stores of glance,
|
|
|
|
# for example; GLANCE_MULTIPLE_FILE_STORES = fast,cheap,slow
|
|
|
|
GLANCE_MULTIPLE_FILE_STORES=${GLANCE_MULTIPLE_FILE_STORES:-fast}
|
|
|
|
|
|
|
|
# Default store/backend for glance, must be one of the store specified
|
|
|
|
# in GLANCE_MULTIPLE_FILE_STORES option.
|
|
|
|
GLANCE_DEFAULT_BACKEND=${GLANCE_DEFAULT_BACKEND:-fast}
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
GLANCE_CACHE_DIR=${GLANCE_CACHE_DIR:=$DATA_DIR/glance/cache}
|
2019-10-17 09:02:41 +00:00
|
|
|
|
|
|
|
# File path for each store specified in GLANCE_MULTIPLE_FILE_STORES, the store
|
|
|
|
# identifier will be appended to this path at runtime. If GLANCE_MULTIPLE_FILE_STORES
|
|
|
|
# has fast,cheap specified then filepath will be generated like $DATA_DIR/glance/fast
|
|
|
|
# and $DATA_DIR/glance/cheap.
|
|
|
|
GLANCE_MULTISTORE_FILE_IMAGE_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/glance}
|
2012-09-17 11:22:21 -05:00
|
|
|
GLANCE_IMAGE_DIR=${GLANCE_IMAGE_DIR:=$DATA_DIR/glance/images}
|
2017-04-25 01:30:10 -04:00
|
|
|
GLANCE_LOCK_DIR=${GLANCE_LOCK_DIR:=$DATA_DIR/glance/locks}
|
2019-10-17 09:02:41 +00:00
|
|
|
GLANCE_STAGING_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/os_glance_staging_store}
|
|
|
|
GLANCE_TASKS_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/os_glance_tasks_store}
|
2012-09-17 11:22:21 -05:00
|
|
|
|
|
|
|
GLANCE_CONF_DIR=${GLANCE_CONF_DIR:-/etc/glance}
|
2014-09-06 07:06:46 -04:00
|
|
|
GLANCE_METADEF_DIR=$GLANCE_CONF_DIR/metadefs
|
2012-09-17 11:22:21 -05:00
|
|
|
GLANCE_REGISTRY_CONF=$GLANCE_CONF_DIR/glance-registry.conf
|
|
|
|
GLANCE_API_CONF=$GLANCE_CONF_DIR/glance-api.conf
|
|
|
|
GLANCE_REGISTRY_PASTE_INI=$GLANCE_CONF_DIR/glance-registry-paste.ini
|
|
|
|
GLANCE_API_PASTE_INI=$GLANCE_CONF_DIR/glance-api-paste.ini
|
|
|
|
GLANCE_CACHE_CONF=$GLANCE_CONF_DIR/glance-cache.conf
|
2013-09-09 14:31:37 +02:00
|
|
|
GLANCE_SCHEMA_JSON=$GLANCE_CONF_DIR/schema-image.json
|
2015-06-19 02:52:41 +00:00
|
|
|
GLANCE_SWIFT_STORE_CONF=$GLANCE_CONF_DIR/glance-swift-store.conf
|
2017-12-14 13:23:41 +05:30
|
|
|
GLANCE_IMAGE_IMPORT_CONF=$GLANCE_CONF_DIR/glance-image-import.conf
|
2016-07-15 22:53:17 -04:00
|
|
|
GLANCE_V1_ENABLED=${GLANCE_V1_ENABLED:-False}
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2017-04-13 10:11:48 -04:00
|
|
|
if is_service_enabled tls-proxy; then
|
2014-03-19 17:47:42 -04:00
|
|
|
GLANCE_SERVICE_PROTOCOL="https"
|
|
|
|
fi
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
# Glance connection info. Note the port must be specified.
|
2014-03-19 17:47:42 -04:00
|
|
|
GLANCE_SERVICE_HOST=${GLANCE_SERVICE_HOST:-$SERVICE_HOST}
|
2017-09-19 10:52:32 +00:00
|
|
|
GLANCE_SERVICE_LISTEN_ADDRESS=${GLANCE_SERVICE_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)}
|
2014-03-19 17:47:42 -04:00
|
|
|
GLANCE_SERVICE_PORT=${GLANCE_SERVICE_PORT:-9292}
|
|
|
|
GLANCE_SERVICE_PORT_INT=${GLANCE_SERVICE_PORT_INT:-19292}
|
|
|
|
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_SERVICE_HOST:$GLANCE_SERVICE_PORT}
|
|
|
|
GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
|
|
|
GLANCE_REGISTRY_PORT=${GLANCE_REGISTRY_PORT:-9191}
|
|
|
|
GLANCE_REGISTRY_PORT_INT=${GLANCE_REGISTRY_PORT_INT:-19191}
|
2017-06-23 22:32:37 +00:00
|
|
|
GLANCE_UWSGI=$GLANCE_BIN_DIR/glance-wsgi-api
|
2017-07-12 10:09:48 +08:00
|
|
|
GLANCE_UWSGI_CONF=$GLANCE_CONF_DIR/glance-uwsgi.ini
|
2017-06-23 22:32:37 +00:00
|
|
|
# If wsgi mode is uwsgi run glance under uwsgi, else default to eventlet
|
|
|
|
# TODO(mtreinish): Remove the eventlet path here and in all the similar
|
|
|
|
# conditionals below after the Pike release
|
|
|
|
if [[ "$WSGI_MODE" == "uwsgi" ]]; then
|
|
|
|
GLANCE_URL="$GLANCE_SERVICE_PROTOCOL://$GLANCE_SERVICE_HOST/image"
|
|
|
|
else
|
|
|
|
GLANCE_URL="$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT"
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2013-04-08 15:38:03 -05:00
|
|
|
# Functions
|
|
|
|
# ---------
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2014-01-15 15:04:49 -06:00
|
|
|
# Test if any Glance services are enabled
|
|
|
|
# is_glance_enabled
|
|
|
|
function is_glance_enabled {
|
2017-05-30 14:11:09 -07:00
|
|
|
[[ ,${DISABLED_SERVICES} =~ ,"glance" ]] && return 1
|
2014-01-15 15:04:49 -06:00
|
|
|
[[ ,${ENABLED_SERVICES} =~ ,"g-" ]] && return 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
# cleanup_glance() - 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_glance {
|
2012-09-17 11:22:21 -05:00
|
|
|
# delete image files (glance)
|
2017-11-17 19:52:29 +01:00
|
|
|
sudo rm -rf $GLANCE_CACHE_DIR $GLANCE_IMAGE_DIR
|
2019-10-17 09:02:41 +00:00
|
|
|
|
|
|
|
# Cleanup multiple stores directories
|
|
|
|
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
|
|
|
|
local store file_dir
|
|
|
|
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
|
|
|
|
file_dir="${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/${store}/"
|
|
|
|
sudo rm -rf $file_dir
|
|
|
|
done
|
|
|
|
|
|
|
|
# Cleanup reserved stores directories
|
|
|
|
sudo rm -rf $GLANCE_STAGING_DIR $GLANCE_TASKS_DIR
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# configure_glance() - Set config files, create data dirs, etc
|
2014-02-21 15:35:08 +11:00
|
|
|
function configure_glance {
|
2015-03-16 13:52:19 -05:00
|
|
|
sudo install -d -o $STACK_USER $GLANCE_CONF_DIR $GLANCE_METADEF_DIR
|
2014-09-06 07:06:46 -04:00
|
|
|
|
2017-12-11 18:07:50 -05:00
|
|
|
# Set non-default configuration options for registry
|
2013-08-10 09:56:16 -05:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
2015-06-16 13:14:31 -04:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
|
2018-06-02 09:34:20 -04:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT workers $API_WORKERS
|
2015-10-07 14:06:26 +11:00
|
|
|
local dburl
|
|
|
|
dburl=`database_connection_url glance`
|
2015-06-19 11:46:36 +02:00
|
|
|
iniset $GLANCE_REGISTRY_CONF database connection $dburl
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT use_syslog $SYSLOG
|
|
|
|
iniset $GLANCE_REGISTRY_CONF paste_deploy flavor keystone
|
2017-11-17 19:52:29 +01:00
|
|
|
configure_keystone_authtoken_middleware $GLANCE_REGISTRY_CONF glance
|
2017-03-05 13:07:39 -05:00
|
|
|
iniset $GLANCE_REGISTRY_CONF oslo_messaging_notifications driver messagingv2
|
2015-03-14 12:39:14 -05:00
|
|
|
iniset_rpc_backend glance $GLANCE_REGISTRY_CONF
|
2015-10-22 15:47:49 -04:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2019-10-17 09:02:41 +00:00
|
|
|
# Configure multiple stores
|
|
|
|
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
|
|
|
|
local store enabled_backends
|
|
|
|
enabled_backends=""
|
|
|
|
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
|
|
|
|
enabled_backends+="${store}:file,"
|
|
|
|
done
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT enabled_backends ${enabled_backends::-1}
|
|
|
|
fi
|
|
|
|
|
2017-12-11 18:07:50 -05:00
|
|
|
# Set non-default configuration options for the API server
|
2013-08-10 09:56:16 -05:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
2015-06-19 11:46:36 +02:00
|
|
|
iniset $GLANCE_API_CONF database connection $dburl
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT use_syslog $SYSLOG
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/
|
2019-04-30 10:12:51 +08:00
|
|
|
iniset $GLANCE_API_CONF oslo_concurrency lock_path $GLANCE_LOCK_DIR
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_API_CONF paste_deploy flavor keystone+cachemanagement
|
2017-11-17 19:52:29 +01:00
|
|
|
configure_keystone_authtoken_middleware $GLANCE_API_CONF glance
|
2017-03-05 13:07:39 -05:00
|
|
|
iniset $GLANCE_API_CONF oslo_messaging_notifications driver messagingv2
|
2015-03-14 12:39:14 -05:00
|
|
|
iniset_rpc_backend glance $GLANCE_API_CONF
|
2013-08-15 18:06:59 +01:00
|
|
|
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT container_formats "ami,ari,aki,bare,ovf,tgz"
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT disk_formats "ami,ari,aki,vhd,raw,iso"
|
|
|
|
fi
|
2014-11-24 14:20:35 +04:00
|
|
|
if [ "$VIRT_DRIVER" = 'libvirt' ] && [ "$LIBVIRT_TYPE" = 'parallels' ]; then
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT disk_formats "ami,ari,aki,vhd,vmdk,raw,qcow2,vdi,iso,ploop"
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2016-05-11 12:49:07 -05:00
|
|
|
# NOTE(flaper87): To uncomment as soon as all services consuming Glance are
|
|
|
|
# able to consume V2 entirely.
|
|
|
|
if [ "$GLANCE_V1_ENABLED" != "True" ]; then
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT enable_v1_api False
|
|
|
|
fi
|
|
|
|
|
2019-10-17 09:02:41 +00:00
|
|
|
# Glance multiple store Store specific configs
|
|
|
|
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
|
|
|
|
iniset $GLANCE_API_CONF glance_store default_backend $GLANCE_DEFAULT_BACKEND
|
|
|
|
local store
|
|
|
|
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
|
|
|
|
iniset $GLANCE_API_CONF $store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/${store}/"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Glance configure reserved stores
|
|
|
|
iniset $GLANCE_API_CONF os_glance_staging_store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/os_glance_staging_store/"
|
|
|
|
iniset $GLANCE_API_CONF os_glance_tasks_store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/os_glance_tasks_store/"
|
|
|
|
else
|
|
|
|
# Store specific configs
|
|
|
|
iniset $GLANCE_API_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
|
|
|
|
fi
|
2017-09-19 10:52:32 +00:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT registry_host $(ipv6_unquote $GLANCE_SERVICE_HOST)
|
2014-09-03 11:51:00 +02:00
|
|
|
|
2016-04-29 14:08:51 +03:00
|
|
|
# CORS feature support - to allow calls from Horizon by default
|
|
|
|
if [ -n "$GLANCE_CORS_ALLOWED_ORIGIN" ]; then
|
|
|
|
iniset $GLANCE_API_CONF cors allowed_origin "$GLANCE_CORS_ALLOWED_ORIGIN"
|
|
|
|
else
|
|
|
|
iniset $GLANCE_API_CONF cors allowed_origin "http://$SERVICE_HOST"
|
|
|
|
fi
|
|
|
|
|
2019-10-17 09:02:41 +00:00
|
|
|
# No multiple stores for swift yet
|
2013-03-29 10:51:01 -05:00
|
|
|
# Store the images in swift if enabled.
|
|
|
|
if is_service_enabled s-proxy; then
|
2014-09-03 11:51:00 +02:00
|
|
|
iniset $GLANCE_API_CONF glance_store default_store swift
|
|
|
|
iniset $GLANCE_API_CONF glance_store swift_store_create_container_on_put True
|
2017-01-02 09:30:16 -05:00
|
|
|
if python3_enabled; then
|
|
|
|
iniset $GLANCE_API_CONF glance_store swift_store_auth_insecure True
|
|
|
|
fi
|
2015-06-19 02:52:41 +00:00
|
|
|
|
|
|
|
iniset $GLANCE_API_CONF glance_store swift_store_config_file $GLANCE_SWIFT_STORE_CONF
|
|
|
|
iniset $GLANCE_API_CONF glance_store default_swift_reference ref1
|
2014-09-03 11:51:00 +02:00
|
|
|
iniset $GLANCE_API_CONF glance_store stores "file, http, swift"
|
2015-10-22 15:47:49 -04:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
|
2015-06-19 02:52:41 +00:00
|
|
|
|
2016-02-17 06:23:36 -05:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 user $SERVICE_PROJECT_NAME:glance-swift
|
2015-12-15 16:14:26 +03:00
|
|
|
|
2015-06-19 02:52:41 +00:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 key $SERVICE_PASSWORD
|
2017-01-02 09:30:16 -05:00
|
|
|
if python3_enabled; then
|
|
|
|
# NOTE(dims): Currently the glance_store+swift does not support either an insecure flag
|
|
|
|
# or ability to specify the CACERT. So fallback to http:// url
|
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_address ${KEYSTONE_SERVICE_URI/https/http}/v3
|
|
|
|
else
|
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_address $KEYSTONE_SERVICE_URI/v3
|
|
|
|
fi
|
2015-08-05 15:53:21 +10:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_version 3
|
2013-03-29 10:51:01 -05:00
|
|
|
fi
|
|
|
|
|
2017-06-23 22:32:37 +00:00
|
|
|
# We need to tell glance what it's public endpoint is so that the version
|
|
|
|
# discovery document will be correct
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT public_endpoint $GLANCE_URL
|
|
|
|
|
2014-03-19 17:47:42 -04:00
|
|
|
if is_service_enabled tls-proxy; then
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT bind_port $GLANCE_SERVICE_PORT_INT
|
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT bind_port $GLANCE_REGISTRY_PORT_INT
|
2015-05-26 15:33:45 -04:00
|
|
|
|
|
|
|
iniset $GLANCE_API_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
|
|
|
|
iniset $GLANCE_REGISTRY_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
|
2014-03-19 17:47:42 -04:00
|
|
|
fi
|
|
|
|
|
2017-04-13 10:11:48 -04:00
|
|
|
if is_service_enabled tls-proxy; then
|
2014-03-19 17:47:42 -04:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT registry_client_protocol https
|
|
|
|
fi
|
|
|
|
|
2015-02-11 19:34:09 +00:00
|
|
|
# Format logging
|
2016-04-05 12:08:57 -04:00
|
|
|
setup_logging $GLANCE_API_CONF
|
|
|
|
setup_logging $GLANCE_REGISTRY_CONF
|
2015-02-11 19:34:09 +00:00
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
|
|
|
|
cp -p $GLANCE_DIR/etc/glance-api-paste.ini $GLANCE_API_PASTE_INI
|
|
|
|
|
2017-12-11 18:07:50 -05:00
|
|
|
# Set non-default configuration options for the glance-cache
|
2013-08-10 09:56:16 -05:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT use_syslog $SYSLOG
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/
|
2017-04-20 06:54:51 -04:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT auth_url $KEYSTONE_AUTH_URI
|
2016-02-17 06:23:36 -05:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT admin_tenant_name $SERVICE_PROJECT_NAME
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT admin_user glance
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT admin_password $SERVICE_PASSWORD
|
2017-09-19 10:52:32 +00:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT registry_host $(ipv6_unquote $GLANCE_SERVICE_HOST)
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2014-09-03 11:51:00 +02:00
|
|
|
# Store specific confs
|
|
|
|
iniset $GLANCE_CACHE_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
|
|
|
|
|
2017-12-14 13:23:41 +05:30
|
|
|
# Set default configuration options for the glance-image-import
|
|
|
|
iniset $GLANCE_IMAGE_IMPORT_CONF image_import_opts image_import_plugins []
|
|
|
|
iniset $GLANCE_IMAGE_IMPORT_CONF inject_metadata_properties ignore_user_roles admin
|
|
|
|
iniset $GLANCE_IMAGE_IMPORT_CONF inject_metadata_properties inject
|
|
|
|
|
2013-09-09 14:31:37 +02:00
|
|
|
cp -p $GLANCE_DIR/etc/schema-image.json $GLANCE_SCHEMA_JSON
|
2014-09-06 07:06:46 -04:00
|
|
|
|
|
|
|
cp -p $GLANCE_DIR/etc/metadefs/*.json $GLANCE_METADEF_DIR
|
2014-03-19 17:47:42 -04:00
|
|
|
|
2017-04-13 10:11:48 -04:00
|
|
|
if is_service_enabled tls-proxy; then
|
2014-03-19 17:47:42 -04:00
|
|
|
CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST}
|
|
|
|
CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776}
|
|
|
|
|
2019-02-07 16:46:49 -05:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/%(project_id)s"
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/%(project_id)s"
|
2014-03-19 17:47:42 -04:00
|
|
|
fi
|
2017-06-23 22:32:37 +00:00
|
|
|
|
|
|
|
if [[ "$WSGI_MODE" == "uwsgi" ]]; then
|
|
|
|
write_local_uwsgi_http_config "$GLANCE_UWSGI_CONF" "$GLANCE_UWSGI" "/image"
|
|
|
|
else
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
2014-03-03 14:31:29 -06:00
|
|
|
# create_glance_accounts() - Set up common required glance accounts
|
|
|
|
|
2015-03-31 00:28:39 -07:00
|
|
|
# Project User Roles
|
|
|
|
# ---------------------------------------------------------------------
|
2016-02-17 06:23:36 -05:00
|
|
|
# SERVICE_PROJECT_NAME glance service
|
|
|
|
# SERVICE_PROJECT_NAME glance-swift ResellerAdmin (if Swift is enabled)
|
|
|
|
# SERVICE_PROJECT_NAME glance-search search (if Search is enabled)
|
2014-03-03 14:31:29 -06:00
|
|
|
|
|
|
|
function create_glance_accounts {
|
|
|
|
if is_service_enabled g-api; then
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2015-01-28 14:28:01 +10:00
|
|
|
create_service_user "glance"
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2014-03-03 14:31:29 -06:00
|
|
|
# required for swift access
|
|
|
|
if is_service_enabled s-proxy; then
|
2016-01-21 16:08:14 -06:00
|
|
|
create_service_user "glance-swift" "ResellerAdmin"
|
2014-03-03 14:31:29 -06:00
|
|
|
fi
|
2014-02-28 14:15:19 +01:00
|
|
|
|
2016-02-10 07:25:24 -05:00
|
|
|
get_or_create_service "glance" "image" "Glance Image Service"
|
2016-04-23 01:45:40 +00:00
|
|
|
get_or_create_endpoint \
|
2016-02-10 07:25:24 -05:00
|
|
|
"image" \
|
|
|
|
"$REGION_NAME" \
|
2017-06-23 22:32:37 +00:00
|
|
|
"$GLANCE_URL"
|
2016-09-13 22:41:41 +02:00
|
|
|
|
|
|
|
# Note(frickler): Crude workaround for https://bugs.launchpad.net/glance-store/+bug/1620999
|
|
|
|
service_domain_id=$(get_or_create_domain $SERVICE_DOMAIN_NAME)
|
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 project_domain_id $service_domain_id
|
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 user_domain_id $service_domain_id
|
2014-03-03 14:31:29 -06:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
# init_glance() - Initialize databases, etc.
|
2014-02-21 15:35:08 +11:00
|
|
|
function init_glance {
|
2012-09-17 11:22:21 -05:00
|
|
|
# Delete existing images
|
|
|
|
rm -rf $GLANCE_IMAGE_DIR
|
|
|
|
mkdir -p $GLANCE_IMAGE_DIR
|
|
|
|
|
2020-01-19 12:41:14 +01:00
|
|
|
# (Re)create glance database
|
|
|
|
recreate_database glance
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2020-01-19 12:41:14 +01:00
|
|
|
time_start "dbsync"
|
|
|
|
# Migrate glance database
|
|
|
|
$GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_sync
|
2012-10-01 14:06:44 -05:00
|
|
|
|
2020-01-19 12:41:14 +01:00
|
|
|
# Load metadata definitions
|
|
|
|
$GLANCE_BIN_DIR/glance-manage --config-file $GLANCE_CONF_DIR/glance-api.conf db_load_metadefs
|
|
|
|
time_stop "dbsync"
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# install_glanceclient() - Collect source and prepare
|
2014-02-21 15:35:08 +11:00
|
|
|
function install_glanceclient {
|
2014-11-13 17:09:28 -05:00
|
|
|
if use_library_from_git "python-glanceclient"; then
|
|
|
|
git_clone_by_name "python-glanceclient"
|
|
|
|
setup_dev_lib "python-glanceclient"
|
2014-11-20 13:09:03 +00:00
|
|
|
sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-glanceclient"]}/tools/,/etc/bash_completion.d/}glance.bash_completion
|
2014-11-01 01:37:45 +01:00
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# install_glance() - Collect source and prepare
|
2014-02-21 15:35:08 +11:00
|
|
|
function install_glance {
|
2020-03-30 09:56:53 +02:00
|
|
|
local glance_store_extras=()
|
|
|
|
|
|
|
|
if is_service_enabled cinder; then
|
|
|
|
glance_store_extras=("cinder" "${glance_store_extras[@]}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if is_service_enabled swift; then
|
|
|
|
glance_store_extras=("swift" "${glance_store_extras[@]}")
|
|
|
|
fi
|
|
|
|
|
2014-09-09 09:37:42 +02:00
|
|
|
# Install glance_store from git so we make sure we're testing
|
|
|
|
# the latest code.
|
2014-11-13 13:23:27 -05:00
|
|
|
if use_library_from_git "glance_store"; then
|
|
|
|
git_clone_by_name "glance_store"
|
2020-03-30 09:56:53 +02:00
|
|
|
setup_dev_lib "glance_store" $(join_extras "${glance_store_extras[@]}")
|
|
|
|
else
|
|
|
|
# we still need to pass extras
|
|
|
|
pip_install_gr_extras glance-store $(join_extras "${glance_store_extras[@]}")
|
2014-11-13 13:23:27 -05:00
|
|
|
fi
|
2014-09-09 09:37:42 +02:00
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH
|
2015-03-31 00:28:39 -07:00
|
|
|
|
|
|
|
setup_develop $GLANCE_DIR
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
2017-08-30 14:16:58 -04:00
|
|
|
# start_glance() - Start running processes
|
2014-02-21 15:35:08 +11:00
|
|
|
function start_glance {
|
2014-03-19 17:47:42 -04:00
|
|
|
local service_protocol=$GLANCE_SERVICE_PROTOCOL
|
|
|
|
if is_service_enabled tls-proxy; then
|
2017-06-23 22:32:37 +00:00
|
|
|
if [[ "$WSGI_MODE" != "uwsgi" ]]; then
|
|
|
|
start_tls_proxy glance-service '*' $GLANCE_SERVICE_PORT $GLANCE_SERVICE_HOST $GLANCE_SERVICE_PORT_INT
|
|
|
|
fi
|
2016-08-31 18:19:51 -07:00
|
|
|
start_tls_proxy glance-registry '*' $GLANCE_REGISTRY_PORT $GLANCE_SERVICE_HOST $GLANCE_REGISTRY_PORT_INT
|
2014-03-19 17:47:42 -04:00
|
|
|
fi
|
|
|
|
|
2014-09-09 13:46:02 +01:00
|
|
|
run_process g-reg "$GLANCE_BIN_DIR/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf"
|
2017-06-23 22:32:37 +00:00
|
|
|
if [[ "$WSGI_MODE" == "uwsgi" ]]; then
|
2017-08-17 08:59:59 -04:00
|
|
|
run_process g-api "$GLANCE_BIN_DIR/uwsgi --procname-prefix glance-api --ini $GLANCE_UWSGI_CONF"
|
2017-06-23 22:32:37 +00:00
|
|
|
else
|
2018-12-17 10:38:42 -05:00
|
|
|
run_process g-api "$GLANCE_BIN_DIR/glance-api --config-dir=$GLANCE_CONF_DIR"
|
2017-06-23 22:32:37 +00:00
|
|
|
fi
|
2014-03-19 17:47:42 -04:00
|
|
|
|
2017-06-23 22:32:37 +00:00
|
|
|
echo "Waiting for g-api ($GLANCE_SERVICE_HOST) to start..."
|
|
|
|
if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_URL; then
|
2013-10-22 08:47:11 -04:00
|
|
|
die $LINENO "g-api did not start"
|
2012-09-17 11:22:21 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-09-10 14:10:27 -05:00
|
|
|
# stop_glance() - Stop running processes
|
2014-02-21 15:35:08 +11:00
|
|
|
function stop_glance {
|
2014-09-09 13:46:02 +01:00
|
|
|
stop_process g-api
|
|
|
|
stop_process g-reg
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Restore xtrace
|
2015-10-13 11:03:03 +11:00
|
|
|
$_XTRACE_GLANCE
|
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:
|