From 65749bd432d0bbb752adb079845dcb0f7f891e6f Mon Sep 17 00:00:00 2001 From: maorlipchuk Date: Wed, 4 Oct 2017 11:43:42 +0300 Subject: [PATCH] Return None for DC in case of detached storage domain (#29175) The following patch fixes a regression when trying to remove a detached storage domain. As part of the remove process the ovirt_storage_domains module first tries to move the domain to maintenance and detach it. In case of removing a detached storage domain with no DC attached to it The maintenace process will fail with 404 (not exists) exception when trying to fetch the DC using empty Guid. The fix proposes a solution to return None value in case of a detached storage domain. --- lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py index 9b5bc91e181..3c4e0cf00d3 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_storage_domains.py @@ -335,9 +335,9 @@ class StorageDomainModule(BaseModule): # Serach the data_center name, if it does not exists, try to search by guid. dc = search_by_name(dcs_service, self._module.params['data_center']) if dc is None: - dc = dcs_service.service(self._module.params['data_center']).get() + dc = get_entity(dcs_service.service(self._module.params['data_center'])) if dc is None: - return + return None dc_service = dcs_service.data_center_service(dc.id) return dc_service.storage_domains_service()