示例#1
0
 def getRequest(self, requestName=None):
     """ If a request name is specified, return the details of the request. 
     Otherwise, return an overview of all requests """
     if requestName == None:
         return GetRequest.getRequests()
     else:
         return Utilities.requestDetails(requestName)
示例#2
0
 def _getConfigCache(self, requestName, processMethod):
     try:
         request = Utilities.requestDetails(requestName)
     except Exception, ex:
         msg = "Cannot find request %s, check logs." % requestName
         logging.error("%s, reason: %s" % (msg, ex))
         return msg
示例#3
0
 def _getConfigCache(self, requestName, processMethod):
     try:
         request = Utilities.requestDetails(requestName)
     except Exception, ex:
         msg = "Cannot find request %s, check logs." % requestName
         logging.error("%s, reason: %s" % (msg, ex))
         return msg
示例#4
0
文件: Assign.py 项目: stuartw/WMCore
    def handleAssignmentPage(self, **kwargs):
        """ handler for the main page """
        #Accept Json encoded strings
        decodedArgs = {}
        for key in kwargs.keys():
            try:
                decodedArgs[key] = JsonWrapper.loads(kwargs[key])
            except:
                #Probably wasn't JSON
                decodedArgs[key] = kwargs[key]
        kwargs = decodedArgs
        # handle the checkboxes
        teams = []
        requestNames = []
        for key, value in kwargs.iteritems():
            if isinstance(value, types.StringTypes):
                kwargs[key] = value.strip()
            if key.startswith("Team"):
                teams.append(key[4:])
            if key.startswith("checkbox"):
                requestName = key[8:]
                self.validate(requestName)
                requestNames.append(key[8:])
        
        for requestName in requestNames:
            if kwargs['action'] == 'Reject':
                ChangeState.changeRequestStatus(requestName, 'rejected', wmstatUrl = self.wmstatWriteURL) 
            else:
                assignments = GetRequest.getAssignmentsByName(requestName)
                if teams == [] and assignments == []:
                    raise cherrypy.HTTPError(400, "Must assign to one or more teams")
                self.assignWorkload(requestName, kwargs)
                for team in teams:
                    if not team in assignments:
                        ChangeState.assignRequest(requestName, team, wmstatUrl = self.wmstatWriteURL)
                priority = kwargs.get(requestName+':priority', '')
                if priority != '':
                    Utilities.changePriority(requestName, priority, self.wmstatWriteURL)
        participle=kwargs['action']+'ed'
        if self.opshold and kwargs['action'] == 'Assign':
            participle='put into "ops-hold" state (see <a href="%s">OpsClipboard</a>)' % self.clipboardUrl
            # this, previously used, call made all requests injected into OpsClipboard to
            # have campaign_id null since the call doesn't propagate request's 
            # CampaignName at all, AcquisitionEra remains default null and probably
            # a bunch of other things is wrong too
            #requests = [GetRequest.getRequestByName(requestName) for requestName in requestNames]
            requests = [Utilities.requestDetails(requestName) for requestName in requestNames]
            OpsClipboard.inject(self.couchUrl, self.clipboardDB, *requests)
            for request in requestNames:
                ChangeState.changeRequestStatus(requestName, 'ops-hold', wmstatUrl = self.wmstatWriteURL)

        return self.templatepage("Acknowledge", participle=participle, requests=requestNames)
示例#5
0
 def getRequest(self, requestName=None):
     """ If a request name is specified, return the details of the request.
     Otherwise, return an overview of all requests """
     if requestName == None:
         result = GetRequest.getRequests()
     else:
         result = Utilities.requestDetails(requestName)
         try:
             teamNames = GetRequest.getAssignmentsByName(requestName)
             result['teams'] = teamNames
         except:
             # Ignore errors, then we just don't have a team name
             pass
     return result
示例#6
0
 def getRequest(self, requestName=None):
     """ If a request name is specified, return the details of the request.
     Otherwise, return an overview of all requests """
     if requestName == None:
         result = GetRequest.getRequests()
     else:
         result = Utilities.requestDetails(requestName)
         try:
             teamNames = GetRequest.getAssignmentsByName(requestName)
             result['teams'] = teamNames
         except:
             # Ignore errors, then we just don't have a team name
             pass
     return result
