コード例 #1
0
    def deleteLFN(self, lfn):
        """
        attempts to delete a file. will raise if none of the methods work, returns details otherwise
        """
        log.info("Beginning to delete %s" % 'lfn')
        retval = {}
        # generate list of stageout methods we will try
        stageOutMethods = [self.defaultMethod]
        stageOutMethods.extend(self.fallbacks)

        # loop over all the different methods. This unifies regular and fallback stuff. Nice.
        methodCounter = 0
        for currentMethod in stageOutMethods:
            methodCounter += 1
            (seName, command, options, pfn, protocol) =\
                self.getTransferDetails(lfn, currentMethod)

            retval = {'LFN': lfn, 'PFN': pfn, 'SEName': seName}

            log.info("Attempting deletion method %s" % (methodCounter, ))
            log.info("Current method information: %s" % currentMethod)

            try:
                deleteSlave = retrieveStageOutImpl(command, useNewVersion=True)
            except RegistryError:
                deleteSlave = retrieveStageOutImpl(command,
                                                   useNewVersion=False)
                logging.error(
                    "Tried to load stageout backend %s, a new version isn't there yet"
                    % command)
                logging.error(
                    "Will try to fall back to the oldone, but it's really best to redo it"
                )
                logging.error("Here goes...")
                deleteSlave.removeFile(pfn)
                return retval

            # do the delete. The implementation is responsible for its own verification
            try:
                deleteSlave.doDelete(pfn, seName, command, options, protocol)
            except StageOutError, ex:
                log.info("Delete failed in an expected manner. Exception is:")
                log.info("%s" % str(ex))
                log.info(traceback.format_exc())
                if not self.firstException:
                    self.firstException = ex
                continue
            # note to people who think it's cheeky to catch exception after ranting against it:
            # this makes sense because no matter what the exception, we want to keep going
            # additionally, it prints out the proper backtrace so we can diagnose issues
            # AMM - 6/30/2010
            except Exception, ex:
                log.critical(
                    "Delete failed in an unexpected manner. Exception is:")
                log.critical("%s" % str(ex))
                log.info(traceback.format_exc())
                if not self.firstException:
                    self.firstException = ex
                continue
コード例 #2
0
ファイル: FileManager.py プロジェクト: stuartw/WMCore
 def _doTransfer(self, currentMethod, methodCounter, localFileName, pfn, stageOut):
     """
     performs a transfer using a selected method and retries.
     necessary because python doesn't have a good nested loop break syntax
     """
     
     (seName, command, options, _, protocol) =\
         self.getTransferDetails(localFileName, currentMethod)
     
     # Swap directions if we're staging in
     if not stageOut:
         tempPfn       = pfn
         pfn           = localFileName
         localFileName = tempPfn
                 
     for retryNumber in range(self.numberOfRetries + 1):
         log.info("Attempting transfer method %s, Retry number: %s" % (methodCounter, retryNumber))
         log.info("Current method information: %s" % currentMethod)
         
         try:
             stageOutSlave =  retrieveStageOutImpl(command, useNewVersion=True, stagein = not stageOut)
         except RegistryError:
             stageOutSlave =  retrieveStageOutImpl(command, useNewVersion=False, stagein = not stageOut)
             logging.error("Tried to load stageout backend %s, a new version isn't there yet" % command)
             logging.error("Will try to fall back to the oldone, but it's really best to redo it")
             logging.error("Here goes...")
             stageOutSlave( protocol, localFileName, pfn, options )
             return pfn
         
         # do the copy. The implementation is responsible for its own verification
         newPfn = None
         try:
             # FIXME add checksum stuff
             newPfn = stageOutSlave.doTransfer( localFileName, pfn, stageOut, seName, command, options, protocol, None  )
         except StageOutError, ex:
             log.info("Transfer failed in an expected manner. Exception is:")
             log.info("%s" % str(ex))
             log.info("Sleeping for %s seconds" % self.retryPauseTime)
             log.info(traceback.format_exc())
             time.sleep( self.retryPauseTime )
             if not self.firstException:
                 self.firstException = ex
             continue
         # note to people who think it's cheeky to catch exception after ranting against it:
         # this makes sense because no matter what the exception, we want to keep going
         # additionally, it prints out the proper backtrace so we can diagnose issues
         # AMM - 6/30/2010
         except Exception, ex:
             log.critical("Transfer failed in an unexpected manner. Exception is:")
             log.critical("%s" % str(ex))
             log.critical("Since this is an unexpected error, we are continuing to the next method")
             log.critical("and not retrying the same one")
             log.critical(traceback.format_exc())
             if not self.firstException:
                 self.firstException = ex
             break
コード例 #3
0
ファイル: Registry_t.py プロジェクト: vytjan/WMCore
 def testRetrieveProperBackends(self):
     # make sure the default still gives the old behavior
     self.assertTrue(isinstance(retrieveStageOutImpl('test-win'),
                                WMCore.Storage.Backends.UnittestImpl.WinImpl))
     # make sure you can still explicitly get the old one
     self.assertTrue(isinstance(retrieveStageOutImpl('test-win', useNewVersion=False),
                                WMCore.Storage.Backends.UnittestImpl.WinImpl))
     # make sure that you get the new one if you want it
     self.assertTrue(retrieveStageOutImpl('test-win', useNewVersion=True),
                     WMCore.Storage.Plugins.TestWinImpl.TestWinImpl)
