Skip to content

Commit 049b8f0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Support for s3 backend of glance"
2 parents 5f49df4 + b8cd9d1 commit 049b8f0

1 file changed

Lines changed: 57 additions & 4 deletions

File tree

lib/glance

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ else
4141
GLANCE_BIN_DIR=$(get_python_exec_prefix)
4242
fi
4343

44+
#S3 for Glance
45+
GLANCE_USE_S3=$(trueorfalse False GLANCE_USE_S3)
46+
GLANCE_S3_DEFAULT_BACKEND=${GLANCE_S3_DEFAULT_BACKEND:-s3_fast}
47+
GLANCE_S3_BUCKET_ON_PUT=$(trueorfalse True GLANCE_S3_BUCKET_ON_PUT)
48+
GLANCE_S3_BUCKET_NAME=${GLANCE_S3_BUCKET_NAME:-images}
49+
4450
# Cinder for Glance
4551
USE_CINDER_FOR_GLANCE=$(trueorfalse False USE_CINDER_FOR_GLANCE)
4652
# GLANCE_CINDER_DEFAULT_BACKEND should be one of the values
@@ -174,6 +180,34 @@ function cleanup_glance {
174180
remove_uwsgi_config "$GLANCE_UWSGI_CONF" "glance-wsgi-api"
175181
}
176182

183+
# Set multiple s3 store related config options
184+
#
185+
function configure_multiple_s3_stores {
186+
enabled_backends="${GLANCE_S3_DEFAULT_BACKEND}:s3"
187+
188+
iniset $GLANCE_API_CONF DEFAULT enabled_backends ${enabled_backends}
189+
iniset $GLANCE_API_CONF glance_store default_backend $GLANCE_S3_DEFAULT_BACKEND
190+
}
191+
192+
# Set common S3 store options to given config section
193+
#
194+
# Arguments:
195+
# config_section
196+
#
197+
function set_common_s3_store_params {
198+
local config_section="$1"
199+
openstack ec2 credential create
200+
iniset $GLANCE_API_CONF $config_section s3_store_host "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$S3_SERVICE_PORT"
201+
iniset $GLANCE_API_CONF $config_section s3_store_access_key "$(openstack ec2 credential list -c Access -f value)"
202+
iniset $GLANCE_API_CONF $config_section s3_store_secret_key "$(openstack ec2 credential list -c Secret -f value)"
203+
iniset $GLANCE_API_CONF $config_section s3_store_create_bucket_on_put $GLANCE_S3_BUCKET_ON_PUT
204+
iniset $GLANCE_API_CONF $config_section s3_store_bucket $GLANCE_S3_BUCKET_NAME
205+
iniset $GLANCE_API_CONF $config_section s3_store_bucket_url_format "path"
206+
if is_service_enabled tls-proxy; then
207+
iniset $GLANCE_API_CONF $config_section s3_store_cacert $SSL_BUNDLE_FILE
208+
fi
209+
}
210+
177211
# Set multiple cinder store related config options for each of the cinder store
178212
#
179213
function configure_multiple_cinder_stores {
@@ -258,7 +292,6 @@ function configure_glance_store {
258292
local be
259293

260294
if [[ "$glance_enable_multiple_stores" == "False" ]]; then
261-
# Configure traditional glance_store
262295
if [[ "$use_cinder_for_glance" == "True" ]]; then
263296
# set common glance_store parameters
264297
iniset $GLANCE_API_CONF glance_store stores "cinder,file,http"
@@ -281,7 +314,7 @@ function configure_glance_store {
281314
if [[ "$use_cinder_for_glance" == "True" ]]; then
282315
# Configure multiple cinder stores for glance
283316
configure_multiple_cinder_stores
284-
else
317+
elif ! is_service_enabled s-proxy && [[ "$GLANCE_USE_S3" == "False" ]]; then
285318
# Configure multiple file stores for glance
286319
configure_multiple_file_stores
287320
fi
@@ -360,8 +393,15 @@ function configure_glance {
360393

361394
# No multiple stores for swift yet
362395
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "False" ]]; then
363-
# Store the images in swift if enabled.
364-
if is_service_enabled s-proxy; then
396+
# Return if s3api is enabled for glance
397+
if [[ "$GLANCE_USE_S3" == "True" ]]; then
398+
if is_service_enabled s3api; then
399+
# set common glance_store parameters
400+
iniset $GLANCE_API_CONF glance_store stores "s3,file,http"
401+
iniset $GLANCE_API_CONF glance_store default_store s3
402+
fi
403+
elif is_service_enabled s-proxy; then
404+
# Store the images in swift if enabled.
365405
iniset $GLANCE_API_CONF glance_store default_store swift
366406
iniset $GLANCE_API_CONF glance_store swift_store_create_container_on_put True
367407

@@ -379,6 +419,12 @@ function configure_glance {
379419
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_address $KEYSTONE_SERVICE_URI/v3
380420
iniset $GLANCE_SWIFT_STORE_CONF ref1 auth_version 3
381421
fi
422+
else
423+
if [[ "$GLANCE_USE_S3" == "True" ]]; then
424+
if is_service_enabled s3api; then
425+
configure_multiple_s3_stores
426+
fi
427+
fi
382428
fi
383429

384430
# We need to tell glance what it's public endpoint is so that the version
@@ -484,6 +530,13 @@ function create_glance_accounts {
484530
configure_glance_quotas
485531
fi
486532

533+
if is_service_enabled s3api && [[ "$GLANCE_USE_S3" == "True" ]]; then
534+
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "False" ]]; then
535+
set_common_s3_store_params glance_store
536+
else
537+
set_common_s3_store_params $GLANCE_S3_DEFAULT_BACKEND
538+
fi
539+
fi
487540
fi
488541
}
489542

0 commit comments

Comments
 (0)