diff options
author | Koren Lev <korenlev@gmail.com> | 2017-10-24 13:35:42 +0300 |
---|---|---|
committer | Koren Lev <korenlev@gmail.com> | 2017-10-24 10:38:56 +0000 |
commit | 78b0f48b178325c74d5609bac5c764ac111ad808 (patch) | |
tree | 80cb343392677253d1cd57b1d641a304b61deff8 /app/discover/fetchers/db | |
parent | fb90353f2bf5f3c20b5ada3df2ef3f7c1bee47b8 (diff) |
several bug fixes for release 1.1opnfv-5.1.RC1opnfv-5.1.0
Change-Id: I433d41245107a68959efdcd6b56ce3348c7bbeb5
Signed-off-by: Koren Lev <korenlev@gmail.com>
(cherry picked from commit 7cba26258ea17f790028a7005cb9bbbdc3923389)
Diffstat (limited to 'app/discover/fetchers/db')
-rw-r--r-- | app/discover/fetchers/db/db_access.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/app/discover/fetchers/db/db_access.py b/app/discover/fetchers/db/db_access.py index 64d7372..090ab84 100644 --- a/app/discover/fetchers/db/db_access.py +++ b/app/discover/fetchers/db/db_access.py @@ -40,11 +40,12 @@ class DbAccess(Fetcher): # connection timeout set to 30 seconds, # due to problems over long connections - TIMEOUT = 30 + TIMEOUT = 5 - def __init__(self): + def __init__(self, mysql_config=None): super().__init__() - self.config = Configuration() + self.config = {'mysql': mysql_config} if mysql_config \ + else Configuration() self.conf = self.config.get("mysql") self.connect_to_db() self.neutron_db = self.get_neutron_db_name() @@ -61,8 +62,9 @@ class DbAccess(Fetcher): database=_database, raise_on_warnings=True) DbAccess.conn.ping(True) # auto-reconnect if necessary - except: - self.log.critical("failed to connect to MySQL DB") + except Exception as e: + self.log.critical("failed to connect to MySQL DB: {}" + .format(str(e))) return DbAccess.query_count_per_con = 0 @@ -91,10 +93,9 @@ class DbAccess(Fetcher): DbAccess.conn = None self.conf = self.config.get("mysql") cnf = self.conf - cnf['schema'] = cnf['schema'] if 'schema' in cnf else 'nova' - self.db_connect(cnf["host"], cnf["port"], - cnf["user"], cnf["pwd"], - cnf["schema"]) + self.db_connect(cnf.get('host', ''), cnf.get('port', ''), + cnf.get('user', ''), cnf.get('pwd', ''), + cnf.get('schema', 'nova')) @with_cursor def get_objects_list_for_id(self, query, object_type, object_id, |