本文整理汇总了Python中WMCore.RequestManager.RequestDB.Interface.Request.ChangeState类的典型用法代码示例。如果您正苦于以下问题:Python ChangeState类的具体用法?Python ChangeState怎么用?Python ChangeState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChangeState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: changeStatus
def changeStatus(requestName, status, wmstatUrl, acdcUrl):
""" Changes the status for this request """
request = GetRequest.getRequestByName(requestName)
if not status in RequestStatus.StatusList:
raise RuntimeError, "Bad status code " + status
if not request.has_key('RequestStatus'):
raise RuntimeError, "Cannot find status for request " + requestName
oldStatus = request['RequestStatus']
if not status in RequestStatus.NextStatus[oldStatus]:
raise RuntimeError, "Cannot change status from %s to %s. Allowed values are %s" % (
oldStatus, status, RequestStatus.NextStatus[oldStatus])
if status == 'aborted':
# delete from the workqueue
if not privileged() and not ownsRequest(request):
raise cherrypy.HTTPError(403, "You are not allowed to abort this request")
elif not privileged():
raise cherrypy.HTTPError(403, "You are not allowed to change the state for this request")
# delete from the workqueue if it's been assigned to one
if oldStatus in ["acquired", "running", "running-closed", "running-open"]:
abortRequest(requestName)
else:
raise cherrypy.HTTPError(400, "You cannot abort a request in state %s" % oldStatus)
if status == 'announced':
# cleanup acdc database, if possible
if acdcUrl:
url, database = WMCore.Lexicon.splitCouchServiceURL(acdcUrl)
acdcService = CouchService(url = url, database = database)
acdcService.removeFilesetsByCollectionName(requestName)
# finally, perform the transition, have to do it in both Oracle and CouchDB
# and in WMStats
ChangeState.changeRequestStatus(requestName, status, wmstatUrl=wmstatUrl)
示例2: changeStatus
def changeStatus(requestName, status, wmstatUrl, acdcUrl):
""" Changes the status for this request """
request = GetRequest.getRequestByName(requestName)
if not status in RequestStatus.StatusList:
raise RuntimeError("Bad status code " + status)
if 'RequestStatus' not in request:
raise RuntimeError("Cannot find status for request " + requestName)
oldStatus = request['RequestStatus']
if not status in RequestStatus.NextStatus[oldStatus]:
raise RuntimeError("Cannot change status from %s to %s. Allowed values are %s" % (
oldStatus, status, RequestStatus.NextStatus[oldStatus]))
if status == 'aborted' or status == 'force-complete':
# delete from the workqueue
if not privileged() and not ownsRequest(request):
raise cherrypy.HTTPError(403, "You are not allowed to %s this request" % status)
elif not privileged():
raise cherrypy.HTTPError(403, "You are not allowed to change the state for this request")
# delete from the workqueue if it's been assigned to one
if status in RequestStatus.NextStatus[oldStatus]:
abortRequest(requestName)
else:
raise cherrypy.HTTPError(400, "You cannot abort a request in state %s" % oldStatus)
# ACDC database is cleaned by separate thread
# if status == 'announced':
# # cleanup acdc database, if possible
# if acdcUrl:
# url, database = WMCore.Lexicon.splitCouchServiceURL(acdcUrl)
# acdcService = CouchService(url = url, database = database)
# acdcService.removeFilesetsByCollectionName(requestName)
# finally, perform the transition, have to do it in both Oracle and CouchDB
# and in WMStats
ChangeState.changeRequestStatus(requestName, status, wmstatUrl=wmstatUrl)
示例3: changePriority
def changePriority(requestName, priority, wmstatUrl = None):
"""
Changes the priority that's stored in the workload.
Takes the current priority stored in the workload and adds
to it the input priority value.
"""
request = requestDetails(requestName)
# change in Oracle
newPrior = int(priority)
ChangeState.changeRequestPriority(requestName, newPrior)
# change in workload (spec)
helper = loadWorkload(request)
helper.data.request.priority = newPrior
saveWorkload(helper, request['RequestWorkflow'], wmstatUrl)
# change priority in CouchDB
couchDb = Database(request["CouchWorkloadDBName"], request["CouchURL"])
fields = {"RequestPriority": newPrior}
couchDb.updateDocument(requestName, "ReqMgr", "updaterequest", fields=fields)
# push the change to the WorkQueue
response = ProdManagement.getProdMgr(requestName)
if response == [] or response[0] is None or response[0] == "":
# Request must not be assigned yet, we are safe here
return
workqueue = WorkQueue.WorkQueue(response[0])
workqueue.updatePriority(requestName, priority)
return
示例4: changeStatus
def changeStatus(requestName, status, wmstatUrl):
""" Changes the status for this request """
request = GetRequest.getRequestByName(requestName)
if not status in RequestStatus.StatusList:
raise RuntimeError, "Bad status code " + status
if not request.has_key('RequestStatus'):
raise RuntimeError, "Cannot find status for request " + requestName
oldStatus = request['RequestStatus']
if not status in RequestStatus.NextStatus[oldStatus]:
raise RuntimeError, "Cannot change status from %s to %s. Allowed values are %s" % (
oldStatus, status, RequestStatus.NextStatus[oldStatus])
if status == 'aborted':
# delete from the workqueue
if not privileged() and not ownsRequest(request):
raise cherrypy.HTTPError(403, "You are not allowed to abort this request")
elif not privileged():
raise cherrypy.HTTPError(403, "You are not allowed to change the state for this request")
# delete from the workqueue if it's been assigned to one
if oldStatus in ["acquired", "running"]:
abortRequest(requestName)
else:
raise cherrypy.HTTPError(400, "You cannot abort a request in state %s" % oldStatus)
#FIXME needs logic about who is allowed to do which transition
ChangeState.changeRequestStatus(requestName, status, wmstatUrl = wmstatUrl)
return
示例5: getRequestDetails
def getRequestDetails(requestName):
""" Return a dict with the intimate details of the request """
requestId = requestID(requestName)
request = getRequest(requestId)
request['Assignments'] = getAssignmentsByName(requestName)
request['RequestMessages'] = ChangeState.getMessages(requestName)
request['RequestUpdates'] = ChangeState.getProgress(requestName)
return request
示例6: handleCloseOut
def handleCloseOut(self, **kwargs):
""" Handler for closing out requests """
requests = BulkOperations.requestNamesFromCheckboxes(self, kwargs)
for requestName in requests:
WMCore.Lexicon.identifier(requestName)
ChangeState.changeRequestStatus(requestName, 'closed-out', wmstatUrl = self.wmstatWriteURL)
return self.templatepage("Acknowledge", participle="closed out",
requests=requests)
示例7: changePriority
def changePriority(requestName, priority):
""" Changes the priority that's stored in the workload """
# fill in all details
request = GetRequest.getRequestByName(requestName)
ChangeState.changeRequestPriority(requestName, priority)
helper = loadWorkload(request)
helper.data.request.priority = int(priority)
saveWorkload(helper, request['RequestWorkflow'])
示例8: changePriority
def changePriority(requestName, priority, wmstatUrl = None):
""" Changes the priority that's stored in the workload """
# fill in all details
request = GetRequest.getRequestByName(requestName)
groupPriority = request.get('ReqMgrGroupBasePriority', 0)
userPriority = request.get('ReqMgrRequestorBasePriority', 0)
ChangeState.changeRequestPriority(requestName, priority)
helper = loadWorkload(request)
totalPriority = int(priority) + int(userPriority) + int(groupPriority)
helper.data.request.priority = totalPriority
saveWorkload(helper, request['RequestWorkflow'], wmstatUrl)
示例9: changeStatus
def changeStatus(requestName, status):
""" Changes the status for this request """
request = GetRequest.getRequestByName(requestName)
oldStatus = request['RequestStatus']
if not status in RequestStatus.StatusList:
raise RuntimeError, "Bad status code " + status
if not request.has_key('RequestStatus'):
raise RuntimeError, "Cannot find status for request " + requestName
if not status in RequestStatus.NextStatus[oldStatus]:
raise RuntimeError, "Cannot change status from %s to %s. Allowed values are %s" % (
oldStatus, status, RequestStatus.NextStatus[oldStatus])
ChangeState.changeRequestStatus(requestName, status)
if status == 'aborted':
# delete from the workqueue
abortRequest(requestName)
示例10: getRequest
def getRequest(requestId, reverseTypes=None, reverseStatus=None):
"""
_getRequest_
retrieve a request based on the request id,
return a ReqMgr.DataStructs.Request instance containing
the information
"""
factory = DBConnect.getConnection()
reqGet = factory(classname = "Request.Get")
reqData = reqGet.execute(requestId)
requestName = reqData['request_name']
if not reverseTypes or not reverseStatus:
reverseTypes, reverseStatus = reverseLookups()
getGroup = factory(classname = "Group.GetGroupFromAssoc")
groupData = getGroup.execute(reqData['requestor_group_id'])
getUser = factory(classname = "Requestor.GetUserFromAssoc")
userData = getUser.execute(reqData['requestor_group_id'])
request = Request()
request["ReqMgrRequestID"] = reqData['request_id']
request["RequestName"] = requestName
request["RequestType"] = reverseTypes[reqData['request_type']]
request["RequestStatus"] = reverseStatus[reqData['request_status']]
request["RequestPriority"] = reqData['request_priority']
request["ReqMgrRequestBasePriority"] = reqData['request_priority']
request["RequestWorkflow"] = reqData['workflow']
request["RequestSizeEvents"] = reqData['request_size_events']
request["RequestSizeFiles"] = reqData['request_size_files']
request["Group"] = groupData['group_name']
request["ReqMgrGroupID"] = groupData['group_id']
request["ReqMgrGroupBasePriority"] = \
groupData['group_base_priority']
request["Requestor"] = userData['requestor_hn_name']
request["ReqMgrRequestorID"] = userData['requestor_id']
request["ReqMgrRequestorBasePriority"] = \
userData['requestor_base_priority']
request["RequestPriority"] = \
request['RequestPriority'] + groupData['group_base_priority']
request["RequestPriority"] = \
request['RequestPriority'] + userData['requestor_base_priority']
updates = ChangeState.getProgress(requestName)
request['percent_complete'], request['percent_success'] = percentages(updates)
sqDeps = factory(classname = "Software.GetByAssoc")
swVers = sqDeps.execute(requestId)
request['SoftwareVersions'] = swVers.values()
getDatasetsIn = factory(classname = "Datasets.GetInput")
getDatasetsOut = factory(classname = "Datasets.GetOutput")
datasetsIn = getDatasetsIn.execute(requestId)
datasetsOut = getDatasetsOut.execute(requestId)
request['InputDatasetTypes'] = datasetsIn
request['InputDatasets'] = datasetsIn.keys()
request['OutputDatasets'] = datasetsOut
return request
示例11: handleApprove
def handleApprove(self, **kwargs):
""" Handler for approving requests """
requests = self.requestNamesFromCheckboxes(kwargs)
particple = ''
for requestName in requests:
if kwargs['action'] == 'Reject':
participle = 'rejected'
ChangeState.changeRequestStatus(requestName, 'rejected', wmstatUrl = self.wmstatWriteURL)
else:
participle = 'approved'
ChangeState.changeRequestStatus(requestName, 'assignment-approved', wmstatUrl = self.wmstatWriteURL)
priority = kwargs.get(requestName+':priority', '')
if priority != '':
Utilities.changePriority(requestName, priority, self.wmstatWriteURL)
return self.templatepage("Acknowledge", participle=participle,
requests=requests)
示例12: putAssignment
def putAssignment(self, team, requestName):
""" Assigns this request to this team """
# see if it's already assigned
team = urllib.unquote(team)
if not team in ProdManagement.listTeams():
raise cherrypy.HTTPError(404,"Cannot find this team")
requestNamesAndIDs = ListRequests.listRequestsByTeam(team)
if requestName in requestNamesAndIDs.keys():
raise cherrypy.HTTPError(400,"Already assigned to this team")
return ChangeState.assignRequest(requestName, team)
示例13: handleAssignmentPage
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 Exception:
# Probably wasn't JSON
decodedArgs[key] = kwargs[key]
kwargs = decodedArgs
# handle the checkboxes
teams = []
requestNames = []
for key, value in kwargs.iteritems():
if isinstance(value, basestring):
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")
kwargs["Teams"] = 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"
return self.templatepage("Acknowledge", participle=participle, requests=requestNames)
示例14: postRequest
def postRequest(self, requestName, **kwargs):
"""
Add a progress update to the request Id provided, params can
optionally contain:
- *events_written* Int
- *events_merged* Int
- *files_written* Int
- *files_merged* int
- *percent_success* float
- *percent_complete float
- *dataset* string (dataset name)
"""
return ChangeState.updateRequest(requestName, kwargs)
示例15: handleAnnounce
def handleAnnounce(self, **kwargs):
""" Handler for announcing requests """
requests = self.requestNamesFromCheckboxes(kwargs)
datasets = []
goodDatasets = []
badDatasets = []
for requestName in requests:
WMCore.Lexicon.identifier(requestName)
ChangeState.changeRequestStatus(requestName, 'announced', wmstatUrl = self.wmstatWriteURL)
datasets.extend(Utilities.getOutputForRequest(requestName))
for dataset in datasets:
try:
toks = dataset.split('/')
data = {'primary_ds_name': toks[0], 'processed_ds_name': toks[1],
'data_tier_name': toks[2], 'is_dataset_valid': 1}
dbsSender.post('/DBSWriter/datasets', data=data)
goodDatasets.append(dataset)
except:
logging.warning("Could not update dataset into DBS:" +dataset)
badDatasets.append(dataset)
return self.templatepage("Announce", requests=requests,
goodDatasets=goodDatasets,
badDatasets=badDatasets)