From 854379c12c2b02cfa6e294204c591553e03f5f4c Mon Sep 17 00:00:00 2001 From: Takashi NATSUME Date: Wed, 19 Apr 2017 17:06:07 +0900 Subject: [PATCH] Remove redundant code TrivialFix Change-Id: I17f51b81e8870d17dc16d002c6fb6b2e80fd2c07 --- nova/api/openstack/compute/deferred_delete.py | 5 ++--- nova/api/openstack/compute/server_tags.py | 5 ++--- nova/api/openstack/compute/volumes.py | 10 ++++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/nova/api/openstack/compute/deferred_delete.py b/nova/api/openstack/compute/deferred_delete.py index e8743fc625..c47838b030 100644 --- a/nova/api/openstack/compute/deferred_delete.py +++ b/nova/api/openstack/compute/deferred_delete.py @@ -62,9 +62,8 @@ class DeferredDeleteController(wsgi.Controller): 'project_id': instance.project_id}) try: self.compute_api.force_delete(context, instance) - except exception.InstanceNotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.format_message()) - except exception.InstanceUnknownCell as e: + except (exception.InstanceNotFound, + exception.InstanceUnknownCell) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/server_tags.py b/nova/api/openstack/compute/server_tags.py index f2572ac02a..3eb0b401e1 100644 --- a/nova/api/openstack/compute/server_tags.py +++ b/nova/api/openstack/compute/server_tags.py @@ -183,9 +183,8 @@ class ServerTagsController(wsgi.Controller): try: with nova_context.target_cell(context, im.cell_mapping): objects.Tag.destroy(context, server_id, id) - except exception.InstanceTagNotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.format_message()) - except exception.InstanceNotFound as e: + except (exception.InstanceTagNotFound, + exception.InstanceNotFound) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) @wsgi.Controller.api_version("2.26") diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index 406b4933f8..9b785d7578 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -336,13 +336,11 @@ class VolumeAttachmentController(wsgi.Controller): try: device = self.compute_api.attach_volume(context, instance, volume_id, device) - except exception.InstanceUnknownCell as e: + except (exception.InstanceUnknownCell, + exception.VolumeNotFound) as e: raise exc.HTTPNotFound(explanation=e.format_message()) - except exception.VolumeNotFound as e: - raise exc.HTTPNotFound(explanation=e.format_message()) - except exception.InstanceIsLocked as e: - raise exc.HTTPConflict(explanation=e.format_message()) - except exception.DevicePathInUse as e: + except (exception.InstanceIsLocked, + exception.DevicePathInUse) as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error,