From b429c520f55140df6ebf6a9e4d1da411b5fd1a0b Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sun, 31 Oct 2021 18:37:34 +0100 Subject: [PATCH] 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. --- changelogs/fragments/3626-fix-one_image-error.yml | 2 ++ plugins/modules/cloud/opennebula/one_image.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3626-fix-one_image-error.yml diff --git a/changelogs/fragments/3626-fix-one_image-error.yml b/changelogs/fragments/3626-fix-one_image-error.yml new file mode 100644 index 0000000000..e1dafab017 --- /dev/null +++ b/changelogs/fragments/3626-fix-one_image-error.yml @@ -0,0 +1,2 @@ +bugfixes: + - one_image - fix error message when renaming an image (https://github.com/ansible-collections/community.general/pull/3626). diff --git a/plugins/modules/cloud/opennebula/one_image.py b/plugins/modules/cloud/opennebula/one_image.py index 5e62ee9ee4..5a80306fd1 100644 --- a/plugins/modules/cloud/opennebula/one_image.py +++ b/plugins/modules/cloud/opennebula/one_image.py @@ -306,7 +306,7 @@ def rename_image(module, client, image, new_name): tmp_image = get_image_by_name(module, client, new_name) 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: client.image.rename(image.ID, new_name)