def undeploy(force=False): """ Undeploy an environment :type force: bool :param force: Skip the safety question :returns: bool -- True if the delete of all stacks was successful """ message = ( 'This will DELETE all stacks in the environment. ' 'This action cannot be undone. ' 'Are you sure you want to do continue? [N/y] ') choice = 'yes' if not force: choice = raw_input(message).lower() if choice not in ['yes', 'y']: print('Skipping undeployment.') return None stacks = config.get_stacks() stacks.reverse() if not stacks: LOGGER.warning('No stacks to undeploy.') return None delete_successful = True for stack in stacks: status = delete_stack(stack) if status != 'DELETE_COMPLETE': LOGGER.warning('The stack finished with status {}'.format(status)) delete_successful = False return delete_successful
def undeploy(force=False): """ Undeploy an environment :type force: bool :param force: Skip the safety question :returns: bool -- True if the delete of all stacks was successful """ message = ('This will DELETE all stacks in the environment. ' 'This action cannot be undone. ' 'Are you sure you want to do continue? [N/y] ') choice = 'yes' if not force: choice = raw_input(message).lower() if choice not in ['yes', 'y']: print('Skipping undeployment.') return None stacks = config.get_stacks() stacks.reverse() if not stacks: LOGGER.warning('No stacks to undeploy.') return None delete_successful = True for stack in stacks: status = delete_stack(stack) if status != 'DELETE_COMPLETE': LOGGER.warning('The stack finished with status {}'.format(status)) delete_successful = False return delete_successful
def validate_templates_all_stacks(): """ Validate the template for all stacks""" for stack in config.get_stacks(): template = config.get_stack_template(stack) result = CONNECTION.validate_template( _get_json_from_template(template)) if result: LOGGER.info('Template {} is valid!'.format(template))
def list_all_stacks(): """ List stacks and their statuses """ cf_stacks = CONNECTION.list_stacks() for stack in config.get_stacks(): stack_found = False for cf_stack in cf_stacks: if stack == cf_stack.stack_name: stack_found = True if stack_found: print('{:<30}{}'.format(stack, cf_stack.stack_status)) else: print('{:<30}{}'.format(stack, 'NOT_RUNNING'))
def list_events_all_stacks(): """ List events for all configured stacks """ for stack_name in config.get_stacks(): stack = get_stack_by_name(stack_name) if not stack: break _print_event_log_title() written_events = [] for event in reversed(CONNECTION.describe_stack_events( stack.stack_id)): if event.event_id not in written_events: written_events.append(event.event_id) _print_event_log_event(event)
def deploy(): """ Ensure stack is up and running (create or update it) """ # Run pre-deploy-hook _pre_deploy_hook() stack_names = config.get_stacks() if not stack_names: LOGGER.warning('No stacks configured, nothing to deploy') return for stack_name in stack_names: ensure_stack( stack_name, template=config.get_stack_template(stack_name), disable_rollback=config.get_stack_disable_rollback(stack_name), parameters=config.get_stack_parameters(stack_name), timeout_in_minutes=config.get_stack_timeout_in_minutes(stack_name), tags=config.get_stack_tags(stack_name)) # Run post-deploy-hook _post_deploy_hook()
def print_output_all_stacks(): """ Print the output for all stacks """ for stack in config.get_stacks(): _print_stack_output(stack)