From cb8bce4f1bd5f6709441d45373ea3b99c7eb4b9b Mon Sep 17 00:00:00 2001 From: PranaliDeore Date: Tue, 26 May 2015 00:12:27 -0700 Subject: [PATCH] Change generic NotFound to specific exception 1. Changed exception type from NotFound to specific NotFound exception for better readability. e.g. VolumeNotFound, SnapshotNotFound etc. 2. Error messages returned to the user are not consistent across all apis in case of all exceptions derived from NotFound exception. Instead of returning custom error messages return message defined in exception class itself. NOTE: Doesn't applied to 'HostBinaryNotFound' as host information to the tenant should not be leaked. 3. Added explanation to HTTPNotFound wherever appropriate. e.g. raise webob.exc.HTTPNotFound() to raise webob.exc.HTTPNotFound(explanation=err.msg) Closes-Bug: #1459958 Change-Id: Ice2c375796fac7533d82125ef97288075fa68b85 --- cinder/api/contrib/admin_actions.py | 24 +++++------ cinder/api/contrib/cgsnapshots.py | 10 ++--- cinder/api/contrib/consistencygroups.py | 10 ++--- cinder/api/contrib/qos_specs_manage.py | 2 +- cinder/api/contrib/types_extra_specs.py | 6 ++- cinder/api/contrib/types_manage.py | 8 ++-- cinder/api/contrib/volume_manage.py | 5 +-- cinder/api/contrib/volume_replication.py | 12 +++--- cinder/api/contrib/volume_type_access.py | 5 +-- cinder/api/contrib/volume_type_encryption.py | 2 +- cinder/api/contrib/volume_unmanage.py | 5 +-- cinder/api/v2/snapshots.py | 20 ++++----- cinder/api/v2/types.py | 5 +-- cinder/api/v2/volume_metadata.py | 15 +++---- cinder/api/v2/volumes.py | 42 +++++++------------ .../unit/api/contrib/test_cgsnapshots.py | 2 +- .../api/contrib/test_consistencygroups.py | 2 +- .../unit/api/contrib/test_volume_unmanage.py | 2 +- cinder/tests/unit/api/v2/stubs.py | 2 +- cinder/tests/unit/api/v2/test_snapshots.py | 4 +- 20 files changed, 79 insertions(+), 104 deletions(-) diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py index 3ef3511c5..7649fda45 100644 --- a/cinder/api/contrib/admin_actions.py +++ b/cinder/api/contrib/admin_actions.py @@ -95,7 +95,7 @@ class AdminController(wsgi.Controller): try: self._update(context, id, update) - except exception.NotFound as e: + except exception.VolumeNotFound as e: raise exc.HTTPNotFound(explanation=e.msg) notifier.info(context, self.collection + '.reset_status.end', @@ -110,8 +110,8 @@ class AdminController(wsgi.Controller): self.authorize(context, 'force_delete') try: resource = self._get(context, id) - except exception.NotFound: - raise exc.HTTPNotFound() + except exception.VolumeNotFound as e: + raise exc.HTTPNotFound(explanation=e.msg) self._delete(context, resource, force=True) return webob.Response(status_int=202) @@ -184,8 +184,8 @@ class VolumeAdminController(AdminController): self.authorize(context, 'force_detach') try: volume = self._get(context, id) - except exception.NotFound: - raise exc.HTTPNotFound() + except exception.VolumeNotFound as e: + raise exc.HTTPNotFound(explanation=e.msg) self.volume_api.terminate_connection(context, volume, {}, force=True) @@ -215,8 +215,8 @@ class VolumeAdminController(AdminController): self.authorize(context, 'migrate_volume') try: volume = self._get(context, id) - except exception.NotFound: - raise exc.HTTPNotFound() + except exception.VolumeNotFound as e: + raise exc.HTTPNotFound(explanation=e.msg) params = body['os-migrate_volume'] try: host = params['host'] @@ -243,8 +243,8 @@ class VolumeAdminController(AdminController): self.authorize(context, 'migrate_volume_completion') try: volume = self._get(context, id) - except exception.NotFound: - raise exc.HTTPNotFound() + except exception.VolumeNotFound as e: + raise exc.HTTPNotFound(explanation=e.msg) params = body['os-migrate_volume_completion'] try: new_volume_id = params['new_volume'] @@ -253,8 +253,8 @@ class VolumeAdminController(AdminController): explanation=_("Must specify 'new_volume'")) try: new_volume = self._get(context, new_volume_id) - except exception.NotFound: - raise exc.HTTPNotFound() + except exception.VolumeNotFound as e: + raise exc.HTTPNotFound(explanation=e.msg) error = params.get('error', False) ret = self.volume_api.migrate_volume_completion(context, volume, new_volume, error) @@ -308,7 +308,7 @@ class BackupAdminController(AdminController): try: self.backup_api.reset_status(context=context, backup_id=id, status=update['status']) - except exception.NotFound as e: + except exception.VolumeNotFound as e: raise exc.HTTPNotFound(explanation=e.msg) return webob.Response(status_int=202) diff --git a/cinder/api/contrib/cgsnapshots.py b/cinder/api/contrib/cgsnapshots.py index 76aa38239..670e08bc4 100644 --- a/cinder/api/contrib/cgsnapshots.py +++ b/cinder/api/contrib/cgsnapshots.py @@ -116,9 +116,8 @@ class CgsnapshotsController(wsgi.Controller): context, cgsnapshot_id=id) self.cgsnapshot_api.delete_cgsnapshot(context, cgsnapshot) - except exception.CgSnapshotNotFound: - msg = _("Cgsnapshot could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.CgSnapshotNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.InvalidCgSnapshot: msg = _("Invalid cgsnapshot") raise exc.HTTPBadRequest(explanation=msg) @@ -175,9 +174,8 @@ class CgsnapshotsController(wsgi.Controller): try: group = self.cgsnapshot_api.get(context, group_id) - except exception.NotFound: - msg = _("Consistency group could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.ConsistencyGroupNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) name = cgsnapshot.get('name', None) description = cgsnapshot.get('description', None) diff --git a/cinder/api/contrib/consistencygroups.py b/cinder/api/contrib/consistencygroups.py index 9a147292a..a8304ec1c 100644 --- a/cinder/api/contrib/consistencygroups.py +++ b/cinder/api/contrib/consistencygroups.py @@ -174,9 +174,8 @@ class ConsistencyGroupsController(wsgi.Controller): try: group = self.consistencygroup_api.get(context, id) self.consistencygroup_api.delete(context, group, force) - except exception.ConsistencyGroupNotFound: - msg = _("Consistency group %s could not be found.") % id - raise exc.HTTPNotFound(explanation=msg) + except exception.ConsistencyGroupNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.InvalidConsistencyGroup as error: raise exc.HTTPBadRequest(explanation=error.msg) @@ -354,9 +353,8 @@ class ConsistencyGroupsController(wsgi.Controller): self.consistencygroup_api.update( context, group, name, description, add_volumes, remove_volumes) - except exception.ConsistencyGroupNotFound: - msg = _("Consistency group %s could not be found.") % id - raise exc.HTTPNotFound(explanation=msg) + except exception.ConsistencyGroupNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.InvalidConsistencyGroup as error: raise exc.HTTPBadRequest(explanation=error.msg) diff --git a/cinder/api/contrib/qos_specs_manage.py b/cinder/api/contrib/qos_specs_manage.py index 428dfd6ba..3fc7635de 100644 --- a/cinder/api/contrib/qos_specs_manage.py +++ b/cinder/api/contrib/qos_specs_manage.py @@ -95,7 +95,7 @@ class AssociationsTemplate(xmlutil.TemplateBuilder): def _check_specs(context, specs_id): try: qos_specs.get_qos_specs(context, specs_id) - except exception.NotFound as ex: + except exception.QoSSpecsNotFound as ex: raise webob.exc.HTTPNotFound(explanation=six.text_type(ex)) diff --git a/cinder/api/contrib/types_extra_specs.py b/cinder/api/contrib/types_extra_specs.py index 951368a75..1ce868f4d 100644 --- a/cinder/api/contrib/types_extra_specs.py +++ b/cinder/api/contrib/types_extra_specs.py @@ -63,7 +63,7 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): def _check_type(self, context, type_id): try: volume_types.get_volume_type(context, type_id) - except exception.NotFound as ex: + except exception.VolumeTypeNotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.msg) @wsgi.serializers(xml=VolumeTypeExtraSpecsTemplate) @@ -128,7 +128,9 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): if id in specs['extra_specs']: return {id: specs['extra_specs'][id]} else: - raise webob.exc.HTTPNotFound() + msg = _("Volume Type %(type_id)s has no extra spec with key " + "%(id)s.") % ({'type_id': type_id, 'id': id}) + raise webob.exc.HTTPNotFound(explanation=msg) def delete(self, req, type_id, id): """Deletes an existing extra spec.""" diff --git a/cinder/api/contrib/types_manage.py b/cinder/api/contrib/types_manage.py index 33a4978bd..565b4c8de 100644 --- a/cinder/api/contrib/types_manage.py +++ b/cinder/api/contrib/types_manage.py @@ -89,10 +89,10 @@ class VolumeTypesManageController(wsgi.Controller): self._notify_volume_type_error( context, 'volume_type.create', err, volume_type=vol_type) raise webob.exc.HTTPConflict(explanation=six.text_type(err)) - except exception.NotFound as err: + except exception.VolumeTypeNotFoundByName as err: self._notify_volume_type_error( context, 'volume_type.create', err, name=name) - raise webob.exc.HTTPNotFound() + raise webob.exc.HTTPNotFound(explanation=err.msg) return self._view_builder.show(req, vol_type) @@ -168,10 +168,10 @@ class VolumeTypesManageController(wsgi.Controller): context, 'volume_type.delete', err, volume_type=vol_type) msg = _('Target volume type is still in use.') raise webob.exc.HTTPBadRequest(explanation=msg) - except exception.NotFound as err: + except exception.VolumeTypeNotFound as err: self._notify_volume_type_error( context, 'volume_type.delete', err, id=id) - raise webob.exc.HTTPNotFound() + raise webob.exc.HTTPNotFound(explanation=err.msg) return webob.Response(status_int=202) diff --git a/cinder/api/contrib/volume_manage.py b/cinder/api/contrib/volume_manage.py index 55e681f84..b843adad5 100644 --- a/cinder/api/contrib/volume_manage.py +++ b/cinder/api/contrib/volume_manage.py @@ -125,9 +125,8 @@ class VolumeManageController(wsgi.Controller): else: kwargs['volume_type'] = volume_types.get_volume_type( context, req_volume_type) - except exception.VolumeTypeNotFound: - msg = _("Volume type not found.") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeTypeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) else: kwargs['volume_type'] = {} diff --git a/cinder/api/contrib/volume_replication.py b/cinder/api/contrib/volume_replication.py index e0846548f..f7be25021 100644 --- a/cinder/api/contrib/volume_replication.py +++ b/cinder/api/contrib/volume_replication.py @@ -21,7 +21,7 @@ from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception -from cinder.i18n import _, _LI +from cinder.i18n import _LI from cinder import replication as replicationAPI from cinder import volume @@ -73,9 +73,8 @@ class VolumeReplicationController(wsgi.Controller): id, context=context) self.replication_api.promote(context, vol) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.ReplicationError as error: raise exc.HTTPBadRequest(explanation=six.text_type(error)) return webob.Response(status_int=202) @@ -91,9 +90,8 @@ class VolumeReplicationController(wsgi.Controller): id, context=context) self.replication_api.reenable(context, vol) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.ReplicationError as error: raise exc.HTTPBadRequest(explanation=six.text_type(error)) return webob.Response(status_int=202) diff --git a/cinder/api/contrib/volume_type_access.py b/cinder/api/contrib/volume_type_access.py index b91672f39..dae7a1529 100644 --- a/cinder/api/contrib/volume_type_access.py +++ b/cinder/api/contrib/volume_type_access.py @@ -92,9 +92,8 @@ class VolumeTypeAccessController(object): try: vol_type = volume_types.get_volume_type( context, type_id, expected_fields=['projects']) - except exception.VolumeTypeNotFound: - explanation = _("Volume type not found.") - raise webob.exc.HTTPNotFound(explanation=explanation) + except exception.VolumeTypeNotFound as error: + raise webob.exc.HTTPNotFound(explanation=error.msg) if vol_type['is_public']: expl = _("Access list not available for public volume types.") diff --git a/cinder/api/contrib/volume_type_encryption.py b/cinder/api/contrib/volume_type_encryption.py index 9cbfc7ae6..26dd9d1a5 100644 --- a/cinder/api/contrib/volume_type_encryption.py +++ b/cinder/api/contrib/volume_type_encryption.py @@ -53,7 +53,7 @@ class VolumeTypeEncryptionController(wsgi.Controller): def _check_type(self, context, type_id): try: volume_types.get_volume_type(context, type_id) - except exception.NotFound as ex: + except exception.VolumeTypeNotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.msg) def _check_encryption_input(self, encryption, create=True): diff --git a/cinder/api/contrib/volume_unmanage.py b/cinder/api/contrib/volume_unmanage.py index a4c5ee4d2..a763b8e95 100644 --- a/cinder/api/contrib/volume_unmanage.py +++ b/cinder/api/contrib/volume_unmanage.py @@ -56,9 +56,8 @@ class VolumeUnmanageController(wsgi.Controller): try: vol = self.volume_api.get(context, id) self.volume_api.delete(context, vol, unmanage_only=True) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.VolumeAttached: msg = _("Volume cannot be deleted while in attached state") raise exc.HTTPBadRequest(explanation=msg) diff --git a/cinder/api/v2/snapshots.py b/cinder/api/v2/snapshots.py index d3976629d..e1140ca37 100644 --- a/cinder/api/v2/snapshots.py +++ b/cinder/api/v2/snapshots.py @@ -104,9 +104,8 @@ class SnapshotsController(wsgi.Controller): try: snapshot = self.volume_api.get_snapshot(context, id) req.cache_db_snapshot(snapshot) - except exception.NotFound: - msg = _("Snapshot could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.SnapshotNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) return {'snapshot': _translate_snapshot_detail_view(context, snapshot)} @@ -119,9 +118,8 @@ class SnapshotsController(wsgi.Controller): try: snapshot = self.volume_api.get_snapshot(context, id) self.volume_api.delete_snapshot(context, snapshot) - except exception.NotFound: - msg = _("Snapshot could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.SnapshotNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) return webob.Response(status_int=202) @@ -184,9 +182,8 @@ class SnapshotsController(wsgi.Controller): try: volume = self.volume_api.get(context, volume_id) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) force = snapshot.get('force', False) msg = _LI("Create snapshot from volume %s") LOG.info(msg, volume_id, context=context) @@ -262,9 +259,8 @@ class SnapshotsController(wsgi.Controller): try: snapshot = self.volume_api.get_snapshot(context, id) self.volume_api.update_snapshot(context, snapshot, update_dict) - except exception.NotFound: - msg = _("Snapshot could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.SnapshotNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) snapshot.update(update_dict) req.cache_db_snapshot(snapshot) diff --git a/cinder/api/v2/types.py b/cinder/api/v2/types.py index 6707ccbab..a1dce7342 100644 --- a/cinder/api/v2/types.py +++ b/cinder/api/v2/types.py @@ -79,9 +79,8 @@ class VolumeTypesController(wsgi.Controller): try: vol_type = volume_types.get_volume_type(context, id) req.cache_resource(vol_type, name='types') - except exception.NotFound: - msg = _("Volume type not found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeTypeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) return self._view_builder.show(req, vol_type) diff --git a/cinder/api/v2/volume_metadata.py b/cinder/api/v2/volume_metadata.py index d34d40c12..b9ba8debd 100644 --- a/cinder/api/v2/volume_metadata.py +++ b/cinder/api/v2/volume_metadata.py @@ -33,9 +33,8 @@ class Controller(wsgi.Controller): try: volume = self.volume_api.get(context, volume_id) meta = self.volume_api.get_volume_metadata(context, volume) - except exception.VolumeNotFound: - msg = _('volume does not exist') - raise webob.exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise webob.exc.HTTPNotFound(explanation=error.msg) return meta @wsgi.serializers(xml=common.MetadataTemplate) @@ -113,9 +112,8 @@ class Controller(wsgi.Controller): volume, metadata, delete) - except exception.VolumeNotFound: - msg = _('volume does not exist') - raise webob.exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise webob.exc.HTTPNotFound(explanation=error.msg) except (ValueError, AttributeError): msg = _("Malformed request body") @@ -152,9 +150,8 @@ class Controller(wsgi.Controller): try: volume = self.volume_api.get(context, volume_id) self.volume_api.delete_volume_metadata(context, volume, id) - except exception.VolumeNotFound: - msg = _('volume does not exist') - raise webob.exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise webob.exc.HTTPNotFound(explanation=error.msg) return webob.Response(status_int=200) diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index 4be05fed1..fd2be7a54 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -188,9 +188,8 @@ class VolumeController(wsgi.Controller): try: vol = self.volume_api.get(context, id, viewable_admin_meta=True) req.cache_db_volume(vol) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) utils.add_visible_admin_metadata(vol) @@ -205,9 +204,8 @@ class VolumeController(wsgi.Controller): try: volume = self.volume_api.get(context, id) self.volume_api.delete(context, volume) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) except exception.VolumeAttached: msg = _("Volume cannot be deleted while in attached state") raise exc.HTTPBadRequest(explanation=msg) @@ -353,9 +351,8 @@ class VolumeController(wsgi.Controller): else: kwargs['volume_type'] = volume_types.get_volume_type( context, req_volume_type) - except exception.VolumeTypeNotFound: - msg = _("Volume type not found.") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeTypeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) kwargs['metadata'] = volume.get('metadata', None) @@ -364,9 +361,8 @@ class VolumeController(wsgi.Controller): try: kwargs['snapshot'] = self.volume_api.get_snapshot(context, snapshot_id) - except exception.NotFound: - explanation = _('snapshot id:%s not found') % snapshot_id - raise exc.HTTPNotFound(explanation=explanation) + except exception.SnapshotNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) else: kwargs['snapshot'] = None @@ -376,9 +372,8 @@ class VolumeController(wsgi.Controller): kwargs['source_volume'] = \ self.volume_api.get_volume(context, source_volid) - except exception.NotFound: - explanation = _('source volume id:%s not found') % source_volid - raise exc.HTTPNotFound(explanation=explanation) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) else: kwargs['source_volume'] = None @@ -392,10 +387,8 @@ class VolumeController(wsgi.Controller): ' replicated') % source_volid raise exc.HTTPNotFound(explanation=explanation) kwargs['source_replica'] = src_vol - except exception.NotFound: - explanation = (_('replica source volume id:%s not found') % - source_replica) - raise exc.HTTPNotFound(explanation=explanation) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) else: kwargs['source_replica'] = None @@ -405,10 +398,8 @@ class VolumeController(wsgi.Controller): kwargs['consistencygroup'] = \ self.consistencygroup_api.get(context, consistencygroup_id) - except exception.NotFound: - explanation = _('Consistency group id:%s not found') % \ - consistencygroup_id - raise exc.HTTPNotFound(explanation=explanation) + except exception.ConsistencyGroupNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) else: kwargs['consistencygroup'] = None @@ -494,9 +485,8 @@ class VolumeController(wsgi.Controller): volume_utils.notify_about_volume_usage(context, volume, 'update.start') self.volume_api.update(context, volume, update_dict) - except exception.NotFound: - msg = _("Volume could not be found") - raise exc.HTTPNotFound(explanation=msg) + except exception.VolumeNotFound as error: + raise exc.HTTPNotFound(explanation=error.msg) volume.update(update_dict) diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py index 6a3113e83..61d4a1bd6 100644 --- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py +++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py @@ -474,7 +474,7 @@ class CgsnapshotsAPITestCase(test.TestCase): self.assertEqual(res.status_int, 404) self.assertEqual(res_dict['itemNotFound']['code'], 404) self.assertEqual(res_dict['itemNotFound']['message'], - 'Cgsnapshot could not be found') + 'CgSnapshot 9999 could not be found.') def test_delete_cgsnapshot_with_Invalidcgsnapshot(self): consistencygroup_id = utils.create_consistencygroup(self.context)['id'] diff --git a/cinder/tests/unit/api/contrib/test_consistencygroups.py b/cinder/tests/unit/api/contrib/test_consistencygroups.py index 3524a104e..e70ac0a03 100644 --- a/cinder/tests/unit/api/contrib/test_consistencygroups.py +++ b/cinder/tests/unit/api/contrib/test_consistencygroups.py @@ -372,7 +372,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase): self.assertEqual(404, res.status_int) self.assertEqual(404, res_dict['itemNotFound']['code']) - self.assertEqual('Consistency group 9999 could not be found.', + self.assertEqual('ConsistencyGroup 9999 could not be found.', res_dict['itemNotFound']['message']) def test_delete_consistencygroup_with_Invalidconsistencygroup(self): diff --git a/cinder/tests/unit/api/contrib/test_volume_unmanage.py b/cinder/tests/unit/api/contrib/test_volume_unmanage.py index a7104ee80..baa6578ea 100644 --- a/cinder/tests/unit/api/contrib/test_volume_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_volume_unmanage.py @@ -76,7 +76,7 @@ def api_get(self, context, volume_id): vol = vols.get(volume_id, None) if not vol: - raise exception.NotFound + raise exception.VolumeNotFound(volume_id) return vol diff --git a/cinder/tests/unit/api/v2/stubs.py b/cinder/tests/unit/api/v2/stubs.py index ae5a690d9..9ce9e1d33 100644 --- a/cinder/tests/unit/api/v2/stubs.py +++ b/cinder/tests/unit/api/v2/stubs.py @@ -116,7 +116,7 @@ def stub_volume_get(self, context, volume_id, viewable_admin_meta=False): def stub_volume_get_notfound(self, context, volume_id, viewable_admin_meta=False): - raise exc.NotFound + raise exc.VolumeNotFound(volume_id) def stub_volume_get_db(context, volume_id): diff --git a/cinder/tests/unit/api/v2/test_snapshots.py b/cinder/tests/unit/api/v2/test_snapshots.py index 82ff94f05..7e8d74c2d 100644 --- a/cinder/tests/unit/api/v2/test_snapshots.py +++ b/cinder/tests/unit/api/v2/test_snapshots.py @@ -63,12 +63,12 @@ def stub_snapshot_create(self, context, def stub_snapshot_delete(self, context, snapshot): if snapshot['id'] != UUID: - raise exception.NotFound + raise exception.SnapshotNotFound(snapshot['id']) def stub_snapshot_get(self, context, snapshot_id): if snapshot_id != UUID: - raise exception.NotFound + raise exception.SnapshotNotFound(snapshot_id) param = _get_default_snapshot_param() return param -- 2.45.2