Abort instance provision if it goes to some status
If the instance goes to some status like deleting, we should abort the provision. Change-Id: Id6382388af7a15636f7dd102e4f1d0d0fbf31113
This commit is contained in:
parent
e508d77796
commit
e265fd8e45
|
@ -289,6 +289,10 @@ class CreateInstanceTask(flow_utils.MoganTask):
|
|||
|
||||
def _wait_for_active(self, instance):
|
||||
"""Wait for the node to be marked as ACTIVE in Ironic."""
|
||||
instance.refresh()
|
||||
if instance.status in (status.DELETING, status.ERROR, status.DELETED):
|
||||
raise exception.InstanceDeployFailure(
|
||||
_("Instance %s provisioning was aborted") % instance.uuid)
|
||||
|
||||
node = ironic.get_node_by_instance(self.ironicclient,
|
||||
instance.uuid)
|
||||
|
|
|
@ -87,3 +87,8 @@ class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
|
|||
updates = self.obj_get_changes()
|
||||
self.dbapi.instance_update(context, self.uuid, updates)
|
||||
self.obj_reset_changes()
|
||||
|
||||
def refresh(self, context=None):
|
||||
"""Refresh the object by re-fetching from the DB."""
|
||||
current = self.__class__.get(context, self.uuid)
|
||||
self.obj_refresh(current)
|
||||
|
|
Loading…
Reference in New Issue