Image filters should be dict not set

At the moment we generate a set as a filter for image checksums which
lead to AttributeError in SDK:
'set' object has no attribute 'keys'

With that we ensure that supllying checksum does not cause
module crash.

Change-Id: I490f51950592f62c9ad81806593340779bf6dbdb
This commit is contained in:
Dmitriy Rabotyagov 2023-07-25 12:49:28 +02:00
parent 2808d1c155
commit 0a371445eb
2 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,13 @@
path: '{{ tmp_file.path }}' path: '{{ tmp_file.path }}'
size: 1M size: 1M
- name: Calculating file checksum
ansible.builtin.stat:
path: "{{ tmp_file.path }}"
checksum_algorithm: sha512
get_checksum: true
register: image_details
- name: Ensure mock kernel and ramdisk images (defaults) - name: Ensure mock kernel and ramdisk images (defaults)
openstack.cloud.image: openstack.cloud.image:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
@ -42,6 +49,7 @@
name: ansible_image name: ansible_image
filename: "{{ tmp_file.path }}" filename: "{{ tmp_file.path }}"
is_protected: true is_protected: true
checksum: "{{ image_details.stat.checksum }}"
disk_format: raw disk_format: raw
tags: tags:
- test - test

View File

@ -485,7 +485,7 @@ class ImageModule(OpenStackModule):
if image_name_or_id: if image_name_or_id:
image = self.conn.get_image( image = self.conn.get_image(
image_name_or_id, image_name_or_id,
filters={(k, self.params[k]) filters={k: self.params[k]
for k in ['checksum'] if self.params[k] is not None}) for k in ['checksum'] if self.params[k] is not None})
changed = False changed = False