Example #1
0
def apply_environment_type(parameter_pool, template_spec, stack_name, env_name,
                           option_settings, option_to_remove):
    # If not specified, skip
    envtype = parameter_pool.get_value(PName.EnvironmentType)
    if envtype:
        # Describe applicable option settings
        eb_client = api_wrapper.create_eb_client(parameter_pool)
        app_name = parameter_pool.get_value(PName.ApplicationName, False)

        if env_name:
            raw_option_defs = api_wrapper.retrieve_configuration_options(
                eb_client=eb_client,
                app_name=app_name,
                env_name=env_name,
                template_specification=template_spec,
                options=None)
        else:
            raw_option_defs = api_wrapper.retrieve_configuration_options(
                eb_client=eb_client,
                app_name=app_name,
                solution_stack=stack_name,
                template_specification=template_spec,
                options=None)

        option_defs = set()
        for raw_option_def in raw_option_defs:
            option_defs.add(raw_option_def.namespace + u'-' +
                            raw_option_def.name)

        # Return if environment type option is not available
        if OptionSettingEnvironmentType.Namespace + u'-' + \
            OptionSettingEnvironmentType.OptionName not in option_defs:
            prompt.result(
                ValidationMessage.EnvTypeInapplicable.format(envtype))
            return

        # remove inapplicable option settings
        removed = False
        for namespace in option_settings.keys():

            # TODO Fix this temporary hack to let environment tier options pass through
            if namespace == u'aws:elasticbeanstalk:sqsd':
                continue

            for option_name in option_settings[namespace].keys():
                if not is_customizable_namespace(namespace)\
                    and namespace + u'-' + option_name not in option_defs:
                    remove_option_setting(option_settings, option_to_remove,
                                          namespace, option_name, False)
                    removed = True
        if removed:
            prompt.result(ValidationMessage.EnvTypeBlowAwayOptionSettings)

        # Set environment type
        add_option_setting(option_settings, option_to_remove,
                           OptionSettingEnvironmentType.Namespace,
                           OptionSettingEnvironmentType.OptionName, envtype)
Example #2
0
def apply_environment_type(parameter_pool, template_spec, stack_name, env_name, option_settings, option_to_remove):
    # If not specified, skip 
    envtype = parameter_pool.get_value(PName.EnvironmentType)
    if envtype:
        # Describe applicable option settings
        eb_client = api_wrapper.create_eb_client(parameter_pool)
        app_name = parameter_pool.get_value(PName.ApplicationName, False)
        
        if env_name:
            raw_option_defs = api_wrapper.retrieve_configuration_options(eb_client=eb_client,
                                                              app_name=app_name,
                                                              env_name=env_name,
                                                              template_specification=template_spec,
                                                              options=None)
        else:
            raw_option_defs = api_wrapper.retrieve_configuration_options(eb_client=eb_client,
                                                              app_name=app_name,
                                                              solution_stack=stack_name,
                                                              template_specification=template_spec,
                                                              options=None)
        
        option_defs = set()
        for raw_option_def in raw_option_defs:
            option_defs.add(raw_option_def.namespace + '-' + raw_option_def.name)

        # Return if environment type option is not available
        if OptionSettingEnvironmentType.Namespace + '-' + \
            OptionSettingEnvironmentType.OptionName not in option_defs:
            prompt.result(ValidationMessage.EnvTypeInapplicable.format(envtype))
            return

        # remove inapplicable option settings
        removed = False
        for namespace in list(option_settings.keys()):
            
            # TODO Fix this temporary hack to let environment tier options pass through
            if namespace == 'aws:elasticbeanstalk:sqsd':
                continue
            
            for option_name in list(option_settings[namespace].keys()):
                if not is_customizable_namespace(namespace)\
                    and namespace + '-' + option_name not in option_defs:
                    remove_option_setting(option_settings, option_to_remove, 
                                          namespace, option_name, False)
                    removed = True
        if removed:
            prompt.result(ValidationMessage.EnvTypeBlowAwayOptionSettings)

        # Set environment type
        add_option_setting(option_settings, option_to_remove, 
                           OptionSettingEnvironmentType.Namespace, 
                           OptionSettingEnvironmentType.OptionName, 
                           envtype)
Example #3
0
def has_default_app(parameter_pool, solution_stack, eb_client = None):
    appsource = OptionSepcification(DefualtAppSource.Namespace, DefualtAppSource.OptionName)
    
    options = api_wrapper.retrieve_configuration_options(parameter_pool, 
                                            solution_stack = solution_stack,
                                            options = [appsource],
                                            eb_client = eb_client)
    for option in options:
        if misc.string_equal_ignore_case(DefualtAppSource.Namespace, option.namespace) \
            and misc.string_equal_ignore_case(DefualtAppSource.OptionName, option.name):
            return True
        
    return False
def get_option_def(eb_client, app_name, namespace, option_name, 
                   solution_stack = None, env_name = None):

    options = dict()
    options[namespace] = set()
    options[namespace].add(option_name)
    optionDef = api_wrapper.retrieve_configuration_options(eb_client = eb_client, 
                                                          app_name = app_name, 
                                                          solution_stack =solution_stack, 
                                                          options = options)
    
    if len(optionDef) > 0:
        return optionDef[0]
    else:
        return None
