From e3d99e35d360b19228e2ba2f0413e64f9dad4f72 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Fri, 8 Dec 2017 16:22:53 +0100 Subject: [PATCH] cloud:ovirt:ovirt_storage_domains.py: Raise Exception in case no host is up for SD removal (#33662) --- lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py index 3c94b3574f..58fb55a814 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py @@ -531,7 +531,12 @@ def main(): host_param = module.params['host'] if not host_param: host = search_by_attributes(connection.system_service().hosts_service(), status='up') - host_param = host.name if host is not None else None + if host is None: + raise Exception( + "Not possible to remove storage domain '%s' " + "because no host found with status `up`." % module.params['name'] + ) + host_param = host.name ret = storage_domains_module.remove( destroy=module.params['destroy'], format=module.params['format'],