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:
parent
3c614f938e
commit
0d1ebe943a
@ -31,9 +31,19 @@
|
|||||||
when:
|
when:
|
||||||
- image_file_result.stat.exists | bool
|
- 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
|
- name: Convert image if indicated
|
||||||
when:
|
when:
|
||||||
- amp_to_raw | bool
|
- amp_to_raw | bool
|
||||||
|
- img_format != "raw"
|
||||||
block:
|
block:
|
||||||
- name: create temporary directory
|
- name: create temporary directory
|
||||||
tempfile:
|
tempfile:
|
||||||
@ -48,10 +58,6 @@
|
|||||||
shell: |
|
shell: |
|
||||||
qemu-img convert -f qcow2 -O raw {{ image_filename }} {{ raw_filename }}
|
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
|
- name: get the checksum for the converted file
|
||||||
stat:
|
stat:
|
||||||
path: "{{ raw_filename }}"
|
path: "{{ raw_filename }}"
|
||||||
@ -62,6 +68,10 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
image_checksum: "{{ raw_file_result.stat.checksum }}"
|
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
|
- name: gather facts about the service project
|
||||||
shell: |
|
shell: |
|
||||||
openstack project show "{{ auth_project_name }}" -c id -f value
|
openstack project show "{{ auth_project_name }}" -c id -f value
|
||||||
@ -180,7 +190,7 @@
|
|||||||
|
|
||||||
- name: upload image to glance
|
- name: upload image to glance
|
||||||
shell: |
|
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 }} \
|
--container-format bare --tag {{ amp_image_tag }} \
|
||||||
--file {{ raw_filename|default(image_filename) }} \
|
--file {{ raw_filename|default(image_filename) }} \
|
||||||
--property hw_architecture={{ amp_hw_arch }} \
|
--property hw_architecture={{ amp_hw_arch }} \
|
||||||
|
Loading…
Reference in New Issue
Block a user