diff --git a/nova/api/openstack/compute/admin_actions.py b/nova/api/openstack/compute/admin_actions.py index 4aa8f05f358d..82f223009dc2 100644 --- a/nova/api/openstack/compute/admin_actions.py +++ b/nova/api/openstack/compute/admin_actions.py @@ -48,6 +48,8 @@ class AdminActionsController(wsgi.Controller): try: instance = common.get_instance(self.compute_api, context, id) self.compute_api.reset_network(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) @@ -61,6 +63,8 @@ class AdminActionsController(wsgi.Controller): try: instance = common.get_instance(self.compute_api, context, id) self.compute_api.inject_network_info(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/admin_password.py b/nova/api/openstack/compute/admin_password.py index c5d11317f75d..ed1bd2050a1e 100644 --- a/nova/api/openstack/compute/admin_password.py +++ b/nova/api/openstack/compute/admin_password.py @@ -49,6 +49,8 @@ class AdminPasswordController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.set_admin_password(context, instance, password) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstancePasswordSetFailed as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as e: diff --git a/nova/api/openstack/compute/create_backup.py b/nova/api/openstack/compute/create_backup.py index 1d81bb8c6f08..f8d8082e9b51 100644 --- a/nova/api/openstack/compute/create_backup.py +++ b/nova/api/openstack/compute/create_backup.py @@ -66,6 +66,8 @@ class CreateBackupController(wsgi.Controller): try: image = self.compute_api.backup(context, instance, image_name, backup_type, rotation, extra_properties=props) + except exception.InstanceUnknownCell as e: + raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createBackup', id) diff --git a/nova/api/openstack/compute/deferred_delete.py b/nova/api/openstack/compute/deferred_delete.py index d3cc9c8df895..13b5f5954f54 100644 --- a/nova/api/openstack/compute/deferred_delete.py +++ b/nova/api/openstack/compute/deferred_delete.py @@ -42,6 +42,8 @@ class DeferredDeleteController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.restore(context, instance) + except exception.InstanceUnknownCell as error: + raise webob.exc.HTTPNotFound(explanation=error.format_message()) except exception.QuotaError as error: raise webob.exc.HTTPForbidden(explanation=error.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/evacuate.py b/nova/api/openstack/compute/evacuate.py index b0d26b673c2e..7b42982110f4 100644 --- a/nova/api/openstack/compute/evacuate.py +++ b/nova/api/openstack/compute/evacuate.py @@ -86,6 +86,8 @@ class EvacuateController(wsgi.Controller): try: self.compute_api.evacuate(context, instance, host, on_shared_storage, password) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'evacuate', id) diff --git a/nova/api/openstack/compute/floating_ips.py b/nova/api/openstack/compute/floating_ips.py index d080f9acd624..b32d2214f4e8 100644 --- a/nova/api/openstack/compute/floating_ips.py +++ b/nova/api/openstack/compute/floating_ips.py @@ -242,6 +242,8 @@ class FloatingIPActionController(wsgi.Controller): except exception.NoFloatingIpInterface: msg = _('l3driver call to add floating ip failed') raise webob.exc.HTTPBadRequest(explanation=msg) + except exception.InstanceUnknownCell as e: + raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.FloatingIpNotFoundForAddress: msg = _('floating ip not found') raise webob.exc.HTTPNotFound(explanation=msg) diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index 4b8bd6a61232..18437ae7ddf8 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -80,6 +80,8 @@ class MigrateServerController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) self.compute_api.live_migrate(context, instance, block_migration, disk_over_commit, host) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.NoValidHost, exception.ComputeServiceUnavailable, exception.InvalidHypervisorType, diff --git a/nova/api/openstack/compute/multinic.py b/nova/api/openstack/compute/multinic.py index 21575364542a..75ea342915a0 100644 --- a/nova/api/openstack/compute/multinic.py +++ b/nova/api/openstack/compute/multinic.py @@ -48,6 +48,8 @@ class MultinicController(wsgi.Controller): network_id = body['addFixedIp']['networkId'] try: self.compute_api.add_fixed_ip(context, instance, network_id) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.NoMoreFixedIps as e: raise exc.HTTPBadRequest(explanation=e.format_message()) @@ -65,6 +67,8 @@ class MultinicController(wsgi.Controller): try: self.compute_api.remove_fixed_ip(context, instance, address) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.FixedIpNotFoundForSpecificInstance as e: raise exc.HTTPBadRequest(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/pause_server.py b/nova/api/openstack/compute/pause_server.py index c4eeea33411b..042cd2c16b58 100644 --- a/nova/api/openstack/compute/pause_server.py +++ b/nova/api/openstack/compute/pause_server.py @@ -46,7 +46,8 @@ class PauseServerController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'pause', id) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise exc.HTTPNotFound(explanation=e.format_message()) except NotImplementedError: common.raise_feature_not_supported() @@ -66,7 +67,8 @@ class PauseServerController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'unpause', id) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise exc.HTTPNotFound(explanation=e.format_message()) except NotImplementedError: common.raise_feature_not_supported() diff --git a/nova/api/openstack/compute/remote_consoles.py b/nova/api/openstack/compute/remote_consoles.py index 8638cde91051..bb0a850f8b1b 100644 --- a/nova/api/openstack/compute/remote_consoles.py +++ b/nova/api/openstack/compute/remote_consoles.py @@ -56,7 +56,8 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -84,7 +85,8 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -114,7 +116,8 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -139,7 +142,8 @@ class RemoteConsolesController(wsgi.Controller): output = self.compute_api.get_serial_console(context, instance, console_type) - except exception.InstanceNotFound as e: + except (exception.InstanceUnknownCell, + exception.InstanceNotFound) as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/rescue.py b/nova/api/openstack/compute/rescue.py index aff601ce6b96..12990bb9ebf2 100644 --- a/nova/api/openstack/compute/rescue.py +++ b/nova/api/openstack/compute/rescue.py @@ -65,6 +65,8 @@ class RescueController(wsgi.Controller): self.compute_api.rescue(context, instance, rescue_password=password, rescue_image_ref=rescue_image_ref) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -91,6 +93,8 @@ class RescueController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.unrescue(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/server_metadata.py b/nova/api/openstack/compute/server_metadata.py index 2192c1edf0b0..cbec6d5dd3c9 100644 --- a/nova/api/openstack/compute/server_metadata.py +++ b/nova/api/openstack/compute/server_metadata.py @@ -112,6 +112,9 @@ class ServerMetadataController(wsgi.Controller): metadata, delete) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) + except exception.QuotaError as error: raise exc.HTTPForbidden(explanation=error.format_message()) @@ -151,6 +154,9 @@ class ServerMetadataController(wsgi.Controller): try: self.compute_api.delete_instance_metadata(context, server, id) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) + except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index aca867c2f255..fb424642496e 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -792,6 +792,8 @@ class ServersController(wsgi.Controller): instance = self._get_server(context, req, id) try: self.compute_api.confirm_resize(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) @@ -810,6 +812,8 @@ class ServersController(wsgi.Controller): instance = self._get_server(context, req, id) try: self.compute_api.revert_resize(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) @@ -849,6 +853,8 @@ class ServersController(wsgi.Controller): try: self.compute_api.resize(context, instance, flavor_id, **kwargs) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.QuotaError as error: raise exc.HTTPForbidden( explanation=error.format_message(), @@ -891,6 +897,8 @@ class ServersController(wsgi.Controller): except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -995,6 +1003,8 @@ class ServersController(wsgi.Controller): except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.ImageNotFound: msg = _("Cannot find image for rebuild") raise exc.HTTPBadRequest(explanation=msg) @@ -1055,6 +1065,8 @@ class ServersController(wsgi.Controller): instance, image_name, extra_properties=metadata) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage', id) @@ -1107,6 +1119,8 @@ class ServersController(wsgi.Controller): self.compute_api.start(context, instance) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'start', id) @@ -1124,6 +1138,8 @@ class ServersController(wsgi.Controller): self.compute_api.stop(context, instance) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'stop', id) diff --git a/nova/api/openstack/compute/shelve.py b/nova/api/openstack/compute/shelve.py index 2ccbe9fa1835..6f9f8ae2d5d0 100644 --- a/nova/api/openstack/compute/shelve.py +++ b/nova/api/openstack/compute/shelve.py @@ -43,6 +43,8 @@ class ShelveController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.shelve(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -60,6 +62,8 @@ class ShelveController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.shelve_offload(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -77,6 +81,8 @@ class ShelveController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.unshelve(context, instance) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/suspend_server.py b/nova/api/openstack/compute/suspend_server.py index 02a142bfc2b7..b01aaceaca24 100644 --- a/nova/api/openstack/compute/suspend_server.py +++ b/nova/api/openstack/compute/suspend_server.py @@ -41,6 +41,8 @@ class SuspendServerController(wsgi.Controller): try: server = common.get_instance(self.compute_api, context, id) self.compute_api.suspend(context, server) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -57,6 +59,8 @@ class SuspendServerController(wsgi.Controller): try: server = common.get_instance(self.compute_api, context, id) self.compute_api.resume(context, server) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index c05b82ddd9c8..fc881f0a7b63 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -281,6 +281,8 @@ class VolumeAttachmentController(wsgi.Controller): try: device = self.compute_api.attach_volume(context, instance, volume_id, device) + except exception.InstanceUnknownCell 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: @@ -399,6 +401,8 @@ class VolumeAttachmentController(wsgi.Controller): pass except exception.InvalidVolume as e: raise exc.HTTPBadRequest(explanation=e.format_message()) + except exception.InstanceUnknownCell as e: + raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message())