Skip to content
Snippets Groups Projects
Commit 4331f124 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- Improved SQLAlchemy engine and database initialization
parent 61bfa554
No related branches found
No related tags found
1 merge request!142Release TeraFlowSDN 2.1
...@@ -44,9 +44,17 @@ def main(): ...@@ -44,9 +44,17 @@ def main():
start_http_server(metrics_port) start_http_server(metrics_port)
# Get Database Engine instance and initialize database, if needed # Get Database Engine instance and initialize database, if needed
LOGGER.info('Getting SQLAlchemy DB Engine...')
db_engine = Engine.get_engine() db_engine = Engine.get_engine()
if db_engine is None: return -1 if db_engine is None:
Engine.create_database(db_engine) LOGGER.error('Unable to get SQLAlchemy DB Engine...')
return -1
try:
Engine.create_database(db_engine)
except: # pylint: disable=bare-except # pragma: no cover
LOGGER.exception('Failed to check/create the database: {:s}'.format(str(db_engine.url)))
rebuild_database(db_engine) rebuild_database(db_engine)
# Get message broker instance # Get message broker instance
......
...@@ -42,12 +42,6 @@ class Engine: ...@@ -42,12 +42,6 @@ class Engine:
LOGGER.exception('Failed to connect to database: {:s}'.format(str(crdb_uri))) LOGGER.exception('Failed to connect to database: {:s}'.format(str(crdb_uri)))
return None return None
try:
Engine.create_database(engine)
except: # pylint: disable=bare-except # pragma: no cover
LOGGER.exception('Failed to check/create to database: {:s}'.format(str(crdb_uri)))
return None
return engine return engine
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment