Log id in raise_http_conflict_for_instance_invalid_state()
This commit adds the instance id to the log message generated by raise_http_conflict_for_instance_invalid_state(). Previously, the messages just included the action and state failure information, but when investigating a failure knowing the instance id is useful. While there are other clues in the logs, like the req-id or other unique info about the failed request in the logs already, it increase the effort required to figure out what failed. Directly logging the instance id that failed increases the utility of these log messages. Change-Id: I7328ad16f3cb313266011f778c0c8161eded1801
This commit is contained in:
parent
418b1d201e
commit
c96cadc5a2
|
@ -390,7 +390,7 @@ def get_networks_for_instance(context, instance):
|
|||
return get_networks_for_instance_from_nw_info(nw_info)
|
||||
|
||||
|
||||
def raise_http_conflict_for_instance_invalid_state(exc, action):
|
||||
def raise_http_conflict_for_instance_invalid_state(exc, action, server_id):
|
||||
"""Raises a webob.exc.HTTPConflict instance containing a message
|
||||
appropriate to return via the API based on the original
|
||||
InstanceInvalidState exception.
|
||||
|
@ -399,13 +399,17 @@ def raise_http_conflict_for_instance_invalid_state(exc, action):
|
|||
state = exc.kwargs.get('state')
|
||||
not_launched = exc.kwargs.get('not_launched')
|
||||
if attr and state:
|
||||
msg = _("Cannot '%(action)s' while instance is in %(attr)s "
|
||||
"%(state)s") % {'action': action, 'attr': attr, 'state': state}
|
||||
msg = _("Cannot '%(action)s' instance %(server_id)s while it is in "
|
||||
"%(attr)s %(state)s") % {'action': action, 'attr': attr,
|
||||
'state': state,
|
||||
'server_id': server_id}
|
||||
elif not_launched:
|
||||
msg = _("Cannot '%s' an instance which has never been active") % action
|
||||
msg = _("Cannot '%(action)' instance %(server_id)s which has never "
|
||||
"been active") % {'action': action, 'server_id': server_id}
|
||||
else:
|
||||
# At least give some meaningful message
|
||||
msg = _("Instance is in an invalid state for '%s'") % action
|
||||
msg = _("Instance %(server_id)s is in an invalid state for "
|
||||
"'%(action)s'") % {'action': action, 'server_id': server_id}
|
||||
raise webob.exc.HTTPConflict(explanation=msg)
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'pause')
|
||||
'pause', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Server not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -84,7 +84,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unpause')
|
||||
'unpause', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Server not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -107,7 +107,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'suspend')
|
||||
'suspend', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Server not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -130,7 +130,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'resume')
|
||||
'resume', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Server not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -155,7 +155,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'migrate')
|
||||
'migrate', id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.NoValidHost as e:
|
||||
|
@ -298,7 +298,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
backup_type, rotation, extra_properties=props)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'createBackup')
|
||||
'createBackup', id)
|
||||
|
||||
resp = webob.Response(status_int=202)
|
||||
|
||||
|
@ -356,7 +356,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'os-migrateLive')
|
||||
'os-migrateLive', id)
|
||||
except Exception:
|
||||
if host is None:
|
||||
msg = _("Live migration of instance %s to another host "
|
||||
|
|
|
@ -125,7 +125,7 @@ class InterfaceAttachmentController(object):
|
|||
raise webob.exc.HTTPInternalServerError(explanation=msg)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'attach_interface')
|
||||
'attach_interface', server_id)
|
||||
|
||||
return self.show(req, server_id, vif['id'])
|
||||
|
||||
|
@ -150,7 +150,7 @@ class InterfaceAttachmentController(object):
|
|||
raise webob.exc.HTTPNotImplemented(explanation=msg)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'detach_interface')
|
||||
'detach_interface', server_id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
raise webob.exc.HTTPForbidden(explanation=error.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'restore')
|
||||
'restore', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.action('forceDelete')
|
||||
|
|
|
@ -89,7 +89,7 @@ class Controller(wsgi.Controller):
|
|||
on_shared_storage, password)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'evacuate')
|
||||
'evacuate', id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.ComputeServiceInUse as e:
|
||||
|
|
|
@ -68,7 +68,7 @@ class RescueController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'rescue')
|
||||
'rescue', id)
|
||||
except exception.InvalidVolume as volume_error:
|
||||
raise exc.HTTPConflict(explanation=volume_error.format_message())
|
||||
except exception.InstanceNotRescuable as non_rescuable:
|
||||
|
@ -89,7 +89,8 @@ class RescueController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unrescue')
|
||||
'unrescue',
|
||||
id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class ServerDiagnosticsController(object):
|
|||
return self.compute_api.get_diagnostics(context, instance)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'get_diagnostics')
|
||||
'get_diagnostics', server_id)
|
||||
except NotImplementedError:
|
||||
msg = _("Unable to get diagnostics, functionality not implemented")
|
||||
raise webob.exc.HTTPNotImplemented(explanation=msg)
|
||||
|
|
|
@ -56,7 +56,7 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'shelve')
|
||||
'shelve', id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
@ -73,7 +73,8 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'shelveOffload')
|
||||
'shelveOffload',
|
||||
id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
@ -89,7 +90,8 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unshelve')
|
||||
'unshelve',
|
||||
id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'attach_volume')
|
||||
'attach_volume', server_id)
|
||||
|
||||
# The attach is async
|
||||
attachment = {}
|
||||
|
@ -491,7 +491,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'swap_volume')
|
||||
'swap_volume', server_id)
|
||||
|
||||
if not found:
|
||||
msg = _("volume_id not found: %s") % old_volume_id
|
||||
|
@ -542,7 +542,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'detach_volume')
|
||||
'detach_volume', server_id)
|
||||
|
||||
if not found:
|
||||
msg = _("volume_id not found: %s") % volume_id
|
||||
|
|
|
@ -54,7 +54,7 @@ class AdminPasswordController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as e:
|
||||
raise common.raise_http_conflict_for_instance_invalid_state(
|
||||
e, 'changePassword')
|
||||
e, 'changePassword', id)
|
||||
except NotImplementedError:
|
||||
msg = _("Unable to set password on instance")
|
||||
raise exc.HTTPNotImplemented(explanation=msg)
|
||||
|
|
|
@ -128,7 +128,7 @@ class InterfaceAttachmentController(object):
|
|||
explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'attach_interface')
|
||||
'attach_interface', server_id)
|
||||
|
||||
return self.show(req, server_id, vif['id'])
|
||||
|
||||
|
@ -153,7 +153,7 @@ class InterfaceAttachmentController(object):
|
|||
raise webob.exc.HTTPNotImplemented(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'detach_interface')
|
||||
'detach_interface', server_id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class CreateBackupController(wsgi.Controller):
|
|||
backup_type, rotation, extra_properties=props)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'createBackup')
|
||||
'createBackup', id)
|
||||
|
||||
resp = webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
raise webob.exc.HTTPForbidden(explanation=error.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'restore')
|
||||
'restore', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@extensions.expected_errors((404, 409))
|
||||
|
|
|
@ -89,7 +89,7 @@ class EvacuateController(wsgi.Controller):
|
|||
on_shared_storage, password)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'evacuate')
|
||||
'evacuate', id)
|
||||
except exception.ComputeServiceInUse as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
|
||||
|
|
|
@ -92,7 +92,8 @@ class ExtendedVolumesController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'swap_volume')
|
||||
'swap_volume',
|
||||
id)
|
||||
|
||||
if not found:
|
||||
msg = _("The volume was either invalid or not attached to the "
|
||||
|
@ -156,7 +157,7 @@ class ExtendedVolumesController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(
|
||||
state_error, 'attach_volume')
|
||||
state_error, 'attach_volume', server_id)
|
||||
except exception.InvalidVolume as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
except exception.InvalidDevicePath as e:
|
||||
|
@ -213,7 +214,7 @@ class ExtendedVolumesController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(
|
||||
state_error, 'detach_volume')
|
||||
state_error, 'detach_volume', server_id)
|
||||
else:
|
||||
msg = _("Volume %(volume_id)s is not attached to the "
|
||||
"instance %(server_id)s") % {'server_id': server_id,
|
||||
|
|
|
@ -55,7 +55,7 @@ class MigrateServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'migrate')
|
||||
'migrate', id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.NoValidHost as e:
|
||||
|
@ -101,7 +101,7 @@ class MigrateServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'os-migrateLive')
|
||||
'os-migrateLive', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class PauseServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'pause')
|
||||
'pause', id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except NotImplementedError:
|
||||
|
@ -72,7 +72,7 @@ class PauseServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unpause')
|
||||
'unpause', id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except NotImplementedError:
|
||||
|
|
|
@ -71,7 +71,7 @@ class RescueController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'rescue')
|
||||
'rescue', id)
|
||||
except exception.InvalidVolume as volume_error:
|
||||
raise exc.HTTPConflict(explanation=volume_error.format_message())
|
||||
except exception.InstanceNotRescuable as non_rescuable:
|
||||
|
@ -100,7 +100,8 @@ class RescueController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unrescue')
|
||||
'unrescue',
|
||||
id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class ServerDiagnosticsController(object):
|
|||
return self.compute_api.get_diagnostics(context, instance)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'get_diagnostics')
|
||||
'get_diagnostics', server_id)
|
||||
except NotImplementedError:
|
||||
msg = _("Unable to get diagnostics, functionality not implemented")
|
||||
raise webob.exc.HTTPNotImplemented(explanation=msg)
|
||||
|
|
|
@ -116,7 +116,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'update metadata')
|
||||
'update metadata', server_id)
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
|
@ -152,7 +152,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'delete metadata')
|
||||
'delete metadata', server_id)
|
||||
|
||||
|
||||
class ServerMetadata(extensions.V3APIExtensionBase):
|
||||
|
|
|
@ -701,7 +701,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'confirmResize')
|
||||
'confirmResize', id)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.response(202)
|
||||
|
@ -721,7 +721,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'revertResize')
|
||||
'revertResize', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
|
@ -753,7 +753,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'reboot')
|
||||
'reboot', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
def _resize(self, req, instance_id, flavor_id, **kwargs):
|
||||
|
@ -779,7 +779,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'resize')
|
||||
'resize', instance_id)
|
||||
except exception.ImageNotAuthorized:
|
||||
msg = _("You are not authorized to access the image "
|
||||
"the instance was started with.")
|
||||
|
@ -810,7 +810,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'delete')
|
||||
'delete', id)
|
||||
|
||||
def _image_uuid_from_href(self, image_href):
|
||||
# If the image href was generated by nova api, strip image_href
|
||||
|
@ -911,7 +911,7 @@ class ServersController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'rebuild')
|
||||
'rebuild', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Instance could not be found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -993,7 +993,7 @@ class ServersController(wsgi.Controller):
|
|||
extra_properties=props)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'createImage')
|
||||
'createImage', id)
|
||||
except exception.Invalid as err:
|
||||
raise exc.HTTPBadRequest(explanation=err.format_message())
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'shelve')
|
||||
'shelve', id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
@ -70,7 +70,8 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'shelveOffload')
|
||||
'shelveOffload',
|
||||
id)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
@ -88,7 +89,8 @@ class ShelveController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'unshelve')
|
||||
'unshelve',
|
||||
id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class SuspendServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'suspend')
|
||||
'suspend', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@extensions.expected_errors((404, 409))
|
||||
|
@ -67,7 +67,7 @@ class SuspendServerController(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'resume')
|
||||
'resume', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ class Controller(object):
|
|||
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'update metadata')
|
||||
'update metadata', server_id)
|
||||
|
||||
@wsgi.serializers(xml=common.MetaItemTemplate)
|
||||
def show(self, req, server_id, id):
|
||||
|
@ -191,7 +191,7 @@ class Controller(object):
|
|||
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'delete metadata')
|
||||
'delete metadata', server_id)
|
||||
|
||||
|
||||
def create_resource():
|
||||
|
|
|
@ -1105,7 +1105,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'confirmResize')
|
||||
'confirmResize', id)
|
||||
|
||||
@wsgi.response(202)
|
||||
@wsgi.serializers(xml=FullServerTemplate)
|
||||
|
@ -1126,7 +1126,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'revertResize')
|
||||
'revertResize', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -1159,7 +1159,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'reboot')
|
||||
'reboot', id)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
def _resize(self, req, instance_id, flavor_id, **kwargs):
|
||||
|
@ -1184,7 +1184,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'resize')
|
||||
'resize', instance_id)
|
||||
except exception.ImageNotAuthorized:
|
||||
msg = _("You are not authorized to access the image "
|
||||
"the instance was started with.")
|
||||
|
@ -1214,7 +1214,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'delete')
|
||||
'delete', id)
|
||||
|
||||
def _image_ref_from_req_data(self, data):
|
||||
try:
|
||||
|
@ -1391,7 +1391,7 @@ class Controller(wsgi.Controller):
|
|||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'rebuild')
|
||||
'rebuild', id)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _("Instance could not be found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
@ -1477,7 +1477,7 @@ class Controller(wsgi.Controller):
|
|||
extra_properties=props)
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'createImage')
|
||||
'createImage', id)
|
||||
except exception.Invalid as err:
|
||||
raise exc.HTTPBadRequest(explanation=err.format_message())
|
||||
|
||||
|
|
|
@ -116,7 +116,8 @@ class CommonMixin(object):
|
|||
res = self._make_request('/servers/%s/action' % instance['uuid'],
|
||||
{action: body_map.get(action)})
|
||||
self.assertEqual(409, res.status_int)
|
||||
self.assertIn("Cannot \'%s\' while instance" % action, res.body)
|
||||
self.assertIn("Cannot \'%(action)s\' instance %(id)s"
|
||||
% {'id': instance['uuid'], 'action': action}, res.body)
|
||||
# Do these here instead of tearDown because this method is called
|
||||
# more than once for the same test case
|
||||
self.mox.VerifyAll()
|
||||
|
|
|
@ -138,7 +138,8 @@ class CommonMixin(object):
|
|||
res = self._make_request('/servers/%s/action' % instance.uuid,
|
||||
{action: body_map.get(action)})
|
||||
self.assertEqual(409, res.status_int)
|
||||
self.assertIn("Cannot \'%s\' while instance" % action, res.body)
|
||||
self.assertIn("Cannot \'%(action)s\' instance %(id)s"
|
||||
% {'action': action, 'id': instance.uuid}, res.body)
|
||||
# Do these here instead of tearDown because this method is called
|
||||
# more than once for the same test case
|
||||
self.mox.VerifyAll()
|
||||
|
|
|
@ -378,10 +378,11 @@ class MiscFunctionsTest(test.TestCase):
|
|||
instance_uuid='fake')
|
||||
try:
|
||||
common.raise_http_conflict_for_instance_invalid_state(exc,
|
||||
'meow')
|
||||
'meow', 'fake_server_id')
|
||||
except webob.exc.HTTPConflict as e:
|
||||
self.assertEqual(unicode(e),
|
||||
"Cannot 'meow' while instance is in fake_attr fake_state")
|
||||
"Cannot 'meow' instance fake_server_id while it is in "
|
||||
"fake_attr fake_state")
|
||||
else:
|
||||
self.fail("webob.exc.HTTPConflict was not raised")
|
||||
|
||||
|
|
Loading…
Reference in New Issue