コード例 #1
0
def create_env(env_request, interactive=True):
    if env_request.template_name:
        platform = env_request.platform
        env_request.platform = None
    else:
        platform = None
    while True:
        try:
            return elasticbeanstalk.create_environment(env_request)

        except InvalidParameterValueError as e:
            if e.message == responses['app.notexists'].replace(
                    '{app-name}', '\'' + env_request.app_name + '\''):
                commonops.create_app(env_request.app_name)
            elif e.message == responses['create.noplatform']:
                if platform:
                    env_request.platform = platform
                else:
                    raise
            elif interactive:
                LOG.debug('creating env returned error: ' + e.message)
                if re.match(responses['env.cnamenotavailable'], e.message):
                    io.echo(prompts['cname.unavailable'])
                    io.prompt_for_cname()
                elif re.match(responses['env.nameexists'], e.message):
                    io.echo(strings['env.exists'])
                    current_environments = elasticbeanstalk.get_all_environment_names(
                    )
                    unique_name = utils.get_unique_name(
                        env_request.env_name, current_environments)
                    env_request.env_name = io.prompt_for_environment_name(
                        default_name=unique_name)
                elif e.message == responses['app.notexists'].replace(
                        '{app-name}', '\'' + env_request.app_name + '\''):
                    commonops.create_app(env_request.app_name)
                else:
                    raise
            else:
                raise
コード例 #2
0
def get_cname_from_customer(env_name):
    """
    Prompt customer to specify the CNAME for the environment.

    Selection defaults to the Environment's name when provided with blank input.
    :param env_name: name of the environment whose CNAME to configure
    :return: CNAME chosen for the environment
    """
    while True:
        cname = io.prompt_for_cname(default=env_name)
        if cname and not elasticbeanstalk.is_cname_available(cname):
            io.echo('That cname is not available. Please choose another.')
        else:
            break
    return cname
コード例 #3
0
ファイル: createops.py プロジェクト: dangjoeltang/SimpleShop
def create_env(env_request, interactive=True):
    # If a template is being used, we want to try using just the template
    if env_request.template_name:
        platform = env_request.platform
        env_request.platform = None
    else:
        platform = None
    while True:
        try:
            return elasticbeanstalk.create_environment(env_request)

        except InvalidParameterValueError as e:
            if e.message == responses['app.notexists'].replace(
                        '{app-name}', '\'' + env_request.app_name + '\''):
                # App doesnt exist, must be a new region.
                ## Lets create the app in the region
                commonops.create_app(env_request.app_name)
            elif e.message == responses['create.noplatform']:
                if platform:
                    env_request.platform = platform
                else:
                    raise
            elif interactive:
                LOG.debug('creating env returned error: ' + e.message)
                if re.match(responses['env.cnamenotavailable'], e.message):
                    io.echo(prompts['cname.unavailable'])
                    cname = io.prompt_for_cname()
                elif re.match(responses['env.nameexists'], e.message):
                    io.echo(strings['env.exists'])
                    current_environments = elasticbeanstalk.get_all_environment_names()
                    unique_name = utils.get_unique_name(env_request.env_name,
                                                        current_environments)
                    env_request.env_name = io.prompt_for_environment_name(
                        default_name=unique_name)
                elif e.message == responses['app.notexists'].replace(
                            '{app-name}', '\'' + env_request.app_name + '\''):
                    # App doesnt exist, must be a new region.
                    ## Lets create the app in the region
                    commonops.create_app(env_request.app_name)
                else:
                    raise
            else:
                raise
コード例 #4
0
def clone_env(clone_request):
    while True:
        try:
            return elasticbeanstalk.clone_environment(clone_request)
        except InvalidParameterValueError as e:
            LOG.debug('cloning env returned error: ' + e.message)
            if re.match(responses['env.cnamenotavailable'], e.message):
                io.echo(prompts['cname.unavailable'])
                clone_request.cname = io.prompt_for_cname()
            elif re.match(responses['env.nameexists'], e.message):
                io.echo(strings['env.exists'])
                current_environments = elasticbeanstalk.get_environment_names(
                    clone_request.app_name)
                unique_name = utils.get_unique_name(clone_request.env_name,
                                                    current_environments)
                clone_request.env_name = io.prompt_for_environment_name(
                    default_name=unique_name)
            else:
                raise