Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atlas #1067

Merged
merged 3 commits into from
May 16, 2023
Merged

Atlas #1067

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dlx_rest/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

api = Api(app, doc='/api/', authorizations=authorizations)
ns = api.namespace('api', description='DLX MARC REST API')
DB.connect(Config.connect_string)
DB.connect(Config.connect_string, database=Config.dbname)

# Set up the login manager for the API
@login_manager.request_loader
Expand Down
2 changes: 1 addition & 1 deletion dlx_rest/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
login_manager.login_message =""

connect(host=Config.connect_string,db=Config.dbname)
DB.connect(Config.connect_string)
DB.connect(Config.connect_string, database=Config.dbname)

try:
app.secret_key=Config.secret_key
Expand Down
23 changes: 15 additions & 8 deletions dlx_rest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ class Config(object):
bucket = 'undl-files'

if 'DLX_REST_TESTING' in os.environ:
environment = 'test'
connect_string = 'mongomock://localhost'
TESTING = True
LOGIN_DISABLED = True
dbname = 'dlx'
sync_log_collection = 'sync_log'
elif 'DLX_REST_LOCAL' in os.environ:
environment = 'dev'
environment = 'dev/local'
connect_string = "mongodb://localhost:27017/?authSource=undlFiles"
dbname = 'undlFiles'
sync_log_collection = 'sync_log'
Expand All @@ -25,32 +26,33 @@ class Config(object):
environment = 'dev'
client = boto3.client('ssm')
secret_key = client.get_parameter(Name='metadata_cache_key')['Parameter']['Value']
connect_string = client.get_parameter(Name='dev-dlx-connect-string')['Parameter']['Value']
dbname = 'dev_undlFiles'
connect_string = client.get_parameter(Name='devISSU-admin-connect-string')['Parameter']['Value']
dbname = 'undlFiles'
sync_log_collection = 'sync_log'
bucket = 'dev-undl-files'
elif 'DLX_REST_QAT' in os.environ:
environment = 'qat'
client = boto3.client('ssm')
secret_key = client.get_parameter(Name='metadata_cache_key')['Parameter']['Value']
connect_string = client.get_parameter(Name='qat-dlx-connect-string')['Parameter']['Value']
dbname = 'qat_undlFiles'
connect_string = client.get_parameter(Name='devISSU-admin-connect-string')['Parameter']['Value']
dbname = 'undlFiles'
sync_log_collection = 'sync_log'
bucket = 'dev-undl-files'
elif 'DLX_REST_UAT' in os.environ:
environment = 'uat'
client = boto3.client('ssm')
secret_key = client.get_parameter(Name='metadata_cache_key')['Parameter']['Value']
connect_string = client.get_parameter(Name='uat-dlx-connect-string')['Parameter']['Value']
connect_string = client.get_parameter(Name='uatISSU-admin-connect-string')['Parameter']['Value']
dbname = 'uat_undlFiles'
sync_log_collection = 'sync_log'
bucket = 'dev-undl-files'
elif 'DLX_REST_PRODUCTION' in os.environ:
environment = 'prod'
client = boto3.client('ssm')
secret_key = client.get_parameter(Name='metadata_cache_key')['Parameter']['Value']
#connect_string = client.get_parameter(Name='dlx-prod-connect-string')['Parameter']['Value']
connect_string = client.get_parameter(Name='connect-string')['Parameter']['Value']
connect_string = client.get_parameter(Name='dlx-prod-connect-string')['Parameter']['Value']
# Use the following value when we're ready to migrate production to Atlas.
#connect_string = client.get_parameter(Name='prodISSU-admin-connect-string')['Parameter']['Value']
dbname = 'undlFiles'
sync_log_collection = 'dlx_dl_log'
else:
Expand All @@ -61,3 +63,8 @@ class Config(object):
AUTH_COLLECTION = 'auths'
FILE_COLLECTION = 'files'
MAX_QUERY_TIME = 20000

if "@" in connect_string:
print(f'Loading {environment}: {connect_string.split("@")[-1].split("/")[0]}')
else:
print(f'Loading {environment}')