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
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
GLANCE_CACHE_DIR=${GLANCE_CACHE_DIR:=$DATA_DIR/glance/cache}
|
|
|
|
GLANCE_IMAGE_DIR=${GLANCE_IMAGE_DIR:=$DATA_DIR/glance/images}
|
2012-10-01 14:06:44 -05:00
|
|
|
GLANCE_AUTH_CACHE_DIR=${GLANCE_AUTH_CACHE_DIR:-/var/cache/glance}
|
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
|
|
|
|
GLANCE_POLICY_JSON=$GLANCE_CONF_DIR/policy.json
|
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
|
2015-12-15 16:14:26 +03:00
|
|
|
GLANCE_GLARE_CONF=$GLANCE_CONF_DIR/glance-glare.conf
|
|
|
|
GLANCE_GLARE_PASTE_INI=$GLANCE_CONF_DIR/glance-glare-paste.ini
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2014-03-19 17:47:42 -04:00
|
|
|
if is_ssl_enabled_service "glance" || is_service_enabled tls-proxy; then
|
|
|
|
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}
|
2015-06-16 13:14:31 -04:00
|
|
|
GLANCE_SERVICE_LISTEN_ADDRESS=${GLANCE_SERVICE_LISTEN_ADDRESS:-$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}
|
2015-12-15 16:14:26 +03:00
|
|
|
GLANCE_GLARE_PORT=${GLANCE_GLARE_PORT:-9494}
|
|
|
|
GLANCE_GLARE_HOSTPORT=${GLANCE_GLARE_HOSTPORT:-$GLANCE_SERVICE_HOST:$GLANCE_GLARE_PORT}
|
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 {
|
|
|
|
[[ ,${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
|
|
|
# kill instances (nova)
|
|
|
|
# delete image files (glance)
|
2013-03-07 16:11:40 -06:00
|
|
|
sudo rm -rf $GLANCE_CACHE_DIR $GLANCE_IMAGE_DIR $GLANCE_AUTH_CACHE_DIR
|
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
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
# Copy over our glance configurations and update them
|
2015-12-15 16:14:26 +03:00
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
cp $GLANCE_DIR/etc/glance-glare.conf $GLANCE_GLARE_CONF
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
cp $GLANCE_DIR/etc/glance-registry.conf $GLANCE_REGISTRY_CONF
|
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
|
2012-09-17 11:22:21 -05:00
|
|
|
inicomment $GLANCE_REGISTRY_CONF DEFAULT log_file
|
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
|
2015-04-15 10:27:06 +08:00
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT workers "$API_WORKERS"
|
2012-09-17 11:22:21 -05:00
|
|
|
iniset $GLANCE_REGISTRY_CONF paste_deploy flavor keystone
|
2014-09-19 17:22:22 -05:00
|
|
|
configure_auth_token_middleware $GLANCE_REGISTRY_CONF glance $GLANCE_AUTH_CACHE_DIR/registry
|
2016-01-16 17:46:35 +08:00
|
|
|
iniset $GLANCE_REGISTRY_CONF oslo_messaging_notifications driver messaging
|
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
|
|
|
|
|
|
|
cp $GLANCE_DIR/etc/glance-api.conf $GLANCE_API_CONF
|
2013-08-10 09:56:16 -05:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
2015-06-16 13:14:31 -04:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
|
2012-09-17 11:22:21 -05:00
|
|
|
inicomment $GLANCE_API_CONF DEFAULT log_file
|
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/
|
|
|
|
iniset $GLANCE_API_CONF paste_deploy flavor keystone+cachemanagement
|
2014-09-19 17:22:22 -05:00
|
|
|
configure_auth_token_middleware $GLANCE_API_CONF glance $GLANCE_AUTH_CACHE_DIR/api
|
2016-01-16 17:46:35 +08:00
|
|
|
iniset $GLANCE_API_CONF oslo_messaging_notifications driver messaging
|
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
|
|
|
|
2014-09-03 11:51:00 +02:00
|
|
|
# Store specific configs
|
|
|
|
iniset $GLANCE_API_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
|
2015-12-15 16:14:26 +03:00
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
|
|
|
|
fi
|
2015-06-16 13:14:31 -04:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT registry_host $GLANCE_SERVICE_HOST
|
2014-09-03 11:51:00 +02:00
|
|
|
|
2014-09-16 17:25:33 -05:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS"
|
2014-08-28 14:50:04 +01: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
|
|
|
|
|
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
|
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
|
|
|
|
|
|
|
# Store the glare in swift if enabled.
|
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store default_store swift
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store swift_store_create_container_on_put True
|
|
|
|
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store swift_store_config_file $GLANCE_SWIFT_STORE_CONF
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store default_swift_reference ref1
|
|
|
|
iniset $GLANCE_GLARE_CONF glance_store stores "file, http, swift"
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
|
|
|
|
|
|
|
|
# commenting is not strictly necessary but it's confusing to have bad values in conf
|
|
|
|
inicomment $GLANCE_GLARE_CONF glance_store swift_store_user
|
|
|
|
inicomment $GLANCE_GLARE_CONF glance_store swift_store_key
|
|
|
|
inicomment $GLANCE_GLARE_CONF glance_store swift_store_auth_address
|
|
|
|
fi
|
|
|
|
|
2015-06-19 02:52:41 +00:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 key $SERVICE_PASSWORD
|
2015-08-05 15:53:21 +10:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_address $KEYSTONE_SERVICE_URI/v3
|
2016-01-21 16:08:14 -06:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 user_domain_name $SERVICE_DOMAIN_NAME
|
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 project_domain_name $SERVICE_DOMAIN_NAME
|
2015-08-05 15:53:21 +10:00
|
|
|
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_version 3
|
2015-06-19 02:52:41 +00:00
|
|
|
|
|
|
|
# commenting is not strictly necessary but it's confusing to have bad values in conf
|
|
|
|
inicomment $GLANCE_API_CONF glance_store swift_store_user
|
|
|
|
inicomment $GLANCE_API_CONF glance_store swift_store_key
|
|
|
|
inicomment $GLANCE_API_CONF glance_store swift_store_auth_address
|
2013-03-29 10:51:01 -05:00
|
|
|
fi
|
|
|
|
|
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
|
2015-06-05 11:58:15 -04:00
|
|
|
iniset $GLANCE_API_CONF DEFAULT public_endpoint $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT
|
2014-03-19 17:47:42 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
# Register SSL certificates if provided
|
|
|
|
if is_ssl_enabled_service glance; then
|
|
|
|
ensure_certificates GLANCE
|
|
|
|
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT cert_file "$GLANCE_SSL_CERT"
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT key_file "$GLANCE_SSL_KEY"
|
|
|
|
|
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT cert_file "$GLANCE_SSL_CERT"
|
|
|
|
iniset $GLANCE_REGISTRY_CONF DEFAULT key_file "$GLANCE_SSL_KEY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if is_ssl_enabled_service glance || is_service_enabled tls-proxy; then
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT registry_client_protocol https
|
|
|
|
fi
|
|
|
|
|
2015-02-11 19:34:09 +00:00
|
|
|
# Format logging
|
|
|
|
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
2015-03-14 19:24:10 +05:30
|
|
|
setup_colorized_logging $GLANCE_API_CONF DEFAULT tenant user
|
|
|
|
setup_colorized_logging $GLANCE_REGISTRY_CONF DEFAULT tenant user
|
2015-02-11 19:34:09 +00:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
|
|
|
cp $GLANCE_DIR/etc/glance-cache.conf $GLANCE_CACHE_CONF
|
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
|
|
|
inicomment $GLANCE_CACHE_CONF DEFAULT log_file
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT use_syslog $SYSLOG
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/
|
|
|
|
iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_url
|
2016-02-01 14:58:20 +00:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT auth_url $KEYSTONE_AUTH_URI/v2.0
|
2012-09-17 11:22:21 -05:00
|
|
|
iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_tenant_name
|
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
|
|
|
iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_user
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT admin_user glance
|
|
|
|
iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_password
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT admin_password $SERVICE_PASSWORD
|
2015-06-16 13:14:31 -04:00
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT registry_host $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/
|
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
cp -p $GLANCE_DIR/etc/policy.json $GLANCE_POLICY_JSON
|
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
|
|
|
|
|
|
|
if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then
|
|
|
|
CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST}
|
|
|
|
CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776}
|
|
|
|
|
|
|
|
iniset $GLANCE_API_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
|
|
|
|
iniset $GLANCE_CACHE_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
|
|
|
|
fi
|
2015-12-15 16:14:26 +03:00
|
|
|
|
|
|
|
# Configure GLANCE_GLARE (Glance Glare)
|
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
local dburl
|
|
|
|
dburl=`database_connection_url glance`
|
|
|
|
setup_colorized_logging $GLANCE_GLARE_CONF DEFAULT tenant user
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT bind_host $GLANCE_SERVICE_LISTEN_ADDRESS
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT bind_port $GLANCE_GLARE_PORT
|
|
|
|
inicomment $GLANCE_GLARE_CONF DEFAULT log_file
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT workers "$API_WORKERS"
|
|
|
|
|
|
|
|
iniset $GLANCE_GLARE_CONF database connection $dburl
|
|
|
|
iniset $GLANCE_GLARE_CONF paste_deploy flavor keystone
|
|
|
|
configure_auth_token_middleware $GLANCE_GLARE_CONF glare $GLANCE_AUTH_CACHE_DIR/artifact
|
|
|
|
# Register SSL certificates if provided
|
|
|
|
if is_ssl_enabled_service glance; then
|
|
|
|
ensure_certificates GLANCE
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT cert_file "$GLANCE_SSL_CERT"
|
|
|
|
iniset $GLANCE_GLARE_CONF DEFAULT key_file "$GLANCE_SSL_KEY"
|
|
|
|
fi
|
|
|
|
cp $GLANCE_DIR/etc/glance-glare-paste.ini $GLANCE_GLARE_PASTE_INI
|
|
|
|
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)
|
2015-12-15 16:14:26 +03:00
|
|
|
# SERVICE_PROJECT_NAME glare service (if 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" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT"
|
2014-03-03 14:31:29 -06:00
|
|
|
fi
|
2015-12-15 16:14:26 +03:00
|
|
|
|
|
|
|
# Add glance-glare service and endpoints
|
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
create_service_user "glare"
|
|
|
|
get_or_create_service "glare" "artifact" "Glance Artifact Service"
|
|
|
|
|
2016-04-23 01:45:40 +00:00
|
|
|
get_or_create_endpoint "artifact" \
|
2015-12-15 16:14:26 +03:00
|
|
|
"$REGION_NAME" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT" \
|
|
|
|
"$GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT"
|
|
|
|
fi
|
2014-03-03 14:31:29 -06:00
|
|
|
}
|
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
# create_glance_cache_dir() - Part of the init_glance() process
|
2014-02-21 15:35:08 +11:00
|
|
|
function create_glance_cache_dir {
|
2013-02-12 10:58:28 -06:00
|
|
|
# Create cache dir
|
2015-12-15 16:14:26 +03:00
|
|
|
sudo install -d -o $STACK_USER $GLANCE_AUTH_CACHE_DIR/api $GLANCE_AUTH_CACHE_DIR/registry $GLANCE_AUTH_CACHE_DIR/search $GLANCE_AUTH_CACHE_DIR/artifact
|
|
|
|
rm -f $GLANCE_AUTH_CACHE_DIR/api/* $GLANCE_AUTH_CACHE_DIR/registry/* $GLANCE_AUTH_CACHE_DIR/search/* $GLANCE_AUTH_CACHE_DIR/artifact/*
|
2013-02-12 10:58:28 -06:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# Delete existing cache
|
|
|
|
rm -rf $GLANCE_CACHE_DIR
|
|
|
|
mkdir -p $GLANCE_CACHE_DIR
|
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
# (Re)create glance database
|
2014-10-06 13:29:39 +02:00
|
|
|
recreate_database glance
|
2012-09-17 11:22:21 -05:00
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
# Migrate glance database
|
2013-12-22 10:47:39 +08:00
|
|
|
$GLANCE_BIN_DIR/glance-manage db_sync
|
2012-10-01 14:06:44 -05:00
|
|
|
|
2014-09-06 07:06:46 -04:00
|
|
|
# Load metadata definitions
|
|
|
|
$GLANCE_BIN_DIR/glance-manage db_load_metadefs
|
|
|
|
|
2013-02-12 10:58:28 -06:00
|
|
|
create_glance_cache_dir
|
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 {
|
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"
|
|
|
|
setup_dev_lib "glance_store"
|
|
|
|
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
|
|
|
|
|
|
|
if is_service_enabled g-search; then
|
2015-01-22 16:06:41 -08:00
|
|
|
${TOP_DIR}/pkg/elasticsearch.sh download
|
|
|
|
${TOP_DIR}/pkg/elasticsearch.sh install
|
|
|
|
fi
|
2015-03-31 00:28:39 -07:00
|
|
|
|
|
|
|
setup_develop $GLANCE_DIR
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# start_glance() - Start running processes, including screen
|
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
|
|
|
|
start_tls_proxy '*' $GLANCE_SERVICE_PORT $GLANCE_SERVICE_HOST $GLANCE_SERVICE_PORT_INT &
|
|
|
|
start_tls_proxy '*' $GLANCE_REGISTRY_PORT $GLANCE_SERVICE_HOST $GLANCE_REGISTRY_PORT_INT &
|
|
|
|
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"
|
|
|
|
run_process g-api "$GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
|
2014-03-19 17:47:42 -04:00
|
|
|
|
2012-09-17 11:22:21 -05:00
|
|
|
echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
|
2014-03-19 17:47:42 -04:00
|
|
|
if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT; 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
|
2015-12-15 16:14:26 +03:00
|
|
|
|
|
|
|
#Start g-glare after g-reg/g-api/g-search
|
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
run_process g-glare "$GLANCE_BIN_DIR/glance-glare --config-file=$GLANCE_CONF_DIR/glance-glare.conf"
|
|
|
|
echo "Waiting for Glare [g-glare] ($GLANCE_GLARE_HOSTPORT) to start..."
|
|
|
|
if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT; then
|
|
|
|
die $LINENO " Glare [g-glare] did not start"
|
|
|
|
fi
|
|
|
|
fi
|
2012-09-17 11:22:21 -05:00
|
|
|
}
|
|
|
|
|
2012-09-10 14:10:27 -05:00
|
|
|
# stop_glance() - Stop running processes
|
2014-02-21 15:35:08 +11:00
|
|
|
function stop_glance {
|
2012-09-17 11:22:21 -05:00
|
|
|
# Kill the Glance screen windows
|
2014-09-09 13:46:02 +01:00
|
|
|
stop_process g-api
|
|
|
|
stop_process g-reg
|
2015-12-15 16:14:26 +03:00
|
|
|
|
|
|
|
if is_service_enabled g-glare; then
|
|
|
|
stop_process g-glare
|
|
|
|
fi
|
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:
|