Merge "Stop handling 'InstanceUnknownCell' exception"

This commit is contained in:
Zuul 2019-05-31 13:31:02 +00:00 committed by Gerrit Code Review
commit c9afa017a6
17 changed files with 8 additions and 92 deletions

View File

@ -44,8 +44,6 @@ class AdminActionsController(wsgi.Controller):
instance = common.get_instance(self.compute_api, context, id)
try:
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())
@ -59,8 +57,6 @@ class AdminActionsController(wsgi.Controller):
instance = common.get_instance(self.compute_api, context, id)
try:
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())

View File

@ -47,8 +47,6 @@ class AdminPasswordController(wsgi.Controller):
password = body['changePassword']['adminPass']
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,
exception.SetAdminPasswdNotSupported,
exception.InstanceAgentNotEnabled) as e:

View File

@ -68,8 +68,6 @@ 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)

View File

@ -39,8 +39,6 @@ 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:
@ -59,8 +57,7 @@ class DeferredDeleteController(wsgi.Controller):
'project_id': instance.project_id})
try:
self.compute_api.force_delete(context, instance)
except (exception.InstanceNotFound,
exception.InstanceUnknownCell) as e:
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceIsLocked as e:
raise webob.exc.HTTPConflict(explanation=e.format_message())

View File

@ -132,8 +132,6 @@ class EvacuateController(wsgi.Controller):
try:
self.compute_api.evacuate(context, instance, host,
on_shared_storage, password, force)
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)

View File

@ -272,8 +272,6 @@ 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)

View File

@ -139,8 +139,6 @@ class MigrateServerController(wsgi.Controller):
self.compute_api.live_migrate(context, instance, block_migration,
disk_over_commit, host, force,
async_)
except exception.InstanceUnknownCell as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except (exception.NoValidHost,
exception.ComputeServiceUnavailable,
exception.InvalidHypervisorType,

View File

@ -47,8 +47,6 @@ 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())
@ -67,7 +65,5 @@ 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())

View File

@ -44,8 +44,7 @@ class PauseServerController(wsgi.Controller):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'pause', id)
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except NotImplementedError:
common.raise_feature_not_supported()
@ -65,8 +64,7 @@ class PauseServerController(wsgi.Controller):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'unpause', id)
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except NotImplementedError:
common.raise_feature_not_supported()

View File

@ -52,8 +52,7 @@ class RemoteConsolesController(wsgi.Controller):
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except 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())
@ -81,8 +80,7 @@ class RemoteConsolesController(wsgi.Controller):
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except 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())
@ -112,8 +110,7 @@ class RemoteConsolesController(wsgi.Controller):
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except 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())
@ -138,8 +135,7 @@ class RemoteConsolesController(wsgi.Controller):
output = self.compute_api.get_serial_console(context,
instance,
console_type)
except (exception.InstanceUnknownCell,
exception.InstanceNotFound) as e:
except 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())

View File

@ -61,8 +61,6 @@ 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:
@ -89,8 +87,6 @@ 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:

View File

@ -108,16 +108,10 @@ class ServerMetadataController(wsgi.Controller):
server,
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())
except exception.InstanceIsLocked 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,
'update metadata', server_id)
@ -150,13 +144,8 @@ class ServerMetadataController(wsgi.Controller):
server = common.get_instance(self.compute_api, context, server_id)
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())
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'delete metadata', server_id)

View File

@ -852,8 +852,6 @@ 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)
@ -872,8 +870,6 @@ 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)
@ -927,8 +923,6 @@ 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())
@ -967,8 +961,6 @@ 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,
exception.AllocationDeleteFailed) as e:
raise exc.HTTPConflict(explanation=e.format_message())
@ -1093,8 +1085,6 @@ 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)
@ -1188,8 +1178,6 @@ 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)
@ -1262,8 +1250,6 @@ 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)
@ -1282,8 +1268,6 @@ 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)

View File

@ -45,8 +45,6 @@ class ShelveController(wsgi.Controller):
'project_id': instance.project_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:
@ -64,8 +62,6 @@ 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:
@ -98,8 +94,6 @@ class ShelveController(wsgi.Controller):
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:

View File

@ -38,8 +38,6 @@ class SuspendServerController(wsgi.Controller):
target={'user_id': server.user_id,
'project_id': server.project_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:
@ -56,8 +54,6 @@ class SuspendServerController(wsgi.Controller):
server = common.get_instance(self.compute_api, context, id)
try:
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:

View File

@ -335,8 +335,7 @@ class VolumeAttachmentController(wsgi.Controller):
device = self.compute_api.attach_volume(
context, instance, volume_id, device, tag=tag,
supports_multiattach=supports_multiattach)
except (exception.InstanceUnknownCell,
exception.VolumeNotFound) as e:
except exception.VolumeNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except (exception.InstanceIsLocked,
exception.DevicePathInUse,
@ -449,8 +448,6 @@ class VolumeAttachmentController(wsgi.Controller):
self.compute_api.detach_volume(context, instance, volume)
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.InvalidInput as e:
raise exc.HTTPBadRequest(explanation=e.format_message())
except exception.InstanceIsLocked as e:

View File

@ -104,19 +104,6 @@ class DeferredDeleteExtensionTestV21(test.NoDBTestCase):
self.assertIn('Instance fake_uuid could not be found',
ex.explanation)
@mock.patch.object(compute_api.API, 'get')
@mock.patch.object(compute_api.API, 'force_delete',
side_effect=exception.InstanceUnknownCell(
instance_uuid='fake_uuid'))
def test_force_delete_instance_cellunknown(self, mock_force_delete,
mock_get):
req = fakes.HTTPRequest.blank('/v2/fake/servers/fake_uuid/action')
ex = self.assertRaises(webob.exc.HTTPNotFound,
self.extension._force_delete,
req, 'fake_uuid', '')
self.assertIn('Cell is not known for instance fake_uuid',
ex.explanation)
@mock.patch.object(compute_api.API, 'get')
@mock.patch.object(compute_api.API, 'restore')
def test_restore(self, mock_restore, mock_get):