aboutsummaryrefslogtreecommitdiffstats
path: root/app/discover/fetchers/db/db_access.py
diff options
context:
space:
mode:
authorKoren Lev <korenlev@gmail.com>2017-10-24 13:35:42 +0300
committerKoren Lev <korenlev@gmail.com>2017-10-24 13:35:42 +0300
commit7cba26258ea17f790028a7005cb9bbbdc3923389 (patch)
tree603f9b7bd2fa6226f99fde9bfa1526f172fef154 /app/discover/fetchers/db/db_access.py
parente2240ef940939a6c0cc30ca6370aae0d42c5a4af (diff)
several bug fixes for release 1.1
Change-Id: I433d41245107a68959efdcd6b56ce3348c7bbeb5 Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'app/discover/fetchers/db/db_access.py')
-rw-r--r--app/discover/fetchers/db/db_access.py19
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,