Commit 5eeb24d9 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Modified 'copyData()' method to support both CSTORE and HSTORE request types.

parent ef68f958
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
import os
import shutil
import subprocess
import sys

from config import Config
@@ -19,7 +20,9 @@ class StoreExecutor(TaskExecutor):
        self.params = config.loadSection("transfer_node")
        self.storageStorePath = self.params["store_path"]
        self.params = config.loadSection("tape_library")
        self.storageBasePath = self.params["base_path"]
        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"],
@@ -28,17 +31,26 @@ class StoreExecutor(TaskExecutor):
                                  self.params["db"])
        self.jobObj = None
        self.username = None
        self.requestType = None
        self.nodeList = []
        super(StoreExecutor, self).__init__()
        
    def copyData(self):
        srcPathPrefix = self.storageStorePath.replace("{username}", self.username)
        destPathPrefix = self.storageBasePath.replace("{username}", self.username)
        srcData = os.listdir(srcPathPrefix)
        if self.requestType == "CSTORE"
            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)            
            sp = subprocess.run(["rsync", "-av", srcPathPrefix + '/', destPathPrefix + '/'], capture_output = True)
            if(sp.returncode or sp.stderr):
                return False
            else:
                return True

    def cleanup(self):
        srcPathPrefix = self.storageStorePath.replace("{username}", self.username)
@@ -68,6 +80,7 @@ class StoreExecutor(TaskExecutor):
            if self.srcQueue.len() > 0:
                self.jobObj = self.srcQueue.getJob()
                self.username = self.jobObj.jobInfo["userName"]
                self.requestType = self.jobObj.jobInfo["requestType"]
                self.nodeList = self.jobObj.jobInfo["nodeList"]
                # 1) Controlla il tipo di destinazione: hot (server) o cold (tape)
                # *) HOT