Merge "Catch InstanceInvalidState for start/stop action"
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user