def _attach(self, req, id, body):
"""Add attachment metadata."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
# instance uuid is an option now
instance_uuid = None
if 'instance_uuid' in body['os-attach']:
def _detach(self, req, id, body):
"""Clear attachment metadata."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
self.volume_api.detach(context, volume)
return webob.Response(status_int=202)
def _reserve(self, req, id, body):
"""Mark volume as reserved."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
self.volume_api.reserve_volume(context, volume)
return webob.Response(status_int=202)
def _unreserve(self, req, id, body):
"""Unmark volume as reserved."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
self.volume_api.unreserve_volume(context, volume)
return webob.Response(status_int=202)
def _begin_detaching(self, req, id, body):
"""Update volume status to 'detaching'."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
self.volume_api.begin_detaching(context, volume)
return webob.Response(status_int=202)
def _roll_detaching(self, req, id, body):
"""Roll back volume status to 'in-use'."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
self.volume_api.roll_detaching(context, volume)
return webob.Response(status_int=202)
def _initialize_connection(self, req, id, body):
"""Initialize volume attachment."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
connector = body['os-initialize_connection']['connector']
info = self.volume_api.initialize_connection(context,
volume,
def _terminate_connection(self, req, id, body):
"""Terminate volume attachment."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
connector = body['os-terminate_connection']['connector']
self.volume_api.terminate_connection(context, volume, connector)
return webob.Response(status_int=202)
volume = self.volume_api.get(context, id)
except exception.VolumeNotFound as error:
raise webob.exc.HTTPNotFound(explanation=error.msg)
+
authorize(context, "upload_image")
image_metadata = {"container_format": params.get("container_format",
"bare"),
def _extend(self, req, id, body):
"""Extend size of volume."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
+
try:
_val = int(body['os-extend']['new_size'])
except (KeyError, ValueError):
def _volume_readonly_update(self, req, id, body):
"""Update volume readonly flag."""
context = req.environ['cinder.context']
- volume = self.volume_api.get(context, id)
+ try:
+ volume = self.volume_api.get(context, id)
+ except exception.VolumeNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
if not self.is_valid_body(body, 'os-update_readonly_flag'):
msg = _("No 'os-update_readonly_flag' was specified "