def wait_for_deploy_physical_id(self, stack): build_timeout = self.conf.build_timeout build_interval = self.conf.build_interval start = timeutils.utcnow() while timeutils.delta_seconds(start, timeutils.utcnow()) < build_timeout: created = True for res in self.client.resources.list(stack, nested_depth='2'): if not res.physical_resource_id: created = False break if created: return time.sleep(build_interval) message = ('Deployment resources failed to be created within ' 'the required time (%s s).' % (build_timeout)) raise exceptions.TimeoutException(message)
def _wait_for_stack_status(self, stack_identifier, status, failure_pattern=None, success_on_not_found=False): """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 """ if failure_pattern: fail_regexp = re.compile(failure_pattern) elif 'FAILED' in status: # If we're looking for e.g CREATE_FAILED, COMPLETE is unexpected. 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 # ignore this, as the resource may not have # been created yet else: if self._verify_status(stack, stack_identifier, status, fail_regexp): return 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)
def _wait_for_resource_status(self, stack_identifier, resource_name, status, failure_pattern='^.*_FAILED$', success_on_not_found=False): """Waits for a Resource to reach a given status.""" fail_regexp = re.compile(failure_pattern) build_timeout = self.conf.build_timeout build_interval = self.conf.build_interval res = None start = timeutils.utcnow() while timeutils.delta_seconds(start, timeutils.utcnow()) < build_timeout: try: res = self.client.resources.get(stack_identifier, resource_name) except heat_exceptions.HTTPNotFound: if success_on_not_found: return # ignore this, as the resource may not have # been created yet else: if res.resource_status == status: return wait_for_action = status.split('_')[0] resource_action = res.resource_status.split('_')[0] if (resource_action == wait_for_action and fail_regexp.search(res.resource_status)): raise exceptions.StackResourceBuildErrorException( resource_name=res.resource_name, stack_identifier=stack_identifier, resource_status=res.resource_status, resource_status_reason=res.resource_status_reason) time.sleep(build_interval) message = ('Resource %s from stack %s failed to reach %s status ' 'within the required time (%s s). Current resource ' 'status: %s.' % (resource_name, stack_identifier, status, build_timeout, res.resource_status)) raise exceptions.TimeoutException(message)
def _wait_for_stack_status(self, stack_identifier, status, failure_pattern='^.*_FAILED$', success_on_not_found=False): """ 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 """ fail_regexp = re.compile(failure_pattern) 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) except heat_exceptions.HTTPNotFound: if success_on_not_found: return # ignore this, as the resource may not have # been created yet else: if stack.stack_status == status: return if fail_regexp.search(stack.stack_status): raise exceptions.StackBuildErrorException( stack_identifier=stack_identifier, stack_status=stack.stack_status, stack_status_reason=stack.stack_status_reason) time.sleep(build_interval) message = ('Stack %s failed to reach %s status within ' 'the required time (%s s).' % (stack.stack_name, status, build_timeout)) raise exceptions.TimeoutException(message)