Exemplo n.º 1
0
def create_finalized_configuration(eb_environment_name):
    # requires an rds server has been created for the environment.
    # FLASK_SECRET_KEY
    # S3_BUCKET
    finalized_cred_path = get_finalized_credentials_file_path(
        eb_environment_name)
    if os.path.exists(finalized_cred_path):
        log.error("Encountered a finalized configuration file at %s." %
                  finalized_cred_path)
        log.error(
            "This file contains autogenerated parameters which must be identical between "
            "data processing servers and the Elastic Beanstalk frontend servers.  This file "
            "should not exist at this time, so the deployment process has been aborted."
        )
        EXIT(1)

    config = validate_beiwe_environment_config(eb_environment_name)
    config.update(get_full_db_credentials(eb_environment_name))
    config['FLASK_SECRET_KEY'] = random_alphanumeric_string(80)
    config["S3_BUCKET"] = create_data_bucket(eb_environment_name)
    config.update(create_server_access_credentials(config["S3_BUCKET"]))

    with open(finalized_cred_path, 'w') as f:
        json.dump(config, f, indent=1)
    return config
Exemplo n.º 2
0
def create_data_bucket(eb_environment_name):
    for i in range(10):
        name = "beiwe-data-{}-{}".format(
            eb_environment_name, random_alphanumeric_string(63))[:63].lower()
        log.info("checking availability of bucket name '%s'" % name)
        if check_bucket_name_available(name):
            s3_create_bucket(name)
            return name
    raise Exception(
        "Was not able to construct a bucket name that is not in use.")
Exemplo n.º 3
0
def generate_valid_postgres_credentials():
    """ Generates and prints credentials for database access. """
    credentials = {
        # 1 to 63 alphanumeric characters, first character must be a letter.
        "RDS_USERNAME": random_alphanumeric_starting_with_letter(63),
        # 8 to 128 characters, typeable characters, not /, ", or @
        "RDS_PASSWORD": random_alphanumeric_string(128),
        # 1 to 63 alphanumeric characters, begin with a letter
        "RDS_DB_NAME": random_alphanumeric_starting_with_letter(63)
    }
    print "database username:"******"database password:"******"database name:", credentials['RDS_DB_NAME']
    return credentials
Exemplo n.º 4
0
def create_rabbit_mq_password_file(eb_environment_name):
    with open(get_rabbit_mq_manager_ip_file_path(eb_environment_name),
              'w') as f:
        f.write(random_alphanumeric_string(20))
def create_rabbit_mq_password():
    with open(RABBIT_MQ_PASSWORD_FILE, 'w') as f:
        f.write(random_alphanumeric_string(20))