diff --git a/nova/api/openstack/compute/contrib/server_start_stop.py b/nova/api/openstack/compute/contrib/server_start_stop.py index e05279c043..8483b8957c 100644 --- a/nova/api/openstack/compute/contrib/server_start_stop.py +++ b/nova/api/openstack/compute/contrib/server_start_stop.py @@ -14,6 +14,7 @@ import webob +from nova.api.openstack import common from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova import compute @@ -45,8 +46,10 @@ class ServerStartStopActionController(wsgi.Controller): try: self.compute_api.start(context, instance) - except (exception.InstanceNotReady, exception.InstanceIsLocked, - exception.InstanceInvalidState) as e: + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'start', id) + except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) return webob.Response(status_int=202) @@ -59,8 +62,10 @@ class ServerStartStopActionController(wsgi.Controller): try: self.compute_api.stop(context, instance) - except (exception.InstanceNotReady, exception.InstanceIsLocked, - exception.InstanceInvalidState) as e: + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'stop', id) + except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) return webob.Response(status_int=202) diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index d87f22b16b..c89bee935e 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -1071,8 +1071,10 @@ class ServersController(wsgi.Controller): LOG.debug('start instance', instance=instance) try: self.compute_api.start(context, instance) - except (exception.InstanceNotReady, exception.InstanceIsLocked, - exception.InstanceInvalidState) as e: + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'start', id) + except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @wsgi.response(202) @@ -1086,8 +1088,10 @@ class ServersController(wsgi.Controller): LOG.debug('stop instance', instance=instance) try: self.compute_api.stop(context, instance) - except (exception.InstanceNotReady, exception.InstanceIsLocked, - exception.InstanceInvalidState) as e: + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'stop', id) + except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message())