Handle NotFound exception in snapshots API code
Passing tests in the gate leave unhandled trace/error messages for a VolumeNotFound issue. These are caused by the test_volumes_snapshots_negative test which requests a non-existent volume and the tests pass however the log files are a bit messed up due to the unhandled exception. This change just adds a try/catch block around the volume get calls in the snapshot modules and raises HTTPNotFound as appropriate. Change-Id: I2096f2da7c68ef7924fc8e69b2d5c2afea578512 Closes-Bug: #1255214
This commit is contained in:
parent
79d8072236
commit
e6a1ba5291
@ -173,7 +173,11 @@ class SnapshotsController(wsgi.Controller):
|
|||||||
msg = _("'volume_id' must be specified")
|
msg = _("'volume_id' must be specified")
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
volume = self.volume_api.get(context, volume_id)
|
try:
|
||||||
|
volume = self.volume_api.get(context, volume_id)
|
||||||
|
except exception.NotFound:
|
||||||
|
raise exc.HTTPNotFound()
|
||||||
|
|
||||||
force = snapshot.get('force', False)
|
force = snapshot.get('force', False)
|
||||||
msg = _("Create snapshot from volume %s")
|
msg = _("Create snapshot from volume %s")
|
||||||
LOG.audit(msg, volume_id, context=context)
|
LOG.audit(msg, volume_id, context=context)
|
||||||
|
@ -184,7 +184,11 @@ class SnapshotsController(wsgi.Controller):
|
|||||||
msg = _("'volume_id' must be specified")
|
msg = _("'volume_id' must be specified")
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
volume = self.volume_api.get(context, volume_id)
|
try:
|
||||||
|
volume = self.volume_api.get(context, volume_id)
|
||||||
|
except exception.NotFound:
|
||||||
|
msg = _("Volume could not be found")
|
||||||
|
raise exc.HTTPNotFound(explanation=msg)
|
||||||
force = snapshot.get('force', False)
|
force = snapshot.get('force', False)
|
||||||
msg = _("Create snapshot from volume %s")
|
msg = _("Create snapshot from volume %s")
|
||||||
LOG.audit(msg, volume_id, context=context)
|
LOG.audit(msg, volume_id, context=context)
|
||||||
|
Loading…
Reference in New Issue
Block a user