'Waits for a Stack to reach a given status.
Note this compares the full $action_$status, e.g
CREATE_COMPLETE, not just COMPLETE which is exposed
via the status property of Stack in heatclient'

def _wait_for_stack_status(self, stack_identifier, status, failure_pattern=None, success_on_not_found=False, signal_required=False, resources_to_signal=None):

    if failure_pattern:
        fail_regexp = re.compile(failure_pattern)
    elif ('FAILED' in status):
        fail_regexp = re.compile('^.*_COMPLETE$')
    else:
        fail_regexp = re.compile('^.*_FAILED$')
    build_timeout = self.conf.build_timeout
    build_interval = self.conf.build_interval
    start = timeutils.utcnow()
    while (timeutils.delta_seconds(start, timeutils.utcnow()) < build_timeout):
        try:
            stack = self.client.stacks.get(stack_identifier, resolve_outputs=False)
        except heat_exceptions.HTTPNotFound:
            if success_on_not_found:
                return
        else:
            if self._verify_status(stack, stack_identifier, status, fail_regexp):
                return
        if signal_required:
            self.signal_resources(resources_to_signal)
        time.sleep(build_interval)
    message = ('Stack    %s    failed    to    reach    %s    status    within    the    required    time    (%s    s).' % (stack_identifier, status, build_timeout))
    raise exceptions.TimeoutException(message)
