Exemple #1
0
        blockCloseMaxSize = int(
            kwargs.get("BlockCloseMaxSize", helper.getBlockCloseMaxSize()))

        helper.setBlockCloseSettings(blockCloseMaxWaitTime, blockCloseMaxFiles,
                                     blockCloseMaxEvents, blockCloseMaxSize)

        helper.setDashboardActivity(kwargs.get("dashboard", ""))
        Utilities.saveWorkload(helper, request['RequestWorkflow'],
                               self.wmstatWriteURL)

        # update AcquisitionEra in the Couch document (#4380)
        # request object returned above from Oracle doesn't have information Couch
        # database
        reqDetails = Utilities.requestDetails(request["RequestName"])
        couchDb = Database(reqDetails["CouchWorkloadDBName"],
                           reqDetails["CouchURL"])
        couchDb.updateDocument(request["RequestName"],
                               "ReqMgr",
                               "updaterequest",
                               fields={
                                   "AcquisitionEra":
                                   reqDetails["AcquisitionEra"],
                                   "Teams":
                                   JsonWrapper.JSONEncoder().encode(
                                       kwargs["Teams"]),
                                   "SiteWhitelist":
                                   JsonWrapper.JSONEncoder().encode(whiteList),
                                   "SiteBlacklist":
                                   JsonWrapper.JSONEncoder().encode(blackList)
                               })
Exemple #2
0
    def assignWorkload(self, requestName, kwargs):
        """ Make all the necessary changes in the Workload to reflect the new assignment """
        request = GetRequest.getRequestByName(requestName)
        helper = Utilities.loadWorkload(request)

        #Validate the different parts of the processed dataset
        processedDatasetParts = ["AcquisitionEra", "ProcessingVersion"]
        if kwargs.get("ProcessingString", None):
            processedDatasetParts.append("ProcessingString")
        for field in processedDatasetParts:
            if type(kwargs[field]) == dict:
                for value in kwargs[field].values():
                    self.validate(value, field)
            else:
                self.validate(kwargs[field], field)

        # Set white list and black list
        whiteList = kwargs.get("SiteWhitelist", [])
        blackList = kwargs.get("SiteBlacklist", [])
        if type(whiteList) != list:
            whiteList = [whiteList]
        if type(blackList) != list:
            blackList = [blackList]
        helper.setSiteWildcardsLists(siteWhitelist=whiteList,
                                     siteBlacklist=blackList,
                                     wildcardDict=self.wildcardSites)
        res = set(whiteList) & set(blackList)
        if len(res):
            raise cherrypy.HTTPError(
                400, "White and blacklist the same site is not allowed %s" %
                list(res))
        # Set ProcessingVersion and AcquisitionEra, which could be json encoded dicts
        helper.setProcessingVersion(kwargs["ProcessingVersion"])
        helper.setAcquisitionEra(kwargs["AcquisitionEra"])
        helper.setProcessingString(kwargs.get("ProcessingString", None))

        # Now verify the output datasets
        outputDatasets = helper.listOutputDatasets()
        for dataset in outputDatasets:
            tokens = dataset.split("/")
            procds = tokens[2]
            try:
                WMCore.Lexicon.procdataset(procds)
            except AssertionError as ex:
                raise cherrypy.HTTPError(
                    400,
                    "Bad output dataset name, check the processed dataset.\n %s"
                    % str(ex))

        #FIXME not validated
        helper.setLFNBase(kwargs["MergedLFNBase"], kwargs["UnmergedLFNBase"])
        helper.setMergeParameters(int(kwargs.get("MinMergeSize", 2147483648)),
                                  int(kwargs.get("MaxMergeSize", 4294967296)),
                                  int(kwargs.get("MaxMergeEvents", 50000)))
        helper.setupPerformanceMonitoring(
            int(kwargs.get("MaxRSS", 2411724)),
            int(kwargs.get("MaxVSize", 20411724)),
            int(kwargs.get("SoftTimeout", 129600)),
            int(kwargs.get("GracePeriod", 300)))

        # Check whether we should check location for the data
        useAAA = strToBool(kwargs.get("useSiteListAsLocation", False))
        if useAAA:
            helper.setLocationDataSourceFlag(flag=useAAA)

        # Set phedex subscription information
        custodialList = kwargs.get("CustodialSites", [])
        nonCustodialList = kwargs.get("NonCustodialSites", [])
        autoApproveList = kwargs.get("AutoApproveSubscriptionSites", [])
        for site in autoApproveList:
            if site.endswith('_MSS'):
                raise cherrypy.HTTPError(
                    400, "Auto-approval to MSS endpoint not allowed %s" %
                    autoApproveList)
        subscriptionPriority = kwargs.get("SubscriptionPriority", "Low")
        if subscriptionPriority not in ["Low", "Normal", "High"]:
            raise cherrypy.HTTPError(
                400, "Invalid subscription priority %s" % subscriptionPriority)
        custodialType = kwargs.get("CustodialSubType", "Replica")
        if custodialType not in ["Move", "Replica"]:
            raise cherrypy.HTTPError(
                400, "Invalid custodial subscription type %s" % custodialType)
        nonCustodialType = kwargs.get("NonCustodialSubType", "Replica")
        if nonCustodialType not in ["Move", "Replica"]:
            raise cherrypy.HTTPError(
                400,
                "Invalid noncustodial subscription type %s" % nonCustodialType)

        helper.setSubscriptionInformationWildCards(
            wildcardDict=self.wildcardSites,
            custodialSites=custodialList,
            nonCustodialSites=nonCustodialList,
            autoApproveSites=autoApproveList,
            custodialSubType=custodialType,
            nonCustodialSubType=nonCustodialType,
            priority=subscriptionPriority)

        # Block closing information
        blockCloseMaxWaitTime = int(
            kwargs.get("BlockCloseMaxWaitTime",
                       helper.getBlockCloseMaxWaitTime()))
        blockCloseMaxFiles = int(
            kwargs.get("BlockCloseMaxFiles", helper.getBlockCloseMaxFiles()))
        blockCloseMaxEvents = int(
            kwargs.get("BlockCloseMaxEvents", helper.getBlockCloseMaxEvents()))
        blockCloseMaxSize = int(
            kwargs.get("BlockCloseMaxSize", helper.getBlockCloseMaxSize()))

        helper.setBlockCloseSettings(blockCloseMaxWaitTime, blockCloseMaxFiles,
                                     blockCloseMaxEvents, blockCloseMaxSize)

        helper.setDashboardActivity(kwargs.get("Dashboard", ""))
        Utilities.saveWorkload(helper, request['RequestWorkflow'],
                               self.wmstatWriteURL)

        # update AcquisitionEra in the Couch document (#4380)
        # request object returned above from Oracle doesn't have information Couch
        # database
        reqDetails = Utilities.requestDetails(request["RequestName"])
        couchDb = Database(reqDetails["CouchWorkloadDBName"],
                           reqDetails["CouchURL"])
        couchDb.updateDocument(
            request["RequestName"],
            "ReqMgr",
            "updaterequest",
            fields={
                "AcquisitionEra": reqDetails["AcquisitionEra"],
                "Teams": JsonWrapper.JSONEncoder().encode(kwargs["Teams"]),
                "OutputDatasets":
                JsonWrapper.JSONEncoder().encode(outputDatasets),
                "SiteWhitelist": JsonWrapper.JSONEncoder().encode(whiteList),
                "SiteBlacklist": JsonWrapper.JSONEncoder().encode(blackList)
            })