From 953568e21301fe69b069554f782e1dc82bf108fd Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Mon, 5 Nov 2018 18:36:57 +0100 Subject: [PATCH] fix missing exceptions openstack modules (#48088) * Fix missing exceptions (#45775) * Replace non-existing OpenStackCloudTimeout exception. Fixes: #45151 * Replace OpenStackCloudURINotFound that doesn't exist in the 'exceptions' module (cherry picked from commit eb39c461cebc9c54cd014d2988a8a02c17eb44a1) * add changelog --- changelogs/fragments/45151-fix-os-exception.yaml | 2 ++ lib/ansible/modules/cloud/openstack/os_quota.py | 4 ++-- lib/ansible/modules/cloud/openstack/os_server_volume.py | 2 +- lib/ansible/modules/cloud/openstack/os_volume.py | 2 +- lib/ansible/modules/cloud/openstack/os_volume_snapshot.py | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/45151-fix-os-exception.yaml diff --git a/changelogs/fragments/45151-fix-os-exception.yaml b/changelogs/fragments/45151-fix-os-exception.yaml new file mode 100644 index 00000000000..7e9181d5d65 --- /dev/null +++ b/changelogs/fragments/45151-fix-os-exception.yaml @@ -0,0 +1,2 @@ +bugfixes: +- replace renamed exceptions in multiple openstack modules diff --git a/lib/ansible/modules/cloud/openstack/os_quota.py b/lib/ansible/modules/cloud/openstack/os_quota.py index f983bd5970e..108446df1db 100644 --- a/lib/ansible/modules/cloud/openstack/os_quota.py +++ b/lib/ansible/modules/cloud/openstack/os_quota.py @@ -249,12 +249,12 @@ def _get_quotas(sdk, module, cloud, project): quota = {} try: quota['volume'] = _get_volume_quotas(cloud, project) - except sdk.exceptions.OpenStackCloudURINotFound: + except sdk.exceptions.NotFoundException: module.warn("No public endpoint for volumev2 service was found. Ignoring volume quotas.") try: quota['network'] = _get_network_quotas(cloud, project) - except sdk.exceptions.OpenStackCloudURINotFound: + except sdk.exceptions.NotFoundException: module.warn("No public endpoint for network service was found. Ignoring network quotas.") quota['compute'] = _get_compute_quotas(cloud, project) diff --git a/lib/ansible/modules/cloud/openstack/os_server_volume.py b/lib/ansible/modules/cloud/openstack/os_server_volume.py index f49dd886c07..81d593c1ab0 100644 --- a/lib/ansible/modules/cloud/openstack/os_server_volume.py +++ b/lib/ansible/modules/cloud/openstack/os_server_volume.py @@ -139,7 +139,7 @@ def main(): result='Detached volume from server' ) - except (sdk.exceptions.OpenStackCloudException, sdk.exceptions.OpenStackCloudTimeout) as e: + except (sdk.exceptions.OpenStackCloudException, sdk.exceptions.ResourceTimeout) as e: module.fail_json(msg=str(e)) diff --git a/lib/ansible/modules/cloud/openstack/os_volume.py b/lib/ansible/modules/cloud/openstack/os_volume.py index c42ffb5e4f5..034b499b62d 100644 --- a/lib/ansible/modules/cloud/openstack/os_volume.py +++ b/lib/ansible/modules/cloud/openstack/os_volume.py @@ -124,7 +124,7 @@ def _absent_volume(module, cloud, sdk): changed = cloud.delete_volume(name_or_id=module.params['display_name'], wait=module.params['wait'], timeout=module.params['timeout']) - except sdk.exceptions.OpenStackCloudTimeout: + except sdk.exceptions.ResourceTimeout: module.exit_json(changed=changed) module.exit_json(changed=changed) diff --git a/lib/ansible/modules/cloud/openstack/os_volume_snapshot.py b/lib/ansible/modules/cloud/openstack/os_volume_snapshot.py index f03ce14657d..5b49c5806ec 100644 --- a/lib/ansible/modules/cloud/openstack/os_volume_snapshot.py +++ b/lib/ansible/modules/cloud/openstack/os_volume_snapshot.py @@ -186,7 +186,7 @@ def main(): module.fail_json( msg="No volume with name or id '{0}' was found.".format( module.params['volume'])) - except (sdk.exceptions.OpenStackCloudException, sdk.exceptions.OpenStackCloudTimeout) as e: + except (sdk.exceptions.OpenStackCloudException, sdk.exceptions.ResourceTimeout) as e: module.fail_json(msg=e.message)