Commit 8c1f5000 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added storage info using db instead of config file.

parent f64943b3
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ class StoreExecutor(TaskExecutor):
                                     self.params["password"])
        self.params = config.loadSection("transfer_node")
        self.storageStorePath = self.params["store_path"]
        self.params = config.loadSection("tape_library")
        self.tapeStorageBasePath = self.params["base_path"]
        self.params = config.loadSection("ia2_server")
        self.serverStorageBasePath = self.params["base_path"]
        #self.params = config.loadSection("tape_library")
        #self.tapeStorageBasePath = self.params["base_path"]
        #self.params = config.loadSection("ia2_server")
        #self.serverStorageBasePath = self.params["base_path"]
        self.params = config.loadSection("file_catalog")
        self.dbConn = DbConnector(self.params["user"],
                                  self.params["password"],
@@ -33,6 +33,7 @@ class StoreExecutor(TaskExecutor):
        self.jobObj = None
        self.username = None
        self.requestType = None
        self.storageId = None
        self.nodeList = []
        self.systemUtils = SystemUtils()
        super(StoreExecutor, self).__init__()
@@ -41,13 +42,19 @@ class StoreExecutor(TaskExecutor):
        srcPathPrefix = self.storageStorePath.replace("{username}", self.username)
        srcData = os.listdir(srcPathPrefix)
        if self.requestType == "CSTORE":
            destPathPrefix = self.tapeStorageBasePath.replace("{username}", self.username)
            self.dbConn.connect()
            destPathPrefix = self.dbConn.getStorageBasePath(self.storageId) + '/' + self.username
            self.dbConn.disconnect()
            #destPathPrefix = self.tapeStorageBasePath.replace("{username}", self.username)
            self.tapeClient.connect()
            for el in srcData:
                self.tapeClient.copy(srcPathPrefix + '/' + el, destPathPrefix + '/' + el)
            self.tapeClient.disconnect()
        else:
            destPathPrefix = self.serverStorageBasePath.replace("{username}", self.username)
            self.dbConn.connect()
            destPathPrefix = self.dbConn.getStorageBasePath(self.storageId) + '/' + self.username
            self.dbConn.disconnect()
            #destPathPrefix = self.serverStorageBasePath.replace("{username}", self.username)
            sp = subprocess.run(["rsync", "-av", srcPathPrefix + '/', destPathPrefix + '/'], capture_output = True)
            if(sp.returncode or sp.stderr):
                return False
@@ -87,6 +94,7 @@ class StoreExecutor(TaskExecutor):
                self.jobObj = self.srcQueue.getJob()
                self.username = self.jobObj.jobInfo["userName"]
                self.requestType = self.jobObj.jobInfo["requestType"]
                self.storageId = self.jobObj.jobInfo["storageId"]
                self.nodeList = self.jobObj.jobInfo["nodeList"]
                # 1) Controlla il tipo di destinazione: hot (server) o cold (tape)
                # *) HOT