Merge "Implement the do_check method to check stack's status"

This commit is contained in:
Jenkins 2015-06-25 02:52:14 +00:00 committed by Gerrit Code Review
commit 94875cb5e0
2 changed files with 21 additions and 2 deletions

View File

@ -19,6 +19,7 @@ class HeatClient(base.DriverBase):
def __init__(self, context):
self.conn = sdk.create_connection(context)
self.session = self.conn.session
def stack_create(self, **params):
try:

View File

@ -197,8 +197,26 @@ class StackProfile(base.Profile):
return True
def do_check(self, obj):
# TODO(anyone): Use heat client to query stack status
return True
"""Check stack status."""
hc = self.heat(obj)
try:
stack = hc.stack_get(obj.physical_id)
except Exception as ex:
raise ex
# When the stack is in a status which can't be checked(
# CREATE_IN_PROGRESS, DELETE_IN_PROGRESS, etc), return False.
try:
stack.check(hc.session)
except Exception:
return False
status = stack.status
while status == 'CHECK_IN_PROGRESS':
status = hc.stack_get(obj.physical_id).status
if status == 'CHECK_COMPLETE':
return True
else:
return False
def get_template(self):
return {}