Fix image detection in os_image openstack module (#63959)
Currently first check was by checksum only, and if there are 2 images with the same checksum, but different names, this check fails with error: * Multiple matches found for None * To prevent this let's add more exact check in the beginning: 1. Firstly try to find by unique ID if it's given, most safe way. 2. Try to find by combination of name and checksum, not only checksum, it will drop duplicates with different name. 3. Try to find just by name, as most general approach. By going from most narrow to more general checks we can drop duplicates in more efficient manner.
This commit is contained in:
parent
0cd2ad5880
commit
554285acb7
1 changed files with 4 additions and 2 deletions
|
@ -177,8 +177,10 @@ def main():
|
|||
try:
|
||||
|
||||
changed = False
|
||||
if module.params['checksum']:
|
||||
image = cloud.get_image(name_or_id=None, filters={'checksum': module.params['checksum']})
|
||||
if module.params['id']:
|
||||
image = cloud.get_image(name_or_id=module.params['id'])
|
||||
elif module.params['checksum']:
|
||||
image = cloud.get_image(name_or_id=module.params['name'], filters={'checksum': module.params['checksum']})
|
||||
else:
|
||||
image = cloud.get_image(name_or_id=module.params['name'])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue