diff --git a/senlin/drivers/openstack/heat_v1.py b/senlin/drivers/openstack/heat_v1.py index 6c13b7ef1..5f5e9c5ea 100644 --- a/senlin/drivers/openstack/heat_v1.py +++ b/senlin/drivers/openstack/heat_v1.py @@ -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: diff --git a/senlin/profiles/os/heat/stack.py b/senlin/profiles/os/heat/stack.py index 38c0f248e..d6b4d4aa6 100644 --- a/senlin/profiles/os/heat/stack.py +++ b/senlin/profiles/os/heat/stack.py @@ -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 {}