Beispiel #1
0
def assignRequest(requestName, teamName, prodMgr=None, wmstatUrl=None):
    """
    _assignRequest_

    Assign a request to a team.

    This does the following:

    - Changes the status to assigned
    - Creates an association to the team provided
    - Optionally associates the request to a prod mgr instance

    """

    factory = DBConnect.getConnection()
    reqId = requestID(requestName)

    teamId = factory(classname="Team.ID").execute(teamName)
    if teamId == None:
        msg = "Team named %s not known in database" % teamName
        msg += "Failed to assign request %s to team %s" % (requestName, teamName)
        raise RuntimeError(msg)

    if wmstatUrl:
        wmstatSvc = WMStatsWriter(wmstatUrl)
        wmstatSvc.updateTeam(requestName, teamName)

    assigner = factory(classname="Assignment.New")
    assigner.execute(reqId, teamId)

    changeRequestStatus(requestName, "assigned", priority=None, wmstatUrl=wmstatUrl)

    if prodMgr != None:
        addPM = factory(classname="Progress.ProdMgr")
        addPM.execute(reqId, prodMgr)
Beispiel #2
0
def deleteRequest(requestName):
    """
    _deleteRequest_

    delete the request from the database by its RequestName
    """
    reqId = requestID(requestName)

    factory = DBConnect.getConnection()
    deleteReq = factory(classname="Request.Delete")
    deleteReq.execute(reqId)
Beispiel #3
0
def updateRequest(requestName, paramDict):
    """
    _updateRequest_
    Add a progress update to teh request Id provided, params can
    optionally contain:

    - *events_written* Int
    - *events_merged*  Int
    - *files_written*  Int
    - *files_merged*   int
    - *percent_success* float
    - *percent_completed* float
    - *dataset*        string (dataset name)
    """

    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    factory(classname="Progress.Update").execute(reqId, **paramDict)
Beispiel #4
0
def updateRequest(requestName, paramDict):
    """
    _updateRequest_
    Add a progress update to teh request Id provided, params can
    optionally contain:

    - *events_written* Int
    - *events_merged*  Int
    - *files_written*  Int
    - *files_merged*   int
    - *percent_success* float
    - *percent_completed* float
    - *dataset*        string (dataset name)
    """

    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    factory(classname="Progress.Update").execute(reqId, **paramDict)
Beispiel #5
0
def changeRequestStatus(requestName, newState, priority=None, wmstatUrl=None):
    """
    _changeRequestStatus_

    Basic API to change a request to a new state, also
    includes optional priority change for the request

    - *requestName* : name of the request to be modified
    - *newState*    : name of the new status for the request
    - *priority* : optional integer priority

    Apparently when changing request state (on assignment page),
    it's possible to change priority at one go. Hence the argument is here.

    """
    # MySQL/Oracle
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    changeRequestIDStatus(reqId, newState, priority)

    # CouchDB
    # have to first get information where the request Couch document is,
    # extracting the information from reqmgr_request.workflow table field
    reqData = factory(classname="Request.Get").execute(reqId)
    # this would be something like this:
    # http://localhost:5984/reqmgr_workload_cache/maxa_RequestString-OVERRIDE-ME_130306_205649_8066/spec
    wfUrl = reqData['workflow']
    # cut off /maxa_RequestString-OVERRIDE-ME_130306_205649_8066/spec
    couchUrl = wfUrl.replace('/' + requestName + "/spec", '')
    couchDbName = couchUrl[couchUrl.rfind('/') + 1:]
    # cut off database name from the URL
    url = couchUrl.replace('/' + couchDbName, '')
    couchDb = Database(couchDbName, url)
    fields = {"RequestStatus": newState}
    couchDb.updateDocument(requestName,
                           "ReqMgr",
                           "updaterequest",
                           fields=fields,
                           useBody=True)

    # TODO: should we make this mandatory?
    if wmstatUrl:
        wmstatSvc = WMStatsWriter(wmstatUrl)
        wmstatSvc.updateRequestStatus(requestName, newState)
Beispiel #6
0
def changeRequestStatus(requestName, newState, priority=None, wmstatUrl=None):
    """
    _changeRequestStatus_

    Basic API to change a request to a new state, also
    includes optional priority change for the request

    - *requestName* : name of the request to be modified
    - *newState*    : name of the new status for the request
    - *priority* : optional integer priority

    Apparently when changing request state (on assignment page),
    it's possible to change priority at one go. Hence the argument is here.

    """
    # MySQL/Oracle
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    changeRequestIDStatus(reqId, newState, priority)

    # CouchDB
    # have to first get information where the request Couch document is,
    # extracting the information from reqmgr_request.workflow table field
    reqData = factory(classname="Request.Get").execute(reqId)
    # this would be something like this:
    # http://localhost:5984/reqmgr_workload_cache/maxa_RequestString-OVERRIDE-ME_130306_205649_8066/spec
    wfUrl = reqData["workflow"]
    # cut off /maxa_RequestString-OVERRIDE-ME_130306_205649_8066/spec
    couchUrl = wfUrl.replace("/" + requestName + "/spec", "")
    couchDbName = couchUrl[couchUrl.rfind("/") + 1 :]
    # cut off database name from the URL
    url = couchUrl.replace("/" + couchDbName, "")
    couchDb = Database(couchDbName, url)
    fields = {"RequestStatus": newState}
    couchDb.updateDocument(requestName, "ReqMgr", "updaterequest", fields=fields, useBody=True)

    # TODO: should we make this mandatory?
    if wmstatUrl:
        wmstatSvc = WMStatsWriter(wmstatUrl)
        wmstatSvc.updateRequestStatus(requestName, newState)
Beispiel #7
0
def assignRequest(requestName, teamName, prodMgr=None, wmstatUrl=None):
    """
    _assignRequest_

    Assign a request to a team.

    This does the following:

    - Changes the status to assigned
    - Creates an association to the team provided
    - Optionally associates the request to a prod mgr instance

    """

    factory = DBConnect.getConnection()
    reqId = requestID(requestName)

    teamId = factory(classname="Team.ID").execute(teamName)
    if teamId == None:
        msg = "Team named %s not known in database" % teamName
        msg += "Failed to assign request %s to team %s" % (requestName,
                                                           teamName)
        raise RuntimeError(msg)

    if wmstatUrl:
        wmstatSvc = WMStatsWriter(wmstatUrl)
        wmstatSvc.updateTeam(requestName, teamName)

    assigner = factory(classname="Assignment.New")
    assigner.execute(reqId, teamId)

    changeRequestStatus(requestName,
                        'assigned',
                        priority=None,
                        wmstatUrl=wmstatUrl)

    if prodMgr != None:
        addPM = factory(classname="Progress.ProdMgr")
        addPM.execute(reqId, prodMgr)
Beispiel #8
0
def changeRequestPriority(requestName, priority):
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    priorityChange = factory(classname="Request.Priority")
    priorityChange.execute(reqId, priority)
Beispiel #9
0
def deleteAssignment(requestName):
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    factory(classname="Assignment.Delete").execute(reqId)
Beispiel #10
0
def changeRequestPriority(requestName, priority):
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    priorityChange = factory(classname="Request.Priority")
    priorityChange.execute(reqId, priority)
Beispiel #11
0
def deleteAssignment(requestName):
    factory = DBConnect.getConnection()
    reqId = requestID(requestName)
    factory(classname="Assignment.Delete").execute(reqId)