From 536540781ae15c9793120f875a196f1954968d01 Mon Sep 17 00:00:00 2001 From: Yoshi Kadokawa Date: Thu, 16 Sep 2021 11:24:56 +0900 Subject: [PATCH] Add support of image format conversion on importing Optinally enable conversion of images to raw format when uploading images to Glance. Only supported when "image_conversion" is enabled in Glance. This is an equivalent change to the one in simplestreams: https://git.launchpad.net/simplestreams/commit/?id=cbc0ac9 Closes-Bug: #1889729 Change-Id: Id15fab364c27242347c520b959065c490e4da6b6 --- config.yaml | 6 ++++++ files/glance_simplestreams_sync.py | 4 ++++ hooks/hooks.py | 3 ++- templates/mirrors.yaml | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 371b3e5..96ee3f7 100644 --- a/config.yaml +++ b/config.yaml @@ -138,3 +138,9 @@ options: OpenStack mostly defaults to using public endpoints for internal communication between services. If set to True this option will configure services to use internal endpoints where possible. + image_import_conversion: + type: boolean + default: False + description: | + Enable conversion of images to raw format when uploading images to Glance. + Only supported when "image_conversion" is enabled in Glance. diff --git a/files/glance_simplestreams_sync.py b/files/glance_simplestreams_sync.py index d1e774b..148caae 100755 --- a/files/glance_simplestreams_sync.py +++ b/files/glance_simplestreams_sync.py @@ -299,6 +299,10 @@ def do_sync(ksc, charm_conf): '--custom-property', custom_property ] + if charm_conf.get('image_import_conversion', False): + sync_command += [ + '--image-import-conversion' + ] if charm_conf.get('set_latest_property', False): sync_command += [ diff --git a/hooks/hooks.py b/hooks/hooks.py index a4b066b..61b5d45 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -183,7 +183,8 @@ class MirrorsConfigServiceContext(OSContextGenerator): user_agent=config['user_agent'], custom_properties=config['custom_properties'], hypervisor_mapping=config['hypervisor_mapping'], - set_latest_property=config['set_latest_property']) + set_latest_property=config['set_latest_property'], + image_import_conversion=config['image_import_conversion']) def ensure_perms(): diff --git a/templates/mirrors.yaml b/templates/mirrors.yaml index 461da3d..32f05aa 100644 --- a/templates/mirrors.yaml +++ b/templates/mirrors.yaml @@ -9,6 +9,7 @@ region: {{ region }} cloud_name: {{ cloud_name }} content_id_template: {{ content_id_template }} hypervisor_mapping: {{ hypervisor_mapping }} +image_import_conversion: {{ image_import_conversion }} {% if custom_properties %} custom_properties: {{ custom_properties }} {% endif %}