示例#7
0
 def details(self, requestName):
     """ A page showing the details for the requests """
     self.validate(requestName)
     try:
         request = Utilities.requestDetails(requestName)
     except AssertionError:
         raise cherrypy.HTTPError(404, "Cannot load request %s" % requestName)
     adminHtml = statusMenu(requestName, request['RequestStatus']) \
               + ' Priority ' + Utilities.priorityMenu(request)
     return self.templatepage("Request", requestName=requestName,
                             detailsFields=self.detailsFields, 
                             requestSchema=request,
                             docId=request.get('ProcConfigCacheID', None),
                             assignments=request['Assignments'],
                             adminHtml=adminHtml,
                             messages=request['RequestMessages'],
                             updateDictList=request['RequestUpdates'])
示例#8
0
 def _getConfigCache(self, requestName, processMethod):
     try:
         request = Utilities.requestDetails(requestName)
     except Exception as ex:
         msg = "Cannot find request %s, check logs." % requestName
         logging.error("%s, reason: %s" % (msg, ex))
         return msg
     url = request.get("ConfigCacheUrl", None) or self.couchUrl
     try:
         configCache = ConfigCache(url, self.configDBName)
         configDocId = request["ConfigCacheID"]
         configCache.loadByID(configDocId)
     except Exception as ex:
         msg = "Cannot find ConfigCache document %s on %s." % (configDocId, url)
         logging.error("%s, reason: %s" % (msg, ex))
         return msg
     return getattr(configCache, processMethod)()
示例#9
0
 def details(self, requestName):
     """ A page showing the details for the requests """
     self.validate(requestName)
     try:
         request = Utilities.requestDetails(requestName)
     except AssertionError:
         raise cherrypy.HTTPError(404, "Cannot load request %s" % requestName)
     adminHtml = statusMenu(requestName, request['RequestStatus']) \
               + ' Priority: ' + Utilities.priorityMenu(request)
     return self.templatepage("Request", requestName=requestName,
                             detailsFields=self.detailsFields,
                             requestSchema=request,
                             docId=request.get('ConfigCacheID', None),
                             assignments=request['Assignments'],
                             adminHtml=adminHtml,
                             messages=request['RequestMessages'],
                             updateDictList=request['RequestUpdates'])
示例#10
0
    def handleAssignmentPage(self, **kwargs):
        """ handler for the main page """
        # handle the checkboxes
        teams = []
        requestNames = []
        for key, value in kwargs.iteritems():
            if isinstance(value, types.StringTypes):
                kwargs[key] = value.strip()
            if key.startswith("Team"):
                teams.append(key[4:])
            if key.startswith("checkbox"):
                requestName = key[8:]
                self.validate(requestName)
                requestNames.append(key[8:])

        for requestName in requestNames:
            if kwargs["action"] == "Reject":
                ChangeState.changeRequestStatus(requestName, "rejected")
            else:
                assignments = GetRequest.getAssignmentsByName(requestName)
                if teams == [] and assignments == []:
                    raise cherrypy.HTTPError(400, "Must assign to one or more teams")
                self.assignWorkload(requestName, kwargs)
                for team in teams:
                    if not team in assignments:
                        ChangeState.assignRequest(requestName, team)
                priority = kwargs.get(requestName + ":priority", "")
                if priority != "":
                    Utilities.changePriority(requestName, priority)
        participle = kwargs["action"] + "ed"
        if self.opshold and kwargs["action"] == "Assign":
            participle = 'put into "ops-hold" state (see <a href="%s">OpsClipboard</a>)' % self.clipboardUrl
            # this, previously used, call made all requests injected into OpsClipboard to
            # have campaign_id null since the call doesn't propagate request's
            # CampaignName at all, AcquisitionEra remains default null and probably
            # a bunch of other things is wrong too
            # requests = [GetRequest.getRequestByName(requestName) for requestName in requestNames]
            requests = [Utilities.requestDetails(requestName) for requestName in requestNames]
            OpsClipboard.inject(self.couchUrl, self.clipboardDB, *requests)
            for requestName in requestNames:
                ChangeState.changeRequestStatus(requestName, "ops-hold")
        return self.templatepage("Acknowledge", participle=participle, requests=requestNames)
示例#11
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(kwargs.get("MaxRSS", None),
                                          kwargs.get("MaxVSize", None),
                                          kwargs.get("SoftTimeout",None),
                                          kwargs.get("GracePeriod", None))        

        # 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", ""))
        # set Task properties if they are exist
        # TODO: need to define the task format (maybe kwargs["tasks"]?)
        helper.setTaskProperties(kwargs)
        
        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"],
                                       "ProcessingVersion": reqDetails["ProcessingVersion"],
                                       "CustodialSites": custodialList, 
                                       "NonCustodialSites": nonCustodialList, 
                                       "AutoApproveSubscriptionSites": autoApproveList,
                                       "SubscriptionPriority": subscriptionPriority,
                                       "CustodialSubType": custodialType,
                                       "NonCustodialSubType": nonCustodialType,
                                       "Teams": kwargs["Teams"],
                                       "OutputDatasets": outputDatasets, 
                                       "SiteWhitelist": whiteList,
                                       "SiteBlacklist": blackList},
                               useBody = True)
