def __init__(self, rpcClient=None, transferClient=None, smdb=None, **kwargs): self.__serviceName = "WorkloadManagement/SandboxStore" self.__rpcClient = rpcClient self.__transferClient = transferClient self.__kwargs = kwargs self.__vo = None SandboxStoreClient.__smdb = smdb if 'delegatedGroup' in kwargs: self.__vo = getVOForGroup(kwargs['delegatedGroup']) if SandboxStoreClient.__smdb is None: try: from DIRAC.WorkloadManagementSystem.DB.SandboxMetadataDB import SandboxMetadataDB SandboxStoreClient.__smdb = SandboxMetadataDB() result = SandboxStoreClient.__smdb._getConnection() # pylint: disable=protected-access if not result['OK']: SandboxStoreClient.__smdb = False else: result['Value'].close() except (ImportError, RuntimeError, AttributeError): SandboxStoreClient.__smdb = False
def __init__(self, rpcClient=None, transferClient=None, smdb=False, **kwargs): """ Constructor :param object rpcClient: SandboxStore service client (None by default) :param object transferClient: client to upload/download sandboxes (None by default) :param object smdb: SandboxMetadataDB object, or True if SandboxMetadataDB is to be instantiated for direct access or False if no direct access to the SandboxMetadataDB is done (default) """ self.__serviceName = "WorkloadManagement/SandboxStore" self.__rpcClient = rpcClient self.__transferClient = transferClient self.__kwargs = kwargs self.__vo = None SandboxStoreClient.__smdb = smdb if 'delegatedGroup' in kwargs: self.__vo = getVOForGroup(kwargs['delegatedGroup']) if SandboxStoreClient.__smdb is True: try: from DIRAC.WorkloadManagementSystem.DB.SandboxMetadataDB import SandboxMetadataDB SandboxStoreClient.__smdb = SandboxMetadataDB() result = SandboxStoreClient.__smdb._getConnection() # pylint: disable=protected-access if not result['OK']: SandboxStoreClient.__smdb = False else: result['Value'].close() except (ImportError, RuntimeError, AttributeError): SandboxStoreClient.__smdb = False
def __init__(self, useCertificates=False, rpcClient=False, transferClient=False, delegatedDN=None, delegatedGroup=None, setup=None): self.__serviceName = "WorkloadManagement/SandboxStore" self.__rpcClient = rpcClient self.__transferClient = transferClient self.__useCertificates = useCertificates self.__delegatedDN = delegatedDN self.__delegatedGroup = delegatedGroup self.__setup = setup if SandboxStoreClient.__smdb == None: try: from DIRAC.WorkloadManagementSystem.DB.SandboxMetadataDB import SandboxMetadataDB SandboxStoreClient.__smdb = SandboxMetadataDB() result = SandboxStoreClient.__smdb._getConnection() if not result['OK']: SandboxStoreClient.__smdb = False else: result['Value'].close() except (ImportError, RuntimeError, AttributeError): SandboxStoreClient.__smdb = False
def test_SandboxMetadataDB(): smDB = SandboxMetadataDB() seNameToUse = "ProductionSandboxSE" sbPath = "/sb/pfn/1.tar.bz2" assignTo = {"adminusername": "******"} res = smDB.registerAndGetSandbox( "adminusername", "/C=ch/O=DIRAC/OU=DIRAC CI/CN=ciuser", "dirac_admin", seNameToUse, sbPath, 123 ) assert res["OK"], res["Message"] sbURL = f"SB:{seNameToUse}|{sbPath}" assignTo = dict([(key, [(sbURL, assignTo[key])]) for key in assignTo]) res = smDB.assignSandboxesToEntities(assignTo, "adminusername", "dirac_admin", "enSetup") assert res["OK"], res["Message"]
def test_SSCChain( self ): """ full test of functionalities """ ssc = SandboxStoreClient() smDB = SandboxMetadataDB() exeScriptLocation = find_all( 'exe-script.py', '.', 'WorkloadManagementSystem' )[0] fileList = [exeScriptLocation] res = ssc.uploadFilesAsSandbox( fileList ) self.assert_( res['OK'] ) # SEPFN = res['Value'].split( '|' )[1] res = ssc.uploadFilesAsSandboxForJob( fileList, 1, 'Input' ) self.assert_( res['OK'] ) # res = ssc.downloadSandboxForJob( 1, 'Input' ) #to run this would need the RSS on # self.assert_( res['OK'] ) # only ones needing the DB res = smDB.getUnusedSandboxes() self.assert_( res['OK'] )
def test_SSCChain(): """full test of functionalities""" ssc = SandboxStoreClient() smDB = SandboxMetadataDB() exeScriptLocation = find_all("exe-script.py", "..", "/DIRAC/tests/Integration")[0] fileList = [exeScriptLocation] res = ssc.uploadFilesAsSandbox(fileList) assert res["OK"] is True, res["Message"] # SEPFN = res['Value'].split( '|' )[1] res = ssc.uploadFilesAsSandboxForJob(fileList, 1, "Input") assert res["OK"] is True, res["Message"] res = ssc.downloadSandboxForJob(1, "Input") # to run this we need the RSS on print(res) # for debug... assert res["OK"] is True, res["Message"] # only ones needing the DB res = smDB.getUnusedSandboxes() print(res) assert res["OK"] is True, res["Message"]
def test_SSCChain(self): """ full test of functionalities """ ssc = SandboxStoreClient() smDB = SandboxMetadataDB() exeScriptLocation = find_all('exe-script.py', '..', '/DIRAC/tests/Integration')[0] fileList = [exeScriptLocation] res = ssc.uploadFilesAsSandbox(fileList) assert res['OK'] is True # SEPFN = res['Value'].split( '|' )[1] res = ssc.uploadFilesAsSandboxForJob(fileList, 1, 'Input') assert res['OK'] is True res = ssc.downloadSandboxForJob(1, 'Input') # to run this we need the RSS on print res # for debug... assert res['OK'] is True # only ones needing the DB res = smDB.getUnusedSandboxes() print res assert res['OK'] is True
def test_SSCChain(self): """ full test of functionalities """ ssc = SandboxStoreClient() smDB = SandboxMetadataDB() exeScriptLocation = find_all('exe-script.py', '..', '/DIRAC/tests/Integration')[0] fileList = [exeScriptLocation] res = ssc.uploadFilesAsSandbox(fileList) assert res['OK'] is True # SEPFN = res['Value'].split( '|' )[1] res = ssc.uploadFilesAsSandboxForJob(fileList, 1, 'Input') assert res['OK'] is True res = ssc.downloadSandboxForJob(1, 'Input') # to run this we need the RSS on print(res) # for debug... assert res['OK'] is True # only ones needing the DB res = smDB.getUnusedSandboxes() print(res) assert res['OK'] is True
def __init__(self, rpcClient=None, transferClient=None, **kwargs): self.__serviceName = "WorkloadManagement/SandboxStore" self.__rpcClient = rpcClient self.__transferClient = transferClient self.__kwargs = kwargs if SandboxStoreClient.__smdb == None: try: from DIRAC.WorkloadManagementSystem.DB.SandboxMetadataDB import SandboxMetadataDB SandboxStoreClient.__smdb = SandboxMetadataDB() result = SandboxStoreClient.__smdb._getConnection() if not result['OK']: SandboxStoreClient.__smdb = False else: result['Value'].close() except (ImportError, RuntimeError, AttributeError): SandboxStoreClient.__smdb = False
def initializeSandboxStoreHandler(serviceInfo): global sandboxDB, gSBDeletionPool random.seed() sandboxDB = SandboxMetadataDB() return S_OK()
def initializeSandboxStoreHandler(serviceInfo): global sandboxDB sandboxDB = SandboxMetadataDB() return S_OK()
def initializeHandler(cls, serviceInfoDict): """ Initialization of DB object """ cls.sandboxDB = SandboxMetadataDB() return S_OK()