diff --git a/src/09_deploys/service_central_deploys/nosql/mongo_setup.py b/src/09_deploys/service_central_deploys/nosql/mongo_setup.py index 8f5f319..bc88333 100644 --- a/src/09_deploys/service_central_deploys/nosql/mongo_setup.py +++ b/src/09_deploys/service_central_deploys/nosql/mongo_setup.py @@ -1,5 +1,22 @@ +import ssl + import mongoengine -def global_init(): - mongoengine.register_connection(alias='core', name='demo_dealership') +def global_init(user=None, password=None, port=27017, server='localhost', use_ssl=True): + if user or password: + data = dict( + username=user, + password=password, + host=server, + port=port, + authentication_source='admin', + authentication_mechanism='SCRAM-SHA-1', + ssl=use_ssl, + ssl_cert_reqs=ssl.CERT_NONE) + mongoengine.register_connection(alias='core', name='demo_dealership', **data) + data['password'] = '*************' + print(" --> Registering prod connection: {}".format(data)) + else: + print(" --> Registering dev connection") + mongoengine.register_connection(alias='core', name='demo_dealership') diff --git a/src/09_deploys/service_central_deploys/service_app.py b/src/09_deploys/service_central_deploys/service_app.py index 3454956..cb1b8cc 100644 --- a/src/09_deploys/service_central_deploys/service_app.py +++ b/src/09_deploys/service_central_deploys/service_app.py @@ -22,14 +22,19 @@ def print_header(): print('----------------------------------------------') print('| |') print('| SERVICE CENTRAL v.02 |') - print('| demo edition |') + print('| prod edition |') print('| |') print('----------------------------------------------') print() def config_mongo(): - mongo_setup.global_init() + mongo_setup.global_init( + 'the_db_admin', + 'the-password-3809b81f-ba37-403d-8013-a1ebaf13cf94', + 10001, + '107.170.211.24' + ) def user_loop():