示例#12
0
文件: Assign.py 项目: mmascher/WMCore
    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": helper.getAcquisitionEra(),
            "ProcessingString": helper.getProcessingString(),
            "ProcessingVersion": helper.getProcessingVersion(),
        }
        for field, origValue in processedDatasetParts.iteritems():
            if field in kwargs and isinstance(kwargs[field], dict):
                for value in kwargs[field].values():
                    self.validate(value, field)
            else:
                self.validate(kwargs.get(field, origValue))

        # Set white list and black list
        whiteList = kwargs.get("SiteWhitelist", [])
        blackList = kwargs.get("SiteBlacklist", [])
        if not isinstance(whiteList, list):
            whiteList = [whiteList]
        if not isinstance(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 AcquisitionEra, ProcessingString and ProcessingVersion
        # which could be json encoded dicts
        if "AcquisitionEra" in kwargs:
            helper.setAcquisitionEra(kwargs["AcquisitionEra"])
        if "ProcessingString" in kwargs:
            helper.setProcessingString(kwargs["ProcessingString"])
        if "ProcessingVersion" in kwargs:
            helper.setProcessingVersion(kwargs["ProcessingVersion"])

        # Now verify the output datasets
        datatier = []
        outputDatasets = helper.listOutputDatasets()
        for dataset in outputDatasets:
            tokens = dataset.split("/")
            procds = tokens[2]
            datatier.append(tokens[3])
            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))

        # Verify whether the output datatiers are available in DBS
        self.validateDatatier(datatier, dbsUrl=helper.getDbsUrl())

        # 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(
            kwargs.get("MaxRSS", None),
            kwargs.get("MaxVSize", None),
            kwargs.get("SoftTimeout", None),
            kwargs.get("GracePeriod", None),
        )

        # Check whether we should check location for the data
        helper.setTrustLocationFlag(
            inputFlag=strToBool(kwargs.get("TrustSitelists", False)),
            pileupFlag=strToBool(kwargs.get("TrustPUSitelists", False)),
        )
        helper.setAllowOpportunistic(allowOpport=strToBool(kwargs.get("AllowOpportunistic", False)))

        # 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)
        if "CustodialGroup" in kwargs and not isinstance(kwargs["CustodialGroup"], basestring):
            raise cherrypy.HTTPError(400, "Invalid CustodialGroup format %s" % kwargs["CustodialGroup"])
        if "NonCustodialGroup" in kwargs and not isinstance(kwargs["NonCustodialGroup"], basestring):
            raise cherrypy.HTTPError(400, "Invalid NonCustodialGroup format %s" % kwargs["NonCustodialGroup"])
        if "DeleteFromSource" in kwargs and not isinstance(kwargs["DeleteFromSource"], bool):
            raise cherrypy.HTTPError(400, "Invalid DeleteFromSource format %s" % kwargs["DeleteFromSource"])

        helper.setSubscriptionInformationWildCards(
            wildcardDict=self.wildcardSites,
            custodialSites=custodialList,
            nonCustodialSites=nonCustodialList,
            autoApproveSites=autoApproveList,
            custodialSubType=custodialType,
            nonCustodialSubType=nonCustodialType,
            custodialGroup=kwargs.get("CustodialGroup", "DataOps"),
            nonCustodialGroup=kwargs.get("NonCustodialGroup", "DataOps"),
            priority=subscriptionPriority,
            deleteFromSource=kwargs.get("DeleteFromSource", False),
        )

        # 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.setMemoryAndCores(kwargs.get("Memory"), kwargs.get("Multicore"))
        helper.setDashboardActivity(kwargs.get("Dashboard", ""))
        helper.setTaskProperties(kwargs)

        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"],
                "ProcessingVersion": reqDetails["ProcessingVersion"],
                "CustodialSites": custodialList,
                "NonCustodialSites": nonCustodialList,
                "AutoApproveSubscriptionSites": autoApproveList,
                "SubscriptionPriority": subscriptionPriority,
                "CustodialSubType": custodialType,
                "NonCustodialSubType": nonCustodialType,
                "CustodialGroup": kwargs.get("CustodialGroup", "DataOps"),
                "NonCustodialGroup": kwargs.get("NonCustodialGroup", "DataOps"),
                "DeleteFromSource": kwargs.get("DeleteFromSource", False),
                "Teams": kwargs["Teams"],
                "OutputDatasets": outputDatasets,
                "SiteWhitelist": whiteList,
                "SiteBlacklist": blackList,
                "MergedLFNBase": kwargs["MergedLFNBase"],
                "UnmergedLFNBase": kwargs["UnmergedLFNBase"],
                "Dashboard": kwargs.get("Dashboard", ""),
                "TrustSitelists": kwargs.get("TrustSitelists", False),
                "TrustPUSitelists": kwargs.get("TrustPUSitelists", False),
                "AllowOpportunistic": kwargs.get("AllowOpportunistic", False),
            },
            useBody=True,
        )