Example #5
0
def has_default_app(parameter_pool, solution_stack, eb_client=None):
    appsource = OptionSepcification(DefaultAppSource.Namespace,
                                    DefaultAppSource.OptionName)

    options = api_wrapper.retrieve_configuration_options(
        parameter_pool,
        solution_stack=solution_stack,
        options=[appsource],
        eb_client=eb_client)
    for option in options:
        if misc.string_equal_ignore_case(DefaultAppSource.Namespace, option.namespace) \
            and misc.string_equal_ignore_case(DefaultAppSource.OptionName, option.name):
            return True

    return False
Example #6
0
def get_option_def(eb_client, app_name, namespace, option_name, 
                   solution_stack = None, env_name = None):

    options = dict()
    options[namespace] = set()
    options[namespace].add(option_name)
    optionDef = api_wrapper.retrieve_configuration_options(eb_client = eb_client, 
                                                          app_name = app_name, 
                                                          solution_stack =solution_stack, 
                                                          options = options)
    
    if len(optionDef) > 0:
        return optionDef[0]
    else:
        return None
Example #7
0
def has_default_app(parameter_pool, solution_stack, eb_client = None):
    appsource_options = {DefaultAppSource.Namespace : {DefaultAppSource.OptionName}}
    
    spec = TemplateSpecification()
    spec.template_source.solution_stack_name = solution_stack,     
    
    options = api_wrapper.retrieve_configuration_options(parameter_pool, 
                                            solution_stack = solution_stack,
                                            options = appsource_options,
                                            template_specification = spec,
                                            eb_client = eb_client)
    for option in options:
        if misc.string_equal_ignore_case(DefaultAppSource.Namespace, option.namespace) \
            and misc.string_equal_ignore_case(DefaultAppSource.OptionName, option.name):
            return True
        
    return False
Example #8
0
def has_default_app(parameter_pool, solution_stack, eb_client = None):
    appsource_options = {DefaultAppSource.Namespace : {DefaultAppSource.OptionName}}
    
    if not eb_client:
        eb_client = api_wrapper.create_eb_client(parameter_pool)
    
    spec = TemplateSpecification()
    spec.template_source.solution_stack_name = solution_stack,     
    
    options = api_wrapper.retrieve_configuration_options(eb_client = eb_client,
                                            solution_stack = solution_stack,
                                            options = appsource_options,
                                            template_specification = spec)
    for option in options:
        if misc.string_equal_ignore_case(DefaultAppSource.Namespace, option.namespace) \
            and misc.string_equal_ignore_case(DefaultAppSource.OptionName, option.name):
            return True
        
    return False
Example #9
0
def apply_environment_type(parameter_pool, stack_name, option_settings,
                           option_to_remove):
    # If not specified, skip
    envtype = parameter_pool.get_value(PName.EnvironmentType)
    if envtype:
        # Describe applicable option settings
        eb_client = api_wrapper.create_eb_client(parameter_pool)
        app_name = parameter_pool.get_value(PName.ApplicationName, False)
        raw_option_defs = api_wrapper.retrieve_configuration_options(
            eb_client=eb_client,
            app_name=app_name,
            solution_stack=stack_name,
            options=None)
        option_defs = set()
        for raw_option_def in raw_option_defs:
            option_defs.add(raw_option_def.namespace + u'-' +
                            raw_option_def.name)

        # Return if environment type option is not available
        if OptionSettingEnvironmentType.Namespace + u'-' + \
            OptionSettingEnvironmentType.OptionName not in option_defs:
            prompt.result(
                ValidationMessage.EnvTypeInapplicable.format(envtype))
            return

        # remove inapplicable option settings
        removed = False
        for namespace in option_settings.keys():
            for option_name in option_settings[namespace].keys():
                if namespace + u'-' + option_name not in option_defs:
                    remove_option_setting(option_settings, option_to_remove,
                                          namespace, option_name, False)
                    removed = True
        if removed:
            prompt.result(ValidationMessage.EnvTypeBlowAwayOptionSettings)

        # Set environment type
        add_option_setting(option_settings, option_to_remove,
                           OptionSettingEnvironmentType.Namespace,
                           OptionSettingEnvironmentType.OptionName, envtype)
Example #10
0
def apply_environment_type(parameter_pool, stack_name, option_settings, option_to_remove):
    # If not specified, skip 
    envtype = parameter_pool.get_value(PName.EnvironmentType)
    if envtype:
        # Describe applicable option settings
        eb_client = api_wrapper.create_eb_client(parameter_pool)
        app_name = parameter_pool.get_value(PName.ApplicationName, False)
        raw_option_defs = api_wrapper.retrieve_configuration_options(eb_client = eb_client, 
                                                              app_name = app_name, 
                                                              solution_stack =stack_name, 
                                                              options = None)    
        option_defs = set()
        for raw_option_def in raw_option_defs:
            option_defs.add(raw_option_def.namespace + u'-' + raw_option_def.name)

        # Return if environment type option is not available
        if OptionSettingEnvironmentType.Namespace + u'-' + \
            OptionSettingEnvironmentType.OptionName not in option_defs:
            prompt.result(ValidationMessage.EnvTypeInapplicable.format(envtype))
            return

        # remove inapplicable option settings
        removed = False
        for namespace in option_settings.keys():
            for option_name in option_settings[namespace].keys():
                if namespace + u'-' + option_name not in option_defs:
                    remove_option_setting(option_settings, option_to_remove, 
                                          namespace, option_name, False)
                    removed = True
        if removed:
            prompt.result(ValidationMessage.EnvTypeBlowAwayOptionSettings)

        # Set environment type
        add_option_setting(option_settings, option_to_remove, 
                           OptionSettingEnvironmentType.Namespace, 
                           OptionSettingEnvironmentType.OptionName, 
                           envtype)