コード例 #4
0
ファイル: FileManager.py プロジェクト: stuartw/WMCore
 def deleteLFN(self, lfn):
     """
     attempts to delete a file. will raise if none of the methods work, returns details otherwise
     """
     log.info("Beginning to delete %s" % 'lfn')
     retval = {}
     # generate list of stageout methods we will try
     stageOutMethods = [ self.defaultMethod ]
     stageOutMethods.extend( self.fallbacks )
     
     # loop over all the different methods. This unifies regular and fallback stuff. Nice.
     methodCounter = 0
     for currentMethod in stageOutMethods:
         methodCounter += 1
         (seName, command, options, pfn, protocol) =\
             self.getTransferDetails(lfn, currentMethod)
         
         retval = { 'LFN' : lfn,
                   'PFN': pfn,
                   'SEName': seName}        
         
         log.info("Attempting deletion method %s" % (methodCounter, ))
         log.info("Current method information: %s" % currentMethod)
         
         try:
             deleteSlave =  retrieveStageOutImpl(command, useNewVersion=True)
         except RegistryError:
             deleteSlave =  retrieveStageOutImpl(command, useNewVersion=False)
             logging.error("Tried to load stageout backend %s, a new version isn't there yet" % command)
             logging.error("Will try to fall back to the oldone, but it's really best to redo it")
             logging.error("Here goes...")
             deleteSlave.removeFile( pfn )
             return retval
         
         # do the delete. The implementation is responsible for its own verification
         try:
             deleteSlave.doDelete( pfn, seName, command, options, protocol  )
         except StageOutError, ex:
             log.info("Delete failed in an expected manner. Exception is:")
             log.info("%s" % str(ex))
             log.info(traceback.format_exc())
             if not self.firstException:
                 self.firstException = ex
             continue
         # note to people who think it's cheeky to catch exception after ranting against it:
         # this makes sense because no matter what the exception, we want to keep going
         # additionally, it prints out the proper backtrace so we can diagnose issues
         # AMM - 6/30/2010
         except Exception, ex:
             log.critical("Delete failed in an unexpected manner. Exception is:")
             log.critical("%s" % str(ex))
             log.info(traceback.format_exc())
             if not self.firstException:
                 self.firstException = ex
             continue
コード例 #5
0
    def deletePFN(self, pfn, lfn, command):
        """
        Delete the given PFN
        """
        try:
            impl = retrieveStageOutImpl(command)
        except Exception as ex:
            msg = "Unable to retrieve impl for file deletion in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command, )
            raise StageOutFailure(msg,
                                  Command=command,
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl.removeFile(pfn)
        except Exception as ex:
            msg = "Failure for file deletion in:\n"
            msg += str(ex)
            try:
                import traceback
                msg += traceback.format_exc()
            except AttributeError as ex:
                msg += "Traceback unavailable\n"
            raise StageOutFailure(msg,
                                  Command=command,
                                  Protocol=command,
                                  LFN=lfn,
                                  TargetPFN=pfn)

        return pfn
コード例 #6
0
ファイル: DeleteMgr.py プロジェクト: BrunoCoimbra/WMCore
    def deletePFN(self, pfn, lfn, command):
        """
        Delete the given PFN
        """
        try:
            impl = retrieveStageOutImpl(command)
        except Exception as ex:
            msg = "Unable to retrieve impl for file deletion in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command,)
            raise StageOutFailure(msg, Command = command,
                                  LFN = lfn, ExceptionDetail = str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl.removeFile(pfn)
        except Exception as ex:
            msg = "Failure for file deletion in:\n"
            msg += str(ex)
            try:
                import traceback
                msg += traceback.format_exc()
            except AttributeError as ex:
                msg += "Traceback unavailable\n"
            raise StageOutFailure(msg, Command = command, Protocol = command,
                                  LFN = lfn, TargetPFN = pfn)

        return pfn
コード例 #7
0
ファイル: DeleteMgr.py プロジェクト: todor-ivanov/WMCore
    def deletePFN(self, pfn, lfn, command):
        """
        Delete the given PFN
        """
        try:
            impl = retrieveStageOutImpl(command)
        except Exception as ex:
            msg = "Unable to retrieve impl for file deletion in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command, )
            raise StageOutFailure(msg,
                                  Command=command,
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl.removeFile(pfn)
        except Exception as ex:
            self.logger.error("Failed to delete file: %s", pfn)
            ex.addInfo(Protocol=command, LFN=lfn, TargetPFN=pfn)
            raise ex

        return pfn
コード例 #8
0
ファイル: StageOutMgr.py プロジェクト: bbockelm/CAFUtilities
    def localStageOut(self, lfn, localPfn):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage out

        """
        seName = self.siteCfg.localStageOut['se-name']
        command = self.siteCfg.localStageOut['command']
        options = self.siteCfg.localStageOut.get('option', None)
        pfn = self.searchTFC(lfn)
        protocol = self.tfc.preferredProtocol
        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN = lfn, TFC = str(self.tfc))


        try:
            impl = retrieveStageOutImpl(command)
        except Exception, ex:
            msg = "Unable to retrieve impl for local stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command,)
            raise StageOutFailure(msg, Command = command,
                                  LFN = lfn, ExceptionDetail = str(ex))
コード例 #9
0
    def localStageIn(self, lfn, override=None):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage in
        i.e. stage in lfn to pfn

        if override is used the follwoing params should be defined:
        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred


        """
        localPfn = os.path.join(os.getcwd(), os.path.basename(lfn))

        if override:
            seName = override['se-name']
            command = override['command']
            options = override['option']
            pfn = "%s%s" % (override['lfn-prefix'], lfn)
            protocol = command
        else:
            seName = self.siteCfg.localStageOut['se-name']
            command = self.siteCfg.localStageOut['command']
            options = self.siteCfg.localStageOut.get('option', None)
            pfn = self.searchTFC(lfn)
            protocol = self.tfc.preferredProtocol

        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN=lfn, TFC=str(self.tfc))

        try:
            impl = retrieveStageOutImpl(command, stagein=True)
        except Exception as ex:
            msg = "Unable to retrieve impl for local stage in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command, )
            raise StageOutFailure(msg,
                                  Command=command,
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(protocol, pfn, localPfn, options)
        except Exception as ex:
            msg = "Failure for local stage in:\n"
            msg += str(ex)
            raise StageOutFailure(msg,
                                  Command=command,
                                  Protocol=protocol,
                                  LFN=lfn,
                                  InputPFN=localPfn,
                                  TargetPFN=pfn)

        return localPfn
コード例 #10
0
    def fallbackStageOut(self, lfn, localPfn, fbParams, checksums):
        """
        _fallbackStageOut_

        Given the lfn and parameters for a fallback stage out, invoke it

        parameters should contain:

        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred

        """
        pfn = "%s%s" % (fbParams['lfn-prefix'], lfn)

        try:
            impl = retrieveStageOutImpl(fbParams['command'])
        except Exception, ex:
            msg = "Unable to retrieve impl for fallback stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: "
            msg += "%s\n" % fbParams['command']
            raise StageOutFailure(msg,
                                  Command=fbParams['command'],
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
コード例 #11
0
    def localStageOut(self, lfn, localPfn, checksums):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage out

        """
        seName = self.siteCfg.localStageOut['se-name']
        command = self.siteCfg.localStageOut['command']
        options = self.siteCfg.localStageOut.get('option', None)
        pfn = self.searchTFC(lfn)
        protocol = self.tfc.preferredProtocol
        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN=lfn, TFC=str(self.tfc))

        try:
            impl = retrieveStageOutImpl(command)
        except Exception, ex:
            msg = "Unable to retrieve impl for local stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command, )
            raise StageOutFailure(msg,
                                  Command=command,
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
コード例 #12
0
ファイル: StageOutMgr.py プロジェクト: nikmagini/WMCore
    def fallbackStageOut(self, lfn, localPfn, fbParams, checksums):
        """
        _fallbackStageOut_

        Given the lfn and parameters for a fallback stage out, invoke it

        parameters should contain:

        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred

        """
        pfn = "%s%s" % (fbParams["lfn-prefix"], lfn)

        try:
            impl = retrieveStageOutImpl(fbParams["command"])
        except Exception as ex:
            msg = "Unable to retrieve impl for fallback stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: "
            msg += "%s\n" % fbParams["command"]
            raise StageOutFailure(msg, Command=fbParams["command"], LFN=lfn, ExceptionDetail=str(ex))

        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(fbParams["command"], localPfn, pfn, fbParams.get("option", None), checksums)
        except Exception as ex:
            msg = "Failure for fallback stage out:\n"
            msg += str(ex)
            raise StageOutFailure(msg, Command=fbParams["command"], LFN=lfn, InputPFN=localPfn, TargetPFN=pfn)

        return pfn
コード例 #13
0
ファイル: StageInMgr.py プロジェクト: HassenRiahi/WMCore
    def localStageIn(self, lfn, override = None):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage in
        i.e. stage in lfn to pfn

        if override is used the follwoing params should be defined:
        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred
        phedex-node - the Name of the PNN to which the file is being xferred

        """
        localPfn = os.path.join(os.getcwd(), os.path.basename(lfn))

        if override:
            seName = override['se-name']
            pnn = override['phedex-node']
            command = override['command']
            options = override['option']
            pfn = "%s%s" % (override['lfn-prefix'], lfn)
            protocol = command
        else:
            seName = self.siteCfg.localStageOut['se-name']
            pnn = self.siteCfg.localStageOut['phedex-node']
            command = self.siteCfg.localStageOut['command']
            options = self.siteCfg.localStageOut.get('option', None)
            pfn = self.searchTFC(lfn)
            protocol = self.tfc.preferredProtocol

        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN = lfn, TFC = str(self.tfc))

        try:
            impl = retrieveStageOutImpl(command, stagein=True)
        except Exception as ex:
            msg = "Unable to retrieve impl for local stage in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command,)
            raise StageOutFailure(msg, Command = command,
                                  LFN = lfn, ExceptionDetail = str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(protocol, pfn, localPfn, options)
        except Exception as ex:
            msg = "Failure for local stage in:\n"
            msg += str(ex)
            raise StageOutFailure(msg, Command = command, Protocol = protocol,
                                  LFN = lfn, InputPFN = localPfn,
                                  TargetPFN = pfn)

        return localPfn
コード例 #14
0
def performDirectTransferImpl(source_file, dest_pfn, dest_se, is_log):
    command = "srmv2-lcg"
    protocol = "srmv2"
    
    try:
        impl = retrieveStageOutImpl(command)
    except Exception, ex:
        msg  = "Unable to retrieve impl for local stage out:\n"
        msg += "Error retrieving StageOutImpl for command named: %s\n" % (command,)
        raise StageOutError.StageOutFailure(msg, Command = command, LFN = dest_pfn, ExceptionDetail = str(ex))
コード例 #15
0
ファイル: RuntimeCleanUp.py プロジェクト: rishiloyola/WMCore
    def invokeCleanUp(self, lfn):
        """
        _invokeCleanUp_

        Instantiate the StageOut impl, map the LFN to PFN using the TFC
        and invoke the CleanUp on that PFN

        """
        #  //
        # // Load Impl
        #//
        try:

            implInstance = retrieveStageOutImpl(self.implName)
        except Exception as ex:
            msg = "Error retrieving Stage Out Impl for name: "
            msg += "%s\n" % self.implName
            msg += str(ex)
            raise CleanUpFailure(lfn, ImplName=self.implName, Message=msg)

        #  //
        # // Match LFN
        #//
        pfn = self.tfc.matchLFN(self.tfc.preferredProtocol, lfn)
        if pfn == None:
            msg = "Unable to map LFN to PFN:\n"
            msg += "LFN: %s\n" % lfn
            raise CleanUpFailure(lfn,
                                 TFC=str(self.tfc),
                                 ImplName=self.implName,
                                 Message=msg,
                                 TFCProtocol=self.tfc.preferredProtocol)

        #  //
        # //  Invoke StageOut Impl removeFile method
        #//
        try:

            implInstance.removeFile(pfn)
        except Exception as ex:
            msg = "Error performing Cleanup command for impl "
            msg += "%s\n" % self.implName
            msg += "On PFN: %s\n" % pfn
            msg += str(ex)

            # //
            # // Will uncomment it after invalidating deleted lfn from mergesensordb
            # //

            raise CleanUpFailure(lfn,
                                 TFC=str(self.tfc),
                                 ImplName=self.implName,
                                 PFN=pfn,
                                 Message=msg,
                                 TFCProtocol=self.tfc.preferredProtocol)
コード例 #16
0
ファイル: RuntimeCleanUp.py プロジェクト: lucacopa/WMCore
    def invokeCleanUp(self, lfn):
        """
        _invokeCleanUp_

        Instantiate the StageOut impl, map the LFN to PFN using the TFC
        and invoke the CleanUp on that PFN

        """
        #  //
        # // Load Impl
        #//
        try:

            implInstance = retrieveStageOutImpl(self.implName)
        except Exception as ex:
            msg = "Error retrieving Stage Out Impl for name: "
            msg += "%s\n" % self.implName
            msg += str(ex)
            raise CleanUpFailure(lfn,
                                 ImplName = self.implName,
                                 Message = msg)

        #  //
        # // Match LFN
        #//
        pfn = self.tfc.matchLFN(self.tfc.preferredProtocol, lfn)
        if pfn == None:
            msg = "Unable to map LFN to PFN:\n"
            msg += "LFN: %s\n" % lfn
            raise CleanUpFailure(lfn, TFC = str(self.tfc),
                                 ImplName = self.implName,
                                 Message = msg,
                                 TFCProtocol = self.tfc.preferredProtocol)

        #  //
        # //  Invoke StageOut Impl removeFile method
        #//
        try:

            implInstance.removeFile(pfn)
        except Exception as ex:
            msg = "Error performing Cleanup command for impl "
            msg += "%s\n" % self.implName
            msg += "On PFN: %s\n" % pfn
            msg += str(ex)

            # //
            # // Will uncomment it after invalidating deleted lfn from mergesensordb
            # //

            raise CleanUpFailure(lfn, TFC = str(self.tfc),
                                 ImplName = self.implName,
                                 PFN = pfn,
                                 Message = msg,
                                 TFCProtocol = self.tfc.preferredProtocol)
コード例 #17
0
ファイル: DeleteMgr.py プロジェクト: AndrewLevin/WMCore
 def deletePFN(self, pfn, lfn, command):
     """
     Delete the given PFN
     """
     try:
         impl = retrieveStageOutImpl(command)
     except Exception, ex:
         msg = "Unable to retrieve impl for file deletion in:\n"
         msg += "Error retrieving StageOutImpl for command named: %s\n" % (
             command,)
         raise StageOutFailure(msg, Command = command,
                               LFN = lfn, ExceptionDetail = str(ex))
コード例 #18
0
ファイル: DeleteMgr.py プロジェクト: samircury/WMCore
 def deletePFN(self, pfn, lfn, command):
     """
     Delete the given PFN
     """
     try:
         impl = retrieveStageOutImpl(command)
     except Exception, ex:
         msg = "Unable to retrieve impl for file deletion in:\n"
         msg += "Error retrieving StageOutImpl for command named: %s\n" % (
             command, )
         raise StageOutFailure(msg,
                               Command=command,
                               LFN=lfn,
                               ExceptionDetail=str(ex))
コード例 #19
0
    def localStageOut(self, lfn, localPfn, checksums):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage out

        """
        seName = self.siteCfg.localStageOut['se-name']
        pnn = self.siteCfg.localStageOut['phedex-node']
        command = self.siteCfg.localStageOut['command']
        options = self.siteCfg.localStageOut.get('option', None)
        pfn = self.searchTFC(lfn)
        protocol = self.tfc.preferredProtocol
        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN=lfn, TFC=str(self.tfc))

        try:
            impl = retrieveStageOutImpl(command)
        except Exception as ex:
            msg = "Unable to retrieve impl for local stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command, )
            raise StageOutFailure(msg,
                                  Command=command,
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(protocol, localPfn, pfn, options, checksums)
        except Exception as ex:
            msg = "Failure for local stage out:\n"
            msg += str(ex)
            try:
                import traceback
                msg += traceback.format_exc()
            except AttributeError as ex:
                msg += "Traceback unavailable\n"
            raise StageOutFailure(msg,
                                  Command=command,
                                  Protocol=protocol,
                                  LFN=lfn,
                                  InputPFN=localPfn,
                                  TargetPFN=pfn)

        return pfn
コード例 #20
0
    def stageOut(self, source, destination, token=None, filesize=None, checksum=None):
        """
        _stageOut_

        Perform a local stage out

        """
        wasSuccessful = False
        msg = ""

        sourcePFN = os.path.join(os.getcwd(), source)
        
        
        seName   = self.siteConf.localStageOut['se-name']
        command  = self.siteConf.localStageOut['command']
        options  = self.siteConf.localStageOut.get('option', None)
        protocol = self.tfc.preferredProtocol

        targetPFN = self.tfc.matchLFN(self.tfc.preferredProtocol, destination)
        msg += "Target PFN is: %s\n" % targetPFN
        if self.verbose:
            print msg
        
        # first try the regular stageout
        try: # an exception around normal stageout
            try:
                impl = retrieveStageOutImpl(command)
            except Exception, ex:
                msg += "Unable to retrieve impl for local stage out:\n"
                msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                    command,)
                self.summary['LocalStageOut'] = \
                          "Failure: Cant retrieve StageOut Impl"
                raise RuntimeError, msg
            
            try:
                impl.retryPause = 15
                impl(protocol, sourcePFN, targetPFN, options)
                wasSuccessful = True
            except Exception, ex:
                msg += "Failure for local stage out:\n"
                msg += str(ex)
                self.summary['LocalStageOut'] = \
                                          "Failure: Local Stage Out Failed"
                raise RuntimeError, msg
コード例 #21
0
    def cleanUp(self,destination):
        """
        _cleanUp_

        Clean up the file from SE

        """
        commandList = [ self.siteConf.localStageOut[ 'command' ] ]
        pfnList     = [ self.tfc.matchLFN(self.tfc.preferredProtocol, destination) ]
        
        for fallback in self.siteConf.fallbackStageOut:
           commandList.append( fallback[ 'command' ])
       	   try:
               pfnList.append( fallback[ 'lfn-prefix' ] + destination )
           except KeyError:
               pfnList.append( destination )
        		 	
        wasSuccessful = False
        msg = ""
        for (command, pfn) in zip( commandList, pfnList ):
            try: # outer try to catch the fallback as a whole
        	
                try: # inner try for getting the impl
                    implInstance = retrieveStageOutImpl(command)
                except Exception, ex:
                    msg += "Unable to retrieve impl for clean up:\n"
                    msg += "Error retrieving StageOutImpl for command named: %s\n" % (command,)
                    self.summary['CleanUp'] = "Failure: Cant retrieve StageOut Impl"
                    raise RuntimeError, msg
		        
                #  //
                # //  Invoke StageOut Impl removeFile method
                #//
                try: # inner try for calling removeFile
                    implInstance.removeFile(pfn)
                except Exception, ex:
                    msg += "Error performing Cleanup command for impl "
                    msg += "%s\n" % command
                    msg += "On PFN: %s\n" % pfn
                    msg += str(ex)
                    self.summary['CleanUp'] = "Failure: Cleanup operation Failed"
                    raise RuntimeError, msg
                self.summary['CleanUp'] = "Successful"
                wasSuccessful = True
コード例 #22
0
ファイル: StageOutMgr.py プロジェクト: HassenRiahi/WMCore
    def localStageOut(self, lfn, localPfn, checksums):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage out

        """
        seName = self.siteCfg.localStageOut['se-name']
        pnn = self.siteCfg.localStageOut['phedex-node']
        command = self.siteCfg.localStageOut['command']
        options = self.siteCfg.localStageOut.get('option', None)
        pfn = self.searchTFC(lfn)
        protocol = self.tfc.preferredProtocol
        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN = lfn, TFC = str(self.tfc))


        try:
            impl = retrieveStageOutImpl(command)
        except Exception as ex:
            msg = "Unable to retrieve impl for local stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                command,)
            raise StageOutFailure(msg, Command = command,
                                  LFN = lfn, ExceptionDetail = str(ex))
        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(protocol, localPfn, pfn, options, checksums)
        except Exception as ex:
            msg = "Failure for local stage out:\n"
            msg += str(ex)
            try:
                import traceback
                msg += traceback.format_exc()
            except AttributeError as ex:
                msg += "Traceback unavailable\n"
            raise StageOutFailure(msg, Command = command, Protocol = protocol,
                                  LFN = lfn, InputPFN = localPfn,
                                  TargetPFN = pfn)

        return pfn
コード例 #23
0
    def fallbackStageOut(self, lfn, localPfn, fbParams, checksums):
        """
        _fallbackStageOut_

        Given the lfn and parameters for a fallback stage out, invoke it

        parameters should contain:

        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        phedex-node - the Name of the PNN to which the file is being xferred

        """
        pfn = "%s%s" % (fbParams['lfn-prefix'], lfn)

        try:
            impl = retrieveStageOutImpl(fbParams['command'])
        except Exception as ex:
            msg = "Unable to retrieve impl for fallback stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: "
            msg += "%s\n" % fbParams['command']
            raise StageOutFailure(msg,
                                  Command=fbParams['command'],
                                  LFN=lfn,
                                  ExceptionDetail=str(ex))

        impl.numRetries = self.numberOfRetries
        impl.retryPause = self.retryPauseTime

        try:
            impl(fbParams['command'], localPfn, pfn,
                 fbParams.get("option", None), checksums)
        except Exception as ex:
            msg = "Failure for fallback stage out:\n"
            msg += str(ex)
            raise StageOutFailure(msg,
                                  Command=fbParams['command'],
                                  LFN=lfn,
                                  InputPFN=localPfn,
                                  TargetPFN=pfn)

        return pfn
コード例 #24
0
    def invokeCleanUp(self, lfn):
        """
        _invokeCleanUp_

        Instantiate the StageOut impl, map the LFN to PFN using the TFC
        and invoke the CleanUp on that PFN

        """
        #  //
        # // Load Impl
        #//
        try:

            implInstance = retrieveStageOutImpl(self.implName)
        except Exception, ex:
            msg = "Error retrieving Stage Out Impl for name: "
            msg += "%s\n" % self.implName
            msg += str(ex)
            raise CleanUpFailure(lfn, ImplName=self.implName, Message=msg)
コード例 #25
0
ファイル: RuntimeCleanUp.py プロジェクト: stuartw/WMCore
    def invokeCleanUp(self, lfn):
        """
        _invokeCleanUp_

        Instantiate the StageOut impl, map the LFN to PFN using the TFC
        and invoke the CleanUp on that PFN

        """
        #  //
        # // Load Impl
        #//
        try:
            
            implInstance = retrieveStageOutImpl(self.implName)
        except Exception, ex:
            msg = "Error retrieving Stage Out Impl for name: "
            msg += "%s\n" % self.implName
            msg += str(ex)
            raise CleanUpFailure(lfn, 
                                 ImplName = self.implName,
                                 Message = msg)
コード例 #26
0
    def localStageIn(self, lfn, override=None):
        """
        _localStageOut_

        Given the lfn and local stage out params, invoke the local stage in
        i.e. stage in lfn to pfn

        if override is used the follwoing params should be defined:
        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred


        """
        localPfn = os.path.join(os.getcwd(), os.path.basename(lfn))

        if override:
            seName = override["se-name"]
            command = override["command"]
            options = override["option"]
            pfn = "%s%s" % (override["lfn-prefix"], lfn)
            protocol = command
        else:
            seName = self.siteCfg.localStageOut["se-name"]
            command = self.siteCfg.localStageOut["command"]
            options = self.siteCfg.localStageOut.get("option", None)
            pfn = self.searchTFC(lfn)
            protocol = self.tfc.preferredProtocol

        if pfn == None:
            msg = "Unable to match lfn to pfn: \n  %s" % lfn
            raise StageOutFailure(msg, LFN=lfn, TFC=str(self.tfc))

        try:
            impl = retrieveStageOutImpl(command, stagein=True)
        except Exception, ex:
            msg = "Unable to retrieve impl for local stage in:\n"
            msg += "Error retrieving StageOutImpl for command named: %s\n" % (command,)
            raise StageOutFailure(msg, Command=command, LFN=lfn, ExceptionDetail=str(ex))
コード例 #27
0
ファイル: StageOutMgr.py プロジェクト: bbockelm/CAFUtilities
    def fallbackStageOut(self, lfn, localPfn, fbParams):
        """
        _fallbackStageOut_

        Given the lfn and parameters for a fallback stage out, invoke it

        parameters should contain:

        command - the stage out impl plugin name to be used
        option - the option values to be passed to that command (None is allowed)
        lfn-prefix - the LFN prefix to generate the PFN
        se-name - the Name of the SE to which the file is being xferred

        """
        pfn = "%s%s" % (fbParams['lfn-prefix'], lfn)

        try:
            impl = retrieveStageOutImpl(fbParams['command'])
        except Exception, ex:
            msg = "Unable to retrieve impl for fallback stage out:\n"
            msg += "Error retrieving StageOutImpl for command named: "
            msg += "%s\n" % fbParams['command']
            raise StageOutFailure(msg, Command = fbParams['command'],
                                  LFN = lfn, ExceptionDetail = str(ex))
コード例 #28
0
ファイル: FileManager.py プロジェクト: todor-ivanov/WMCore
    def _doTransfer(self, currentMethod, methodCounter, localFileName, pfn,
                    stageOut):
        """
        performs a transfer using a selected method and retries.
        necessary because python doesn't have a good nested loop break syntax
        """

        (pnn, command, options, _, protocol) = \
            self.getTransferDetails(localFileName, currentMethod)

        # Swap directions if we're staging in
        if not stageOut:
            tempPfn = pfn
            pfn = localFileName
            localFileName = tempPfn

        for retryNumber in range(self.numberOfRetries + 1):
            log.info("Attempting transfer method %s, Retry number: %s" %
                     (methodCounter, retryNumber))
            log.info("Current method information: %s" % currentMethod)

            try:
                stageOutSlave = retrieveStageOutImpl(command,
                                                     useNewVersion=True,
                                                     stagein=not stageOut)
            except RegistryError:
                stageOutSlave = retrieveStageOutImpl(command,
                                                     useNewVersion=False,
                                                     stagein=not stageOut)
                logging.error(
                    "Tried to load stageout backend %s, a new version isn't there yet"
                    % command)
                logging.error(
                    "Will try to fall back to the oldone, but it's really best to redo it"
                )
                logging.error("Here goes...")
                stageOutSlave(protocol, localFileName, pfn, options)
                return pfn

            # do the copy. The implementation is responsible for its own verification
            newPfn = None
            try:
                # FIXME add checksum stuff
                newPfn = stageOutSlave.doTransfer(localFileName, pfn, stageOut,
                                                  pnn, command, options,
                                                  protocol, None)
            except StageOutError as ex:
                log.info(
                    "Transfer failed in an expected manner. Exception is:")
                log.info("%s" % str(ex))
                log.info("Sleeping for %s seconds" % self.retryPauseTime)
                log.info(traceback.format_exc())
                time.sleep(self.retryPauseTime)
                if not self.firstException:
                    self.firstException = ex
                continue
            # note to people who think it's cheeky to catch exception after ranting against it:
            # this makes sense because no matter what the exception, we want to keep going
            # additionally, it prints out the proper backtrace so we can diagnose issues
            # AMM - 6/30/2010
            except Exception as ex:
                log.critical(
                    "Transfer failed in an unexpected manner. Exception is:")
                log.critical("%s" % str(ex))
                log.critical(
                    "Since this is an unexpected error, we are continuing to the next method"
                )
                log.critical("and not retrying the same one")
                log.critical(traceback.format_exc())
                if not self.firstException:
                    self.firstException = ex
                break

            # successful transfers make it here
            return newPfn
        # unseuccessful transfers make it here
        return False
コード例 #29
0
             
     except RuntimeError, ex:
 
         ### FALLBACK ###
         ### there are N fallbacks in a list called fallbackStageOut ###
         for fallbackCount in range(len(self.siteConf.fallbackStageOut)):
             seName   = self.siteConf.fallbackStageOut[fallbackCount]['se-name']
             command  = self.siteConf.fallbackStageOut[fallbackCount]['command']
             options  = self.siteConf.fallbackStageOut[fallbackCount].get('option', None)
             try:
                 targetPFN = self.siteConf.fallbackStageOut[fallbackCount]['lfn-prefix'] + destination
             except KeyError:
                 targetPFN = destination
     
             try:
                 impl = retrieveStageOutImpl(command)
             except Exception, ex:
                 msg += "Unable to retrieve impl for local stage out:\n"
                 msg += "Error retrieving StageOutImpl for command named: %s\n" % (
                     command,)
                 self.summary['LocalStageOut'] += \
                           "\nFailure: Cant retrieve StageOut Impl for fallback %s" % fallbackCount
                 raise RuntimeError, msg
             
             try:
                 impl.retryPause = 15
                 impl(protocol, sourcePFN, targetPFN, options)
                 wasSuccessful = True
             except Exception, ex:
                 msg += "Failure for local stage out:\n"
                 msg += str(ex)
コード例 #30
0
    def doTransfer(self, sourcePFN, targetPFN, stageOut, seName, command,
                   options, protocol, checksum):
        """
            performs a transfer. stageOut tells you which way to go. returns the new pfn or
            raises on failure. StageOutError (and inherited exceptions) are for expected errors
            such as temporary connection failures. Anything else will be handled as an unexpected
            error and skip retrying with this plugin
        """
        targetPFN = self.createSourceName(protocol, targetPFN)
        sourcePFN = self.createSourceName(protocol, sourcePFN)

        # make directories
        self.createOutputDirectory(os.path.dirname(targetPFN))

        if targetPFN.find('lustre') == -1:
            if not options:
                options = ""

            if stageOut:
                copyCommand =   \
                    self.generateCommandFromPreAndPostParts(\
                                                            ["dccp", "-o", "86400",  "-d", "0", "-X", "-role=cmsprod"],
                                                            [sourcePFN, targetPFN],
                                                            options)
            else:
                copyCommand =   \
                    self.generateCommandFromPreAndPostParts(\
                                                            ["dccp"],
                                                            [pnfsPfn(sourcePFN), targetPFN],
                                                            options)

            logging.info("Staging out with DCCPFNAL")
            logging.info("  commandline: %s" % copyCommand)
            print "command is %s" % copyCommand
            (exitCode, output) = self.doWrapped(copyCommand)
            if exitCode:
                logging.error("Transfer failed")
                raise StageOutFailure("DCCP failed - No good")
            # riddle me this, the following line fails with:
            # not all arguments converted during string formatting
            #FIXME
            logging.info("  output from dccp: %s" % output)
            logging.info("  complete. #")  #exit code" is %s" % exitCode)

            logging.info("Verifying file")
            (exitCode, output) = self.doWrapped([
                '/opt/d-cache/dcap/bin/check_dCachefilecksum.sh',
                pnfsPfn(targetPFN), sourcePFN
            ])
            if exitCode:
                logging.error("Checksum verify failed")
                try:
                    self.doDelete(targetPFN, None, None, None, None)
                except:
                    pass
                raise StageOutFailure("DCCP failed - No good")

            return targetPFN
        else:
            # looks like lustre -- do a regular CP
            copyGuy = retrieveStageOutImpl('cp', useNewVersion=True)
            return copyGuy.doTransfer(sourcePFN, targetPFN, stageOut, seName,
                                      command, options, protocol, checksum)
コード例 #31
0
    msg = "Error: ImplName not provided, you need to provide the --impl option"
    print msg
    sys.exit(1)

if inputPfn == None:
    msg = "Error: Input PFN not provided: use the --input-pfn option"
    print msg
    sys.exit(1)

if targetPfn == None:
    msg = "Error: Target PFN not provided: use the --target-pfn option"
    print msg
    sys.exit(1)

try:
    implInstance = retrieveStageOutImpl(implName)
except StageOutError, ex:
    print "Error retrieving plugin from registry named: %s" % implName
    print str(ex)
    sys.exit(1)

print " Invoking StageOutImpl: %s" % implName
implInstance(protocol, inputPfn, targetPfn)

if doCleanup:
    #  //
    # // Cleanup implies that we invoke the implementations
    #//  removeFile method on the target PFN after the transfer
    print "Invoking %s.removeFile on %s" % (implName, targetPfn)
    implInstance.removeFile(targetPfn)
コード例 #32
0
ファイル: DCCPFNALImpl.py プロジェクト: jha2/WMCore
    def doTransfer(self, sourcePFN, targetPFN, stageOut, pnn, command, options, protocol, checksum ):
        """
            performs a transfer. stageOut tells you which way to go. returns the new pfn or
            raises on failure. StageOutError (and inherited exceptions) are for expected errors
            such as temporary connection failures. Anything else will be handled as an unexpected
            error and skip retrying with this plugin
        """
        targetPFN = self.createSourceName(protocol, targetPFN)
        sourcePFN = self.createSourceName(protocol, sourcePFN)


        # make directories
        self.createOutputDirectory(os.path.dirname(targetPFN))

        if targetPFN.find('lustre') == -1:
            if not options:
                options = ""

            if stageOut:
                copyCommand =   \
                    self.generateCommandFromPreAndPostParts(\
                                                            ["dccp", "-o", "86400",  "-d", "0", "-X", "-role=cmsprod"],
                                                            [sourcePFN, targetPFN],
                                                            options)
            else:
                copyCommand =   \
                    self.generateCommandFromPreAndPostParts(\
                                                            ["dccp"],
                                                            [pnfsPfn(sourcePFN), targetPFN],
                                                            options)


            logging.info("Staging out with DCCPFNAL")
            logging.info("  commandline: %s" % copyCommand)
            print("command is %s" % copyCommand)
            (exitCode, output) = self.doWrapped(copyCommand)
            if exitCode:
                logging.error("Transfer failed")
                raise StageOutFailure("DCCP failed - No good")
            # riddle me this, the following line fails with:
            # not all arguments converted during string formatting
            #FIXME
            logging.info("  output from dccp: %s" % output)
            logging.info("  complete. #" )#exit code" is %s" % exitCode)

            logging.info("Verifying file")
            (exitCode, output) = self.doWrapped(['/opt/d-cache/dcap/bin/check_dCachefilecksum.sh',
                                                    pnfsPfn(targetPFN),
                                                    sourcePFN])
            if exitCode:
                logging.error("Checksum verify failed")
                try:
                    self.doDelete(targetPFN,None,None,None,None)
                except:
                    pass
                raise StageOutFailure("DCCP failed - No good")

            return targetPFN
        else:
            # looks like lustre -- do a regular CP
            copyGuy = retrieveStageOutImpl('cp',useNewVersion = True)
            return copyGuy.doTransfer(sourcePFN,targetPFN,stageOut, pnn, command, options, protocol, checksum)
コード例 #33
0
ファイル: TestImpl.py プロジェクト: AndresTanasijczuk/WMCore
    msg = "Error: ImplName not provided, you need to provide the --impl option"
    print(msg)
    sys.exit(1)

if inputPfn == None:
    msg = "Error: Input PFN not provided: use the --input-pfn option"
    print(msg)
    sys.exit(1)

if targetPfn == None:
    msg = "Error: Target PFN not provided: use the --target-pfn option"
    print(msg)
    sys.exit(1)

try:
    implInstance = retrieveStageOutImpl(implName)
except StageOutError as ex:
    print("Error retrieving plugin from registry named: %s" % implName)
    print(str(ex))
    sys.exit(1)


print(" Invoking StageOutImpl: %s" % implName)
implInstance(protocol, inputPfn, targetPfn)


if doCleanup:
    #  //
    # // Cleanup implies that we invoke the implementations
    #//  removeFile method on the target PFN after the transfer
    print("Invoking %s.removeFile on %s" % (implName, targetPfn))