def get_param_store_paths(): stack_name = utils.get_environ_params('HyP3StackName').pop() [username_param_name, api_key_param_name] = utils.get_environ_params("ParamNameHyP3Username", "ParamNameHyP3ApiKey") utils.step_print(stack_name) return { 'username': '******'.format(stack_name, username_param_name), 'api-key': '/{}/{}'.format(stack_name, api_key_param_name) }
def get_db_low_priv_creds(): """ Get the db params for the low privileged user from environment :returns: host, username, password, dbname in that order :rtype: list[str] """ return utils.get_environ_params( 'HyP3DBHost', 'HyP3DBUser', 'HyP3DBPass', 'HyP3DBName' )
def get_db_creds(): """ Get the db params from environment :returns: host, username, password, dbname in that order :rtype: list[str] """ return utils.get_environ_params( 'HyP3DBHost', 'HyP3DBRootUser', 'HyP3DBRootPass', 'HyP3DBName' )
def add_db_user(db): user, password, db_name = utils.get_environ_params('HyP3DBUser', 'HyP3DBPass', 'HyP3DBName') if does_db_user_exists(db, user): utils.step_print(f'user {user} already exists') return add_user_sql = sql.text(f""" CREATE USER {user} WITH PASSWORD :password; GRANT ALL PRIVILEGES ON DATABASE {db_name} to {user}; """) db.engine.execute(add_user_sql, password=password)
def get_processes(): bucket, key = utils.get_environ_params('DefaultProcessesBucket', 'DefaultProcessesKey') s3 = boto3.resource('s3') base_path = pl.Path('/tmp') if \ 'prod' in os.environ.get('Maturity', 'prod') \ else pl.Path('.') file_path = (base_path / pl.Path(key).name) utils.step_print('downloading default processes') s3.Bucket(bucket) \ .download_file(key, str(file_path)) with file_path.open('r') as f: processes = json.load(f) return processes
def get_user(): name, email = utils.get_environ_params('HyP3AdminUsername', 'HyP3AdminEmail') return User(name, email)