From 4b784bd8c6b94c35ddf33ae7873bbc32d669bf17 Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Mon, 3 May 2021 22:25:28 -0230 Subject: [PATCH] Do not convert amphora images to raw if they are already raw Adds a check on the provided image to see if it is raw before conversion (if requested). Change-Id: I79b03709deffe6cb788aba9e24c63ca33bd297ee Related-Bug: #1843059 (cherry picked from commit 820f84ef42a9c36c677481760989ad36f13de4c0) --- .../octavia_undercloud/tasks/image_mgmt.yml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tripleo_ansible/roles/octavia_undercloud/tasks/image_mgmt.yml b/tripleo_ansible/roles/octavia_undercloud/tasks/image_mgmt.yml index 17fe1900d..20a5a528c 100644 --- a/tripleo_ansible/roles/octavia_undercloud/tasks/image_mgmt.yml +++ b/tripleo_ansible/roles/octavia_undercloud/tasks/image_mgmt.yml @@ -31,9 +31,19 @@ when: - image_file_result.stat.exists | bool +- name: Check the amphora image file format + command: | + qemu-img info --output=json "{{ image_filename }}" + register: image_file_format + +- name: Set the image format + set_fact: + img_format: "{{ (image_file_format.stdout | from_json).format }}" + - name: Convert image if indicated when: - amp_to_raw | bool + - img_format != "raw" block: - name: create temporary directory tempfile: @@ -48,10 +58,6 @@ shell: | qemu-img convert -f qcow2 -O raw {{ image_filename }} {{ raw_filename }} - - name: setting amphora format to raw - set_fact: - raw_format: raw - - name: get the checksum for the converted file stat: path: "{{ raw_filename }}" @@ -62,6 +68,10 @@ set_fact: image_checksum: "{{ raw_file_result.stat.checksum }}" + - name: setting amphora format to raw + set_fact: + img_format: raw + - name: gather facts about the service project shell: | openstack project show "{{ auth_project_name }}" -c id -f value @@ -180,7 +190,7 @@ - name: upload image to glance shell: | - openstack image create --disk-format {{ raw_format|default('qcow2') }} \ + openstack image create --disk-format {{ img_format|default('qcow2') }} \ --container-format bare --tag {{ amp_image_tag }} \ --file {{ raw_filename|default(image_filename) }} \ --property hw_architecture={{ amp_hw_arch }} \