Commit dbadd6c5 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Minor change.

parent 6bde9091
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -1189,9 +1189,9 @@ class DbConnector(object):

    ##### Storage #####

    def insertStorage(self, storageType, basePath, hostname):
    def insertStorage(self, storageType, storageBasePath, storageHostname, vospaceUserBasePath):
        """Inserts a storage point."""
        if not self.getStorageId(basePath):
        if not self.getStorageId(storageBasePath):
            try:
                conn = self.getConnection()
                cursor = conn.cursor(cursor_factory = RealDictCursor)
@@ -1203,8 +1203,8 @@ class DbConnector(object):
                    RETURNING storage_id;
                    """,
                    (storageType,
                     basePath,
                     hostname,))
                     storageBasePath,
                     storageHostname,))
                storageSrcId = cursor.fetchall()[0]["storage_id"]
            except Exception:
                if not conn.closed:
@@ -1213,12 +1213,13 @@ class DbConnector(object):
            else:
                try:
                    cursor.execute("""
                        SELECT DISTINCT storage_id
                        SELECT storage_id
                        FROM storage
                        JOIN location ON storage_id = storage_dest_id
                        WHERE storage_type = 'local'
                        AND location_type = 'async';
                        """)
                        AND base_path = %s
                        AND hostname = 'localhost';
                        """,
                        (vospaceUserBasePath,))
                    storageDestId = cursor.fetchall()[0]["storage_id"]
                except Exception:
                    if not conn.closed:
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ class StorageRPCServer(RedisRPCServer):
    def __init__(self, host, port, db, rpcQueue):
        self.type = "storage"
        config = Config("/etc/vos_ts/vos_ts.conf")
        params = config.loadSection("transfer_node")
        self.vospaceUserBasePath = params["base_path"].split("/{")[0]
        params = config.loadSection("logging")
        self.logger = logging.getLogger(__name__)
        logLevel = "logging." + params["log_level"]
@@ -60,7 +62,8 @@ class StorageRPCServer(RedisRPCServer):
            try:
                result = self.dbConn.insertStorage(storageType,
                                                   storageBasePath,
                                                   storageHostname)
                                                   storageHostname,
                                                   self.vospaceUserBasePath)
            except Exception:
                errorMsg = "Database error."
                self.logger.exception(errorMsg)