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 820f84ef42)
This commit is contained in:
Brent Eagles 2021-05-03 22:25:28 -02:30
parent 0cc2857843
commit 1a171e2db1
1 changed files with 15 additions and 5 deletions

View File

@ -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 }} \