Skip to content

Commit 3bbad9d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Glance: Add support to configure multiple file stores"
2 parents a766d68 + 6f91da9 commit 3bbad9d

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

lib/glance

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,29 @@ else
4141
GLANCE_BIN_DIR=$(get_python_exec_prefix)
4242
fi
4343

44+
# Glance multi-store configuration
45+
# Boolean flag to enable multiple store configuration for glance
46+
GLANCE_ENABLE_MULTIPLE_STORES=$(trueorfalse False GLANCE_ENABLE_MULTIPLE_STORES)
47+
48+
# Comma separated list for configuring multiple file stores of glance,
49+
# for example; GLANCE_MULTIPLE_FILE_STORES = fast,cheap,slow
50+
GLANCE_MULTIPLE_FILE_STORES=${GLANCE_MULTIPLE_FILE_STORES:-fast}
51+
52+
# Default store/backend for glance, must be one of the store specified
53+
# in GLANCE_MULTIPLE_FILE_STORES option.
54+
GLANCE_DEFAULT_BACKEND=${GLANCE_DEFAULT_BACKEND:-fast}
55+
4456
GLANCE_CACHE_DIR=${GLANCE_CACHE_DIR:=$DATA_DIR/glance/cache}
57+
58+
# File path for each store specified in GLANCE_MULTIPLE_FILE_STORES, the store
59+
# identifier will be appended to this path at runtime. If GLANCE_MULTIPLE_FILE_STORES
60+
# has fast,cheap specified then filepath will be generated like $DATA_DIR/glance/fast
61+
# and $DATA_DIR/glance/cheap.
62+
GLANCE_MULTISTORE_FILE_IMAGE_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/glance}
4563
GLANCE_IMAGE_DIR=${GLANCE_IMAGE_DIR:=$DATA_DIR/glance/images}
4664
GLANCE_LOCK_DIR=${GLANCE_LOCK_DIR:=$DATA_DIR/glance/locks}
65+
GLANCE_STAGING_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/os_glance_staging_store}
66+
GLANCE_TASKS_DIR=${GLANCE_MULTISTORE_FILE_IMAGE_DIR:=$DATA_DIR/os_glance_tasks_store}
4767

4868
GLANCE_CONF_DIR=${GLANCE_CONF_DIR:-/etc/glance}
4969
GLANCE_METADEF_DIR=$GLANCE_CONF_DIR/metadefs
@@ -97,6 +117,18 @@ function is_glance_enabled {
97117
function cleanup_glance {
98118
# delete image files (glance)
99119
sudo rm -rf $GLANCE_CACHE_DIR $GLANCE_IMAGE_DIR
120+
121+
# Cleanup multiple stores directories
122+
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
123+
local store file_dir
124+
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
125+
file_dir="${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/${store}/"
126+
sudo rm -rf $file_dir
127+
done
128+
129+
# Cleanup reserved stores directories
130+
sudo rm -rf $GLANCE_STAGING_DIR $GLANCE_TASKS_DIR
131+
fi
100132
}
101133

102134
# configure_glance() - Set config files, create data dirs, etc
@@ -117,6 +149,16 @@ function configure_glance {
117149
iniset_rpc_backend glance $GLANCE_REGISTRY_CONF
118150
iniset $GLANCE_REGISTRY_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
119151

152+
# Configure multiple stores
153+
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
154+
local store enabled_backends
155+
enabled_backends=""
156+
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
157+
enabled_backends+="${store}:file,"
158+
done
159+
iniset $GLANCE_API_CONF DEFAULT enabled_backends ${enabled_backends::-1}
160+
fi
161+
120162
# Set non-default configuration options for the API server
121163
iniset $GLANCE_API_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
122164
iniset $GLANCE_API_CONF database connection $dburl
@@ -141,8 +183,21 @@ function configure_glance {
141183
iniset $GLANCE_API_CONF DEFAULT enable_v1_api False
142184
fi
143185

144-
# Store specific configs
145-
iniset $GLANCE_API_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
186+
# Glance multiple store Store specific configs
187+
if [[ "$GLANCE_ENABLE_MULTIPLE_STORES" == "True" ]]; then
188+
iniset $GLANCE_API_CONF glance_store default_backend $GLANCE_DEFAULT_BACKEND
189+
local store
190+
for store in $(echo $GLANCE_MULTIPLE_FILE_STORES | tr "," "\n"); do
191+
iniset $GLANCE_API_CONF $store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/${store}/"
192+
done
193+
194+
# Glance configure reserved stores
195+
iniset $GLANCE_API_CONF os_glance_staging_store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/os_glance_staging_store/"
196+
iniset $GLANCE_API_CONF os_glance_tasks_store filesystem_store_datadir "${GLANCE_MULTISTORE_FILE_IMAGE_DIR}/os_glance_tasks_store/"
197+
else
198+
# Store specific configs
199+
iniset $GLANCE_API_CONF glance_store filesystem_store_datadir $GLANCE_IMAGE_DIR/
200+
fi
146201
iniset $GLANCE_API_CONF DEFAULT registry_host $(ipv6_unquote $GLANCE_SERVICE_HOST)
147202

148203
# CORS feature support - to allow calls from Horizon by default
@@ -152,6 +207,7 @@ function configure_glance {
152207
iniset $GLANCE_API_CONF cors allowed_origin "http://$SERVICE_HOST"
153208
fi
154209

210+
# No multiple stores for swift yet
155211
# Store the images in swift if enabled.
156212
if is_service_enabled s-proxy; then
157213
iniset $GLANCE_API_CONF glance_store default_store swift

0 commit comments

Comments
 (0)