示例#13
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
        datatier = []
        outputDatasets = helper.listOutputDatasets()
        for dataset in outputDatasets:
            tokens = dataset.split("/")
            procds = tokens[2]
            datatier.append(tokens[3])
            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))

        # Verify whether the output datatiers are available in DBS
        self.validateDatatier(datatier, dbsUrl=helper.getDbsUrl())

        #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(kwargs.get("MaxRSS", None),
                                          kwargs.get("MaxVSize", None),
                                          kwargs.get("SoftTimeout", None),
                                          kwargs.get("GracePeriod", None))

        # 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", ""))
        # set Task properties if they are exist
        # TODO: need to define the task format (maybe kwargs["tasks"]?)
        helper.setTaskProperties(kwargs)

        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"],
                                   "ProcessingVersion":
                                   reqDetails["ProcessingVersion"],
                                   "CustodialSites":
                                   custodialList,
                                   "NonCustodialSites":
                                   nonCustodialList,
                                   "AutoApproveSubscriptionSites":
                                   autoApproveList,
                                   "SubscriptionPriority":
                                   subscriptionPriority,
                                   "CustodialSubType":
                                   custodialType,
                                   "NonCustodialSubType":
                                   nonCustodialType,
                                   "Teams":
                                   kwargs["Teams"],
                                   "OutputDatasets":
                                   outputDatasets,
                                   "SiteWhitelist":
                                   whiteList,
                                   "SiteBlacklist":
                                   blackList
                               },
                               useBody=True)
示例#14
0
        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"]),
                                   "SiteWhitelist":
                                   JsonWrapper.JSONEncoder().encode(whiteList),
                                   "SiteBlacklist":
                                   JsonWrapper.JSONEncoder().encode(blackList)
示例#15
0
文件: Assign.py 项目: cinquo/WMCore
    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", [])
        helper.setSiteWildcardsLists(siteWhitelist=whiteList, siteBlacklist=blackList, wildcardDict=self.wildcardSites)
        # Set ProcessingVersion and AcquisitionEra, which could be json encoded dicts
        helper.setProcessingVersion(kwargs["ProcessingVersion"])
        helper.setAcquisitionEra(kwargs["AcquisitionEra"])
        helper.setProcessingString(kwargs.get("ProcessingString", None))
        # 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", 2411724)),
            int(kwargs.get("SoftTimeout", 129600)),
            int(kwargs.get("GracePeriod", 300)),
        )

        # Check whether we should check location for the data
        if "useSiteListAsLocation" in kwargs:
            helper.setLocationDataSourceFlag()

        # Set phedex subscription information
        custodialList = kwargs.get("CustodialSites", [])
        nonCustodialList = kwargs.get("NonCustodialSites", [])
        autoApproveList = kwargs.get("AutoApproveSubscriptionSites", [])
        subscriptionPriority = kwargs.get("SubscriptionPriority", "Low")
        if subscriptionPriority not in ["Low", "Normal", "High"]:
            raise cherrypy.HTTPError(400, "Invalid subscription priority")
        subscriptionType = kwargs.get("CustodialSubType", "Move")
        if subscriptionType not in ["Move", "Replica"]:
            raise cherrypy.HTTPError(400, "Invalid custodial subscription type")

        helper.setSubscriptionInformationWildCards(
            wildcardDict=self.wildcardSites,
            custodialSites=custodialList,
            nonCustodialSites=nonCustodialList,
            autoApproveSites=autoApproveList,
            custodialSubType=subscriptionType,
            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"]}
        )
