def delete_all_stacks(): stacks = TempestClients.heat().stacks.list() for stack in stacks: try: TempestClients.heat().stacks.delete(stack.to_dict()['id']) except Exception: pass wait_for_status(30, _check_num_stacks, num_stacks=0) time.sleep(4)
def create_stacks(num_stacks, nested, template_file, image): tpl_files, template = template_utils.process_template_path( template_file, object_request=http.authenticated_fetcher(TempestClients.heat())) for i in range(num_stacks): stack_name = 'stack_%s' % i + ('_nested' if nested else '') TempestClients.heat().stacks.create(stack_name=stack_name, template=template, files=tpl_files, parameters={'image': image}) wait_for_status(45, _check_num_stacks, num_stacks=num_stacks, state='CREATE_COMPLETE') time.sleep(2)
def _check_num_stacks(num_stacks, state=''): stacks_list = \ [stack.to_dict() for stack in TempestClients.heat().stacks.list() if 'FAILED' not in stack.to_dict()['stack_status']] if len(stacks_list) != num_stacks: return False return all(stack['stack_status'].upper() == state.upper() for stack in stacks_list)