From 39445786ffed87b440c8699a527482ea66f2ef1e Mon Sep 17 00:00:00 2001 From: Evert Mulder Date: Fri, 12 Apr 2019 19:25:33 +0200 Subject: [PATCH] Bugfixes when removing a tenant- Module reported changed when tenant was not removed.- Script error when removing a non existing tenant without parent_id (#55110) --- .../remote_management/manageiq/manageiq_tenant.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py b/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py index f57ce557b98..0b0e4b16d6d 100644 --- a/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py +++ b/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py @@ -35,7 +35,8 @@ version_added: '2.8' author: Evert Mulder (@evertmulder) description: - The manageiq_tenant module supports adding, updating and deleting tenants in ManageIQ. - +requirements: +- manageiq-client options: state: description: @@ -264,6 +265,9 @@ class ManageIQTenant(object): except Exception as e: self.module.fail_json(msg="failed to delete tenant %s: %s" % (tenant['name'], str(e))) + if result['success'] is False: + self.module.fail_json(msg=result['message']) + return dict(changed=True, msg=result['message']) def edit_tenant(self, tenant, name, description): @@ -513,9 +517,14 @@ def main(): res_args = manageiq_tenant.delete_tenant(tenant) # if we do not have a tenant, nothing to do else: + if parent_id: + msg = "tenant '%s' with parent_id %i does not exist in manageiq" % (name, parent_id) + else: + msg = "tenant '%s' with parent '%s' does not exist in manageiq" % (name, parent) + res_args = dict( changed=False, - msg="tenant %s: with parent: %i does not exist in manageiq" % (name, parent_id)) + msg=msg) # tenant should exist if state == "present":