示例#16
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)

        try:
            helper.validateArgumentForAssignment(kwargs)
        except WMSpecFactoryException as ex:
            raise cherrypy.HTTPError(400, str(ex.message()))
        except Exception:
            msg = traceback.format_exc()
            raise cherrypy.HTTPError(400, "Unhandled error: %s" % msg)

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

        # Set white list and black list
        whiteList = kwargs.get("SiteWhitelist", [])
        blackList = kwargs.get("SiteBlacklist", [])
        if not isinstance(whiteList, list):
            whiteList = [whiteList]
        if not isinstance(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))

        helper.setAcquisitionEra(kwargs.get("AcquisitionEra", None))
        helper.setProcessingString(kwargs.get("ProcessingString", None))
        helper.setProcessingVersion(kwargs.get("ProcessingVersion", None))

        # Now verify the output datasets
        datatier = []
        outputDatasets = helper.listOutputDatasets()
        for dataset in outputDatasets:
            tokens = dataset.split("/")
            procds = tokens[2]
            datatier.append(tokens[3])
            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))
        # Verify whether the output datatiers are available in DBS
        self.validateDatatier(datatier, dbsUrl=helper.getDbsUrl())

        # 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(kwargs.get("MaxRSS", None),
                                          kwargs.get("MaxVSize", None),
                                          kwargs.get("SoftTimeout", None),
                                          kwargs.get("GracePeriod", None))

        # Check whether we should check location for the data
        helper.setTrustLocationFlag(inputFlag=strToBool(kwargs.get("TrustSitelists", False)),
                                    pileupFlag=strToBool(kwargs.get("TrustPUSitelists", False)))
        helper.setAllowOpportunistic(allowOpport=strToBool(kwargs.get("AllowOpportunistic", False)))

        # Set phedex subscription information
        custodialList = kwargs.get("CustodialSites", [])
        nonCustodialList = kwargs.get("NonCustodialSites", [])
        autoApproveList = kwargs.get("AutoApproveSubscriptionSites", [])
        subscriptionPriority = kwargs.get("SubscriptionPriority", "Low")
        custodialType = kwargs.get("CustodialSubType", "Replica")
        nonCustodialType = kwargs.get("NonCustodialSubType", "Replica")

        helper.setSubscriptionInformationWildCards(wildcardDict=self.wildcardSites,
                                                   custodialSites=custodialList,
                                                   nonCustodialSites=nonCustodialList,
                                                   autoApproveSites=autoApproveList,
                                                   custodialSubType=custodialType,
                                                   nonCustodialSubType=nonCustodialType,
                                                   custodialGroup=kwargs.get("CustodialGroup", "DataOps"),
                                                   nonCustodialGroup=kwargs.get("NonCustodialGroup", "DataOps"),
                                                   priority=subscriptionPriority,
                                                   deleteFromSource=kwargs.get("DeleteFromSource", False))

        # 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.setMemory(kwargs.get("Memory"))
        helper.setCores(kwargs.get("Multicore"))
        helper.setDashboardActivity(kwargs.get("Dashboard", ""))
        helper.setTaskProperties(kwargs)

        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"],
                                       "ProcessingVersion": reqDetails["ProcessingVersion"],
                                       "CustodialSites": custodialList,
                                       "NonCustodialSites": nonCustodialList,
                                       "AutoApproveSubscriptionSites": autoApproveList,
                                       "SubscriptionPriority": subscriptionPriority,
                                       "CustodialSubType": custodialType,
                                       "NonCustodialSubType": nonCustodialType,
                                       "CustodialGroup": kwargs.get("CustodialGroup", "DataOps"),
                                       "NonCustodialGroup": kwargs.get("NonCustodialGroup", "DataOps"),
                                       "DeleteFromSource": kwargs.get("DeleteFromSource", False),
                                       "Teams": kwargs["Teams"],
                                       "OutputDatasets": outputDatasets,
                                       "SiteWhitelist": whiteList,
                                       "SiteBlacklist": blackList,
                                       "MergedLFNBase": kwargs["MergedLFNBase"],
                                       "UnmergedLFNBase": kwargs["UnmergedLFNBase"],
                                       "Dashboard": kwargs.get("Dashboard", ""),
                                       "TrustSitelists": kwargs.get("TrustSitelists", False),
                                       "TrustPUSitelists": kwargs.get("TrustPUSitelists", False),
                                       "AllowOpportunistic": kwargs.get("AllowOpportunistic", False)},
                               useBody=True)
示例#17
0
        subscriptionType = kwargs.get("CustodialSubType", "Move")
        if subscriptionType not in ["Move", "Replica"]:
            raise cherrypy.HTTPError(400, "Invalid custodial subscription type %s" % subscriptionType)

        helper.setSubscriptionInformationWildCards(wildcardDict = self.wildcardSites,
                                                   custodialSites = custodialList,
                                                   nonCustodialSites = nonCustodialList,
                                                   autoApproveSites = autoApproveList,
                                                   custodialSubType = subscriptionType,
                                                   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"]})