Пример #1
0
    def getPileupLockedAndAvailable(self, container, account, scope="cms"):
        """
        Mock method to resolve where the pileup container (and all its blocks)
        is locked and available.
        """
        logging.info("%s: calling mock getPileupLockedAndAvailable",
                     self.__class__.__name__)
        result = dict()
        if not self.isContainer(container):
            raise WMRucioException(
                "Pileup location needs to be resolved for a container DID type"
            )

        kwargs = dict(name=container, account=account, scope=scope)

        try:
            DBS3Reader(PROD_DBS).checkDatasetPath(kwargs['name'])
            blocks = DBS3Reader(PROD_DBS).listFileBlocks(
                dataset=kwargs['name'])
            for block in blocks:
                result[block] = self.sitesByBlock(block)
        except DBSReaderError:
            logging.error("%s: Failed to fetch blocks from DBS",
                          self.__class__.__name__)
        return result
Пример #2
0
    def getDataLockedAndAvailable(self, **kwargs):
        """
        Mock the method to discover where data is locked and available.
        Note that, by default, it will not return any Tape RSEs.
        :return: a unique list of RSEs
        """
        logging.info("%s: Calling mock getDataLockedAndAvailable",
                     self.__class__.__name__)
        if 'name' not in kwargs:
            raise WMRucioException(
                "A DID name must be provided to the getBlockLockedAndAvailable API"
            )
        if self.isContainer(kwargs['name']):
            # then resolve it at container level and all its blocks
            return self.getContainerLockedAndAvailable(**kwargs)

        if 'grouping' in kwargs:
            # long strings seem not to be working, like ALL / DATASET. Make it short!
            kwargs['grouping'] = kwargs['grouping'][0]
        # TODO: either grouping or returnTape should change this response...
        returnTape = kwargs.pop("returnTape", False)

        rses = set()
        if kwargs['name'].split('#')[0] == PILEUP_DATASET:
            # Pileup is at a single site
            sites = ['T2_XX_SiteC']
            _BLOCK_LOCATIONS[kwargs['name']] = sites
        else:
            sites = self.sitesByBlock(block=kwargs['name'])
            _BLOCK_LOCATIONS[kwargs['name']] = sites
        rses.update(sites)
        return list(rses)
Пример #3
0
 def _activityMap(self, rseName):
     """
     It maps the WMAgent type (Production vs T0) and the RSE name to
     properly set the rule activity field
     :param rseName: a string with the RSE name
     :return: a string with the rule activity
     """
     if not self.isT0agent and not rseName.endswith("_Tape"):
         return "Production Output"
     elif self.isT0agent and rseName.endswith("_Tape"):
         return "T0 Tape"
     elif self.isT0agent:
         return "T0 Export"
     else:
         msg = "This code should never be reached. Report it to the developers. "
         msg += "Trying to create container rule for RSE name: {}".format(rseName)
         raise WMRucioException(msg)
Пример #4
0
    def getContainerLockedAndAvailable(self, **kwargs):
        """
        Mock the method to discover where container data is locked and available.
        Note that, by default, it will not return any Tape RSEs.
        :return: a unique list of RSEs
        """
        logging.info("%s: Calling mock getContainerLockedAndAvailable",
                     self.__class__.__name__)
        if 'name' not in kwargs:
            raise WMRucioException(
                "A DID name must be provided to the getContainerLockedAndAvailable API"
            )
        kwargs.setdefault("scope", "cms")

        if kwargs['name'] == PILEUP_DATASET:
            return ['T2_XX_SiteA', 'T2_XX_SiteB', 'T2_XX_SiteC']
        try:
            DBS3Reader(PROD_DBS).checkDatasetPath(kwargs['name'])
            blocks = DBS3Reader(PROD_DBS).dbs.listBlocks(
                dataset=kwargs['name'])
            singleBlock = blocks[0]['block_name']
            return self.sitesByBlock(singleBlock)
        except DBSReaderError:
            return []