add config to enable convertion to raw format

image-convertion config enables image convertion to raw format
this optimizes back-end capabilities while not putting the burden
of converting images to their end users

func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/582
Closes-Bug: 1899767
Change-Id: Id3791721f9e38899c87b88591cdc42e46ffea5c1
This commit is contained in:
Hernan Garcia 2021-05-18 06:26:27 -05:00
parent 72cd002dd5
commit 4aaa2ce5a3
5 changed files with 29 additions and 1 deletions

View File

@ -525,3 +525,9 @@ options:
description: |
Value of bluestore compression max blob size for solid state media on
pools requested by this charm.
image-conversion:
type: boolean
default: False
description: |
Enable conversion of all images to raw format during image upload,
only supported on stein or newer.

View File

@ -100,6 +100,15 @@ class GlancePolicyContext(OSContextGenerator):
return ctxt
class GlanceImageImportContext(OSContextGenerator):
def __call__(self):
ctxt = {}
if config('image-conversion'):
ctxt['image_conversion'] = config('image-conversion')
return ctxt
class CephGlanceContext(OSContextGenerator):
interfaces = ['ceph-glance']

View File

@ -200,7 +200,8 @@ CONFIG_FILES = OrderedDict([
interface=['storage-backend'],
service=['glance-api'],
config_file=GLANCE_API_CONF),
context.MemcacheContext()],
context.MemcacheContext(),
glance_contexts.GlanceImageImportContext()],
'services': ['glance-api']
}),
(GLANCE_SWIFT_CONF, {
@ -301,6 +302,9 @@ def determine_packages():
if CompareOpenStackReleases(os_release(VERSION_PACKAGE)) >= 'rocky':
packages = [p for p in packages if not p.startswith('python-')]
packages.extend(PY3_PACKAGES)
if CompareOpenStackReleases(os_release(VERSION_PACKAGE)) >= 'stein':
# required for image-conversion
packages.extend(['qemu-utils'])
return sorted(packages)

View File

@ -0,0 +1,7 @@
{% if image_conversion -%}
[image_import_opts]
image_import_plugins = ['image_conversion']
[image_conversion]
output_format = raw
{% endif -%}

View File

@ -111,3 +111,5 @@ auth_endpoint = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v
{{ key }} = {{ val }}
{% endfor -%}
{% endfor%}
{% include "parts/section-image-import" %}