Loading transfer_service/db_connector.py +21 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class DbConnector(object): connect_timeout = 0 ) def getConnection(self, retry = 5, timeout = 2): def getConnection(self, retry = 10, timeout = 30): if retry < 1: retry = 1 if timeout < 1: Loading Loading @@ -702,6 +702,26 @@ class DbConnector(object): finally: self.connPool.putconn(conn, close = False) def getStorageHostname(self, storageId): """Returns the storage hostname for a given storage id, if any. Otherwise it returns 'False'.""" conn = self.getConnection() try: cursor = conn.cursor(cursor_factory = RealDictCursor) cursor.execute("SELECT hostname FROM storage WHERE storage_id = %s;", (storageId,)) result = cursor.fetchall() cursor.close() except Exception: if not conn.closed: conn.rollback() raise else: if result: return result[0]["hostname"] else: return False finally: self.connPool.putconn(conn, close = False) ##### Location ##### def getLocationId(self, destStorageId): Loading Loading
transfer_service/db_connector.py +21 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class DbConnector(object): connect_timeout = 0 ) def getConnection(self, retry = 5, timeout = 2): def getConnection(self, retry = 10, timeout = 30): if retry < 1: retry = 1 if timeout < 1: Loading Loading @@ -702,6 +702,26 @@ class DbConnector(object): finally: self.connPool.putconn(conn, close = False) def getStorageHostname(self, storageId): """Returns the storage hostname for a given storage id, if any. Otherwise it returns 'False'.""" conn = self.getConnection() try: cursor = conn.cursor(cursor_factory = RealDictCursor) cursor.execute("SELECT hostname FROM storage WHERE storage_id = %s;", (storageId,)) result = cursor.fetchall() cursor.close() except Exception: if not conn.closed: conn.rollback() raise else: if result: return result[0]["hostname"] else: return False finally: self.connPool.putconn(conn, close = False) ##### Location ##### def getLocationId(self, destStorageId): Loading