Пример #1
0
def update_environment(env_name,
                       changes,
                       nohang,
                       remove=None,
                       template=None,
                       timeout=None,
                       template_body=None,
                       solution_stack_name=None,
                       platform_arn=None):
    try:
        request_id = elasticbeanstalk.update_environment(
            env_name,
            changes,
            remove=remove,
            template=template,
            template_body=template_body,
            solution_stack_name=solution_stack_name,
            platform_arn=platform_arn)
    except InvalidStateError:
        io.log_error(prompts['update.invalidstate'])
        return
    except InvalidSyntaxError as e:
        io.log_error(prompts['update.invalidsyntax'] + '\nError = ' +
                     e.message)
        return

    if nohang:
        return

    io.echo('Printing Status:')

    wait_for_success_events(request_id,
                            timeout_in_minutes=timeout,
                            can_abort=True)
Пример #2
0
def setenv(app_name, env_name, var_list, timeout=None):

    options, options_to_remove = create_environment_variables_list(var_list)

    request_id = elasticbeanstalk.update_environment(env_name,
                                                     options,
                                                     remove=options_to_remove)

    if timeout is None:
        timeout = 4

    commonops.wait_for_success_events(request_id,
                                      timeout_in_minutes=timeout,
                                      can_abort=True)
Пример #3
0
def setenv(app_name, env_name, var_list, timeout=None):

    options, options_to_remove = create_environment_variables_list(var_list)

    request_id = elasticbeanstalk.update_environment(env_name, options,
                                                     remove=options_to_remove)

    if timeout is None:
        # specify a lower timeout duration because the `UpdateEnvironment`
        # workflow does not take very long to just set environment variables.
        timeout = 4

    commonops.wait_for_success_events(request_id,
                                      timeout_in_minutes=timeout,
                                      can_abort=True)
Пример #4
0
def setenv(app_name, env_name, var_list, timeout=None):

    options, options_to_remove = create_environment_variables_list(var_list)

    request_id = elasticbeanstalk.update_environment(env_name,
                                                     options,
                                                     remove=options_to_remove)

    if timeout is None:
        # specify a lower timeout duration because the `UpdateEnvironment`
        # workflow does not take very long to just set environment variables.
        timeout = 4

    commonops.wait_for_success_events(request_id,
                                      timeout_in_minutes=timeout,
                                      can_abort=True)
Пример #5
0
def scale(app_name, env_name, number, confirm, timeout=None):
    options = []
    # get environment
    env = elasticbeanstalk.describe_configuration_settings(
        app_name, env_name)['OptionSettings']

    # if single instance, offer to switch to load-balanced
    namespace = 'aws:elasticbeanstalk:environment'
    setting = next((n for n in env if n["Namespace"] == namespace), None)
    value = setting['Value']
    if value == 'SingleInstance':
        if not confirm:
            ## prompt to switch to LoadBalanced environment type
            io.echo(prompts['scale.switchtoloadbalance'])
            io.log_warning(prompts['scale.switchtoloadbalancewarn'])
            switch = io.get_boolean_response()
            if not switch:
                return

        options.append({
            'Namespace': namespace,
            'OptionName': 'EnvironmentType',
            'Value': 'LoadBalanced'
        })

    # change autoscaling min AND max to number
    namespace = 'aws:autoscaling:asg'
    max = 'MaxSize'
    min = 'MinSize'

    for name in [max, min]:
        options.append({
            'Namespace': namespace,
            'OptionName': name,
            'Value': str(number)
        })
    request_id = elasticbeanstalk.update_environment(env_name, options)

    commonops.wait_for_success_events(request_id,
                                      timeout_in_minutes=timeout or 5,
                                      can_abort=True)