]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Change generic NotFound to specific exception
authorPranaliDeore <pranali11.deore@nttdata.com>
Tue, 26 May 2015 07:12:27 +0000 (00:12 -0700)
committerPranaliDeore <pranali11.deore@nttdata.com>
Thu, 25 Jun 2015 12:25:07 +0000 (05:25 -0700)
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

20 files changed:
cinder/api/contrib/admin_actions.py
cinder/api/contrib/cgsnapshots.py
cinder/api/contrib/consistencygroups.py
cinder/api/contrib/qos_specs_manage.py
cinder/api/contrib/types_extra_specs.py
cinder/api/contrib/types_manage.py
cinder/api/contrib/volume_manage.py
cinder/api/contrib/volume_replication.py
cinder/api/contrib/volume_type_access.py
cinder/api/contrib/volume_type_encryption.py
cinder/api/contrib/volume_unmanage.py
cinder/api/v2/snapshots.py
cinder/api/v2/types.py
cinder/api/v2/volume_metadata.py
cinder/api/v2/volumes.py
cinder/tests/unit/api/contrib/test_cgsnapshots.py
cinder/tests/unit/api/contrib/test_consistencygroups.py
cinder/tests/unit/api/contrib/test_volume_unmanage.py
cinder/tests/unit/api/v2/stubs.py
cinder/tests/unit/api/v2/test_snapshots.py

index 3ef3511c5803ce0c9f2ca91c2343378987860664..7649fda4524dbadc4b71c9dc397b3afe088a49f4 100644 (file)
@@ -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)
 
index 76aa382391376ebd2142ef81c49481a185241975..670e08bc41fd9cf156fc7a869529d894ba5e3a5f 100644 (file)
@@ -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)
index 9a147292a7250eb60d7d2d55db800b5540d4fc81..a8304ec1c0e576653efa56ad983e8df063337cd3 100644 (file)
@@ -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)
 
index 428dfd6bab6fc37f19198ca7bda0911176a448a5..3fc7635deea5d7dbace217e7aed2629212cfe0f3 100644 (file)
@@ -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))
 
 
index 951368a75403e3868493fc971a8683d26eb15e90..1ce868f4d32e3c37d0b388710c49db6c6aee5c62 100644 (file)
@@ -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."""
index 33a4978bd5ec16d6c03daaf1312eb8ca97ec0ab9..565b4c8de59ab918bf05dbec02cfffb9074b3b87 100644 (file)
@@ -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)
 
index 55e681f842802d8f49e1fa8fc2d25c3726f892a5..b843adad5933e2b13810bb8d6e11b93875f0ddcf 100644 (file)
@@ -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'] = {}
 
index e0846548f32a59725ef6f8177efaa101cf061d45..f7be250215753c6adee11065b31cc24be6dfc3f5 100644 (file)
@@ -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)
index b91672f396a22d86b5e301b544fa9ea27c986783..dae7a152936b4436e67a8886a84376dd19e77d8e 100644 (file)
@@ -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.")
index 9cbfc7ae6a03fa39124c7051437c569fbd220b54..26dd9d1a5060e62606227c72be8fd4be697b46af 100644 (file)
@@ -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):
index a4c5ee4d2f805f822ae252432816bba5d6cb4b9c..a763b8e9532dd274244c9969d4fece2b1fe688f1 100644 (file)
@@ -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)
index d3976629d72299a9ee5b741096edc71e2d977143..e1140ca374fcd29d55b63e0f7dc25fe9ef76d1a4 100644 (file)
@@ -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)
index 6707ccbab1c6602297793b699224d647b43dd870..a1dce73424e072bc49c743c8778bf112a6b53128 100644 (file)
@@ -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)
 
index d34d40c126de6b0fc82da42b3882575e9d996b44..b9ba8debddd4fdd86b0c6736e9b927e2c704910d 100644 (file)
@@ -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)
 
 
index 4be05fed1c2f28e5d799e697fee1a6fd70495ee5..fd2be7a540d44ea6a48110cbdcb8881b0a5a4690 100644 (file)
@@ -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)
 
index 6a3113e835794cd6400bf2161d8af025856d9357..61d4a1bd6800c4116f427873287c5276af7cf4e3 100644 (file)
@@ -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']
index 3524a104ec09b19b9f028006e1b22f0da8b14279..e70ac0a0367117bac16d821aed2b3c5b5f7f5bcd 100644 (file)
@@ -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):
index a7104ee80596febb4db33bd538ab99c5238282c8..baa6578eaa047e2df6f62eaee820bc06b08d55de 100644 (file)
@@ -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
 
index ae5a690d99b739b1dacbf2158982d2229b76d6e1..9ce9e1d331e9055f0d8f0adf55e3ac0725c365c0 100644 (file)
@@ -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):
index 82ff94f05d8f4a276d2ea8ec77af56a2028fc20d..7e8d74c2db88881c781deffb3a84d0cf2b2a87e8 100644 (file)
@@ -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