mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
opennebula: fix error message when renaming an image (#3626)
While porting this module to make use of `pyone` I have overlooked one attribute. Luckily the error only occurs when trying to rename an image to a name that has already been taken. Instead of telling the user which image ID already uses that name, the module failed with the following error (along with a huge backtrace): AttributeError: 'IMAGESub' object has no attribute 'id' With this commit the error message is much more obvous again.
This commit is contained in:
parent
d6e14276c8
commit
b429c520f5
2 changed files with 3 additions and 1 deletions
2
changelogs/fragments/3626-fix-one_image-error.yml
Normal file
2
changelogs/fragments/3626-fix-one_image-error.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- one_image - fix error message when renaming an image (https://github.com/ansible-collections/community.general/pull/3626).
|
|
@ -306,7 +306,7 @@ def rename_image(module, client, image, new_name):
|
||||||
|
|
||||||
tmp_image = get_image_by_name(module, client, new_name)
|
tmp_image = get_image_by_name(module, client, new_name)
|
||||||
if tmp_image:
|
if tmp_image:
|
||||||
module.fail_json(msg="Name '" + new_name + "' is already taken by IMAGE with id=" + str(tmp_image.id))
|
module.fail_json(msg="Name '" + new_name + "' is already taken by IMAGE with id=" + str(tmp_image.ID))
|
||||||
|
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
client.image.rename(image.ID, new_name)
|
client.image.rename(image.ID, new_name)
|
||||||
|
|
Loading…
Reference in a new issue