Skip to content

Commit 5585d84

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Support optimized cinder backend for glance"
2 parents bdf454f + 6e9f7c2 commit 5585d84

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

lib/cinder

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ if is_fedora || is_suse; then
9898
fi
9999
fi
100100

101+
# When Cinder is used as a backend for Glance, it can be configured to clone
102+
# the volume containing image data directly in the backend instead of
103+
# transferring data from volume to volume. Value is a comma separated list of
104+
# schemes (currently only 'file' and 'cinder' are supported). The default
105+
# configuration in Cinder is empty (that is, do not use this feature). NOTE:
106+
# to use this feature you must also enable GLANCE_SHOW_DIRECT_URL and/or
107+
# GLANCE_SHOW_MULTIPLE_LOCATIONS for glance-api.conf.
108+
CINDER_ALLOWED_DIRECT_URL_SCHEMES=${CINDER_ALLOWED_DIRECT_URL_SCHEMES:-}
109+
if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
110+
if [[ "${GLANCE_SHOW_DIRECT_URL:-False}" != "True" \
111+
&& "${GLANCE_SHOW_MULTIPLE_LOCATIONS:-False}" != "True" ]]; then
112+
warn $LINENO "CINDER_ALLOWED_DIRECT_URL_SCHEMES is set, but neither \
113+
GLANCE_SHOW_DIRECT_URL nor GLANCE_SHOW_MULTIPLE_LOCATIONS is True"
114+
fi
115+
fi
116+
101117
# For backward compatibility
102118
# Before CINDER_BACKUP_DRIVER was introduced, ceph backup driver was configured
103119
# along with ceph backend driver.
@@ -266,6 +282,9 @@ function configure_cinder {
266282
fi
267283
iniset $CINDER_CONF key_manager backend cinder.keymgr.conf_key_mgr.ConfKeyManager
268284
iniset $CINDER_CONF key_manager fixed_key $(openssl rand -hex 16)
285+
if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
286+
iniset $CINDER_CONF DEFAULT allowed_direct_url_schemes $CINDER_ALLOWED_DIRECT_URL_SCHEMES
287+
fi
269288

270289
# Avoid RPC timeouts in slow CI and test environments by doubling the
271290
# default response timeout set by RPC clients. See bug #1873234 for more

lib/glance

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ GLANCE_STORE_ROOTWRAP_BASE_DIR=/usr/local/etc/glance
5151
if is_opensuse; then
5252
GLANCE_STORE_ROOTWRAP_BASE_DIR=/usr/etc/glance
5353
fi
54+
# When Cinder is used as a glance store, you can optionally configure cinder to
55+
# optimize bootable volume creation by allowing volumes to be cloned directly
56+
# in the backend instead of transferring data via Glance. To use this feature,
57+
# set CINDER_ALLOWED_DIRECT_URL_SCHEMES for cinder.conf and enable
58+
# GLANCE_SHOW_DIRECT_URL and/or GLANCE_SHOW_MULTIPLE_LOCATIONS for Glance. The
59+
# default value for both of these is False, because for some backends they
60+
# present a grave security risk (though not for Cinder, because all that's
61+
# exposed is the volume_id where the image data is stored.) See OSSN-0065 for
62+
# more information: https://wiki.openstack.org/wiki/OSSN/OSSN-0065
63+
GLANCE_SHOW_DIRECT_URL=$(trueorfalse False GLANCE_SHOW_DIRECT_URL)
64+
GLANCE_SHOW_MULTIPLE_LOCATIONS=$(trueorfalse False GLANCE_SHOW_MULTIPLE_LOCATIONS)
65+
5466
# Glance multi-store configuration
5567
# Boolean flag to enable multiple store configuration for glance
5668
GLANCE_ENABLE_MULTIPLE_STORES=$(trueorfalse False GLANCE_ENABLE_MULTIPLE_STORES)
@@ -333,6 +345,9 @@ function configure_glance {
333345
if [ "$VIRT_DRIVER" = 'libvirt' ] && [ "$LIBVIRT_TYPE" = 'parallels' ]; then
334346
iniset $GLANCE_API_CONF DEFAULT disk_formats "ami,ari,aki,vhd,vmdk,raw,qcow2,vdi,iso,ploop"
335347
fi
348+
# Only use these if you know what you are doing! See OSSN-0065
349+
iniset $GLANCE_API_CONF DEFAULT show_image_direct_url $GLANCE_SHOW_DIRECT_URL
350+
iniset $GLANCE_API_CONF DEFAULT show_multiple_locations $GLANCE_SHOW_MULTIPLE_LOCATIONS
336351

337352
# Configure glance_store
338353
configure_glance_store $USE_CINDER_FOR_GLANCE $GLANCE_ENABLE_MULTIPLE_STORES

0 commit comments

Comments
 (0)