Beispiel #1
0
def configure_fabric(eb_environment_name, ip_address, key_filename=None):
    if eb_environment_name is not None:
        get_finalized_environment_variables(eb_environment_name)
    if key_filename is None:
        key_filename = get_global_config()['DEPLOYMENT_KEY_FILE_PATH']
    fabric_env.host_string = ip_address
    fabric_env.user = REMOTE_USERNAME
    fabric_env.key_filename = key_filename
    retry(run, "# waiting for ssh to be connectable...")
    run("echo >> {log}".format(log=LOG_FILE))
    sudo("chmod 666 {log}".format(log=LOG_FILE))
def create_processing_server_configuration_file(eb_environment_name):
    list_to_write = ['import os']
    
    for key, value in get_finalized_environment_variables(eb_environment_name).iteritems():
        next_line = "os.environ['{key}'] = '{value}'".format(key=key.upper(), value=value)
        list_to_write.append(next_line)
    string_to_write = '\n'.join(list_to_write) + '\n'
    with open(get_pushed_full_processing_server_env_file_path(eb_environment_name), 'w') as fn:
        fn.write(string_to_write)
Beispiel #3
0
def construct_eb_environment_variables(eb_environment_name):
    global_config = get_global_config()
    try:
        environment_variables = get_finalized_environment_variables(
            eb_environment_name)
    except Exception as e:
        log.error("could not get your environment settings.")
        log.error(e)
        raise

    try:
        server_settings = get_server_configuration_file(eb_environment_name)
    except Exception as e:
        log.error("could not get your server settings.")
        log.error(e)
        raise
    # This needs to be a comma separated list of environment variables declared as "var=value"
    env_var_string = ",".join(
        ["%s=%s" % (k, v) for k, v in environment_variables.iteritems()])

    generated_configuration_details = {
        "ServiceRole": get_or_create_eb_service_role()['Arn'],
        "IamInstanceProfile": get_or_create_eb_instance_profile()['Arn'],
        "EnvironmentVariables": env_var_string,
        "EC2KeyName": global_config["DEPLOYMENT_KEY_NAME"],
        "InstanceType": server_settings['ELASTIC_BEANSTALK_INSTANCE_TYPE'],
        "Notification Endpoint": global_config['SYSTEM_ADMINISTRATOR_EMAIL']
    }

    configuration = get_base_eb_configuration()
    for option in configuration:
        if isinstance(option['Value'], DynamicParameter):
            option['Value'] = generated_configuration_details.pop(
                option['OptionName'])

    if generated_configuration_details:
        pprint(generated_configuration_details)
        raise Exception(
            "encountered unused autogenerated configs, see print statement above to debug."
        )

    return configuration