def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(safe.kwargs["outfilelumis"]):
                raise InvalidParameter("The number of runs and the number of lumis lists are different")
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_num("pandajobid", param, safe, optional=False)
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname", param, safe, RX_PUBLISH, optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumcksum", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumadler32", param, safe, RX_CHECKSUM, optional=False)
            validate_str("outlocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("outtmplocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("acquisitionera", param, safe, RX_WORKFLOW, optional=False)#TODO Do we really need this?
            validate_str("outdatasetname", param, safe, RX_OUTDSLFN, optional=False)#TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_num("events", param, safe, optional=False)
        elif method in ['POST']:
            raise NotImplementedError
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
        elif method in ['DELETE']:
            raise NotImplementedError
Exemplo n.º 2
0
 def validate(self, apiobj, method, api, param, safe):
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     authz_login_valid()
     if method in ['POST']:
         validate_str('subresource',
                      param,
                      safe,
                      RX_SUBRES_TASK,
                      optional=False)
         validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
         validate_str("warning", param, safe, RX_TEXT_FAIL, optional=True)
         validate_str("webdirurl", param, safe, RX_URL, optional=True)
         validate_str("scheddname",
                      param,
                      safe,
                      RX_SCHEDD_NAME,
                      optional=True)
         validate_strlist("outputdatasets", param, safe, RX_OUT_DATASET)
     elif method in ['GET']:
         validate_str('subresource',
                      param,
                      safe,
                      RX_SUBRES_TASK,
                      optional=False)
         validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
         validate_str('taskstatus', param, safe, RX_STATUS, optional=True)
         validate_str('username', param, safe, RX_USERNAME, optional=True)
         validate_str('minutes', param, safe, RX_RUNS, optional=True)
Exemplo n.º 3
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()  # TODO: should we also call authz_operator here ? Otherwise anybody can get tasks from here.
        #      Actually, maybe something even more strict is necessary (only the prod TW machine can access this resource)

        if method in ["POST"]:
            validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("command", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_numlist("resubmittedjobs", param, safe)
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("subresource", param, safe, RX_SUBPOSTWORKER, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_num("clusterid", param, safe, optional=True)  # clusterid of the dag
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ["GET"]:
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource", param, safe, RX_SUBGETWORKER, optional=True)
Exemplo n.º 4
0
 def validate(self, apiobj, method, api, param, safe): #pylint: disable=unused-argument
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     # TODO, use authz_user_action() which will allow only user to maintain and modify its own
     # documents
     authz_login_valid()
     if method in ['PUT']:
         # Do we want to validate everything?
         # Now what is put in CouchDB is not validated
         # And all put are prepared by us in JOB wrappers, so it should already be correct.
         # P.S. Validation is done in function and it double check if all required keys are available
         print (param, safe)
         validate_str("id", param, safe, RX_ANYTHING, optional=False)
         validate_str("username", param, safe, RX_ANYTHING, optional=False)
         validate_str("taskname", param, safe, RX_ANYTHING, optional=False)
         validate_str("destination", param, safe, RX_ANYTHING, optional=False)
         validate_str("destination_lfn", param, safe, RX_ANYTHING, optional=False)
         validate_str("source", param, safe, RX_ANYTHING, optional=False)
         validate_str("source_lfn", param, safe, RX_ANYTHING, optional=False)
         validate_num("filesize", param, safe, optional=False)
         validate_num("publish", param, safe, optional=False)
         validate_str("job_id", param, safe, RX_JOBID, optional=False)
         validate_num("job_retry_count", param, safe, optional=False)
         validate_str("type", param, safe, RX_ANYTHING, optional=False)
         validate_str("asoworker", param, safe, RX_ANYTHING, optional=True)
         validate_num("transfer_retry_count", param, safe, optional=True)
         validate_num("transfer_max_retry_count", param, safe, optional=True)
         validate_num("publication_retry_count", param, safe, optional=True)
         validate_num("publication_max_retry_count", param, safe, optional=True)
         validate_num("start_time", param, safe, optional=False)
         validate_str("rest_host", param, safe, RX_ANYTHING, optional=False)
         validate_str("rest_uri", param, safe, RX_ANYTHING, optional=False)
         validate_str("transfer_state", param, safe, RX_ANYTHING, optional=False)
         validate_str("publication_state", param, safe, RX_ANYTHING, optional=False)
         validate_str("fts_id", param, safe, RX_ANYTHING, optional=True)
         validate_str("fts_instance", param, safe, RX_ANYTHING, optional=True)
     if method in ['POST']:
         # POST is for update, so we should allow anyone anything?
         # Of Course no, but there are multiple combinations, so we are not validating here
         # and all validation is in post function
         validate_str("subresource", param, safe, RX_SUBPOSTUSERTRANSFER, optional=False)
         validate_str("id", param, safe, RX_ANYTHING, optional=True)
         validate_str("username", param, safe, RX_USERNAME, optional=True)
         validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
         validate_num("start_time", param, safe, optional=True)
         validate_str("source", param, safe, RX_ANYTHING, optional=True)
         validate_str("source_lfn", param, safe, RX_ANYTHING, optional=True)
         validate_num("filesize", param, safe, optional=True)
         validate_str("transfer_state", param, safe, RX_ANYTHING, optional=True)
         validate_num("transfer_retry_count", param, safe, optional=True)
         validate_str("publication_state", param, safe, RX_ANYTHING, optional=True)
         validate_str("job_id", param, safe, RX_JOBID, optional=True)
         validate_num("job_retry_count", param, safe, optional=True)
         validate_strlist("listOfIds", param, safe, RX_ANYTHING)  # Interesting... TODO. Have optional in strlist
     elif method in ['GET']:
         validate_str("subresource", param, safe, RX_SUBGETUSERTRANSFER, optional=False)
         validate_str("id", param, safe, RX_TASKNAME, optional=True)
         validate_str("username", param, safe, RX_USERNAME, optional=True)
         validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
     elif method in ['DELETE']:
         raise UnsupportedMethod('This method is not supported in this API!')
Exemplo n.º 5
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)
            validate_strlist("workflow", param, safe, RX_TASKNAME)

        elif method in ['POST']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)

        elif method in ['GET']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=True)
            validate_num('age', param, safe, optional=True)
            validate_str('subresource',
                         param,
                         safe,
                         RX_SUBRESTAT,
                         optional=True)
            validate_num('limit', param, safe, optional=True)
            if not safe.kwargs['campaign'] and not safe.kwargs['age']:
                raise InvalidParameter("Invalid input parameters")
            if not safe.kwargs['campaign'] and safe.kwargs['subresource']:
                raise InvalidParameter("Invalid input parameters")

        elif method in ['DELETE']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)
            validate_num("force", param, safe, optional=True)
Exemplo n.º 6
0
 def validate(self, apiobj, method, api, param, safe):
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     authz_login_valid()
     if method in ['GET']:
         validate_str('subresource',
                      param,
                      safe,
                      RX_SUBRES_SI,
                      optional=False)
Exemplo n.º 7
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(safe.kwargs["outfilelumis"]):
                raise InvalidParameter("The number of runs and the number of lumis lists are different")
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_str("jobid", param, safe, RX_JOBID, optional=True)
            #TODO: for backward compatibility. Get rid of the pandajobid once all jobs using it are done (one month after this gets released)
            #(The following five lines can be deleted)
            validate_num("pandajobid", param, safe, optional=True)
            if bool(safe.kwargs["jobid"]) == bool(safe.kwargs["pandajobid"]):
                raise InvalidParameter("Only one among jobid and pandajobid should be set")
            #Oracle/cx_oracle/python stack does not like None for numbers, even if they are nullable
            if safe.kwargs["pandajobid"] == None:
                safe.kwargs["pandajobid"] =  0
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname", param, safe, RX_PUBLISH, optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumcksum", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumadler32", param, safe, RX_CHECKSUM, optional=False)
            validate_str("outlocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("outtmplocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("acquisitionera", param, safe, RX_TASKNAME, optional=False)#TODO Do we really need this?
            validate_str("outdatasetname", param, safe, RX_OUTDSLFN, optional=False)#TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_PARENTLFN, optional=False)
            validate_str("outtmplfn", param, safe, RX_PARENTLFN, optional=True)
            validate_num("events", param, safe, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=True)
            validate_num("directstageout", param, safe, optional=True)
            safe.kwargs["directstageout"] = 'T' if safe.kwargs["directstageout"] else 'F' #'F' if not provided
        elif method in ['POST']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=False)
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
            validate_num("howmany", param, safe, optional=True)
        elif method in ['DELETE']:
            authz_operator()
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("hours", param, safe, RX_HOURS, optional=True)
            if bool(safe.kwargs["taskname"]) == bool(safe.kwargs["hours"]):
               raise InvalidParameter("You have to specify a taskname or a number of hours. Files of this task or created before the number of hours"+\
                                        " will be deleted. Only one of the two parameters can be specified.")
Exemplo n.º 8
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['POST']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=True)
        elif method in ['GET']:
            validate_str('subresource', param, safe, RX_SUBRES_TASK, optional=False)
            validate_str('taskstatus', param, safe, RX_STATUS, optional=True)
            validate_str('username', param, safe, RX_USERNAME, optional=True)
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=True)
Exemplo n.º 9
0
 def validate(self, apiobj, method, api, param, safe):
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     authz_login_valid()
     if method in ['POST']:
         validate_str('subresource', param, safe, RX_SUBRES_TASK, optional=False)
         validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
         validate_str("warning", param, safe, RX_TEXT_FAIL, optional=True)
         validate_str("webdirurl", param, safe, RX_URL, optional=True)
         validate_str("scheddname", param, safe, RX_SCHEDD_NAME, optional=True)
         validate_strlist("outputdatasets", param, safe, RX_OUT_DATASET)
     elif method in ['GET']:
         validate_str('subresource', param, safe, RX_SUBRES_TASK, optional=False)
         validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
         validate_str('taskstatus', param, safe, RX_STATUS, optional=True)
         validate_str('username', param, safe, RX_USERNAME, optional=True)
         validate_str('minutes', param, safe, RX_RUNS, optional=True)
Exemplo n.º 10
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(safe.kwargs["outfilelumis"]):
                raise InvalidParameter("The number of runs and the number of lumis lists are different")
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_num("pandajobid", param, safe, optional=False)
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname", param, safe, RX_PUBLISH, optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumcksum", param, safe, RX_CHECKSUM, optional=False)
            validate_str("checksumadler32", param, safe, RX_CHECKSUM, optional=False)
            validate_str("outlocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("outtmplocation", param, safe, RX_CMSSITE, optional=False)
            validate_str("acquisitionera", param, safe, RX_WORKFLOW, optional=False)#TODO Do we really need this?
            validate_str("outdatasetname", param, safe, RX_OUTDSLFN, optional=False)#TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_PARENTLFN, optional=False)
            validate_str("outtmplfn", param, safe, RX_PARENTLFN, optional=True)
            validate_num("events", param, safe, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=True)
            validate_num("directstageout", param, safe, optional=True)
            safe.kwargs["directstageout"] = 'T' if safe.kwargs["directstageout"] else 'F' #'F' if not provided
        elif method in ['POST']:
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=False)
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
        elif method in ['DELETE']:
            authz_operator()
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=True)
            validate_str("hours", param, safe, RX_HOURS, optional=True)
            if bool(safe.kwargs["taskname"]) == bool(safe.kwargs["hours"]):
               raise InvalidParameter("You have to specify a taskname or a number of hours. Files of this task or created before the number of hours"+\
                                        " will be deleted. Only one of the two parameters can be specified.")
Exemplo n.º 11
0
    def validate(apiobj, method, api, param, safe):  #pylint: disable=unused-argument
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid(
        )  #TODO: should we also call authz_operator here ? Otherwise anybody can get tasks from here.
        #      Actually, maybe something even more strict is necessary (only the prod TW machine can access this resource)

        if method in ['POST']:
            validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("command", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_strlist("resubmittedjobs", param, safe, RX_JOBID)
            validate_str("workername",
                         param,
                         safe,
                         RX_WORKER_NAME,
                         optional=True)
            validate_str("subresource",
                         param,
                         safe,
                         RX_SUBPOSTWORKER,
                         optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_num("clusterid", param, safe,
                         optional=True)  #clusterid of the dag
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ['GET']:
            validate_str("workername",
                         param,
                         safe,
                         RX_WORKER_NAME,
                         optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource",
                         param,
                         safe,
                         RX_SUBGETWORKER,
                         optional=True)
Exemplo n.º 12
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()
        if not (authz_operator_without_raise('aso', 'operator') or
                authz_operator_without_raise('crab3', 'operator')):
            # TODO: do not forget to uncomment this
            # so far just print a warning
            print ('WARNING. NOT AUTHORIZED')
            #raise ForbiddenAccess('Access is restricted to this API')
        if method in ['PUT']:
            raise UnsupportedMethod('This method is not supported in this API!')
        elif method in ['POST']:
            # POST is for update, so we should allow anyone anything?
            # Of Course no, but there are multiple combinations, so we are not validating here
            # and all validation is in post function
            validate_str("subresource", param, safe, RX_SUBPOSTTRANSFER, optional=False)
            validate_str("asoworker", param, safe, RX_ASO_WORKERNAME, optional=False)
            validate_str("username", param, safe, RX_USERNAME, optional=True)
            validate_str("list_of_ids", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_transfer_state", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_failure_reason", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_retry_value", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_fts_instance", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_fts_id", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_publication_state", param, safe, RX_ANYTHING, optional=True)
            validate_num("time_to", param, safe, optional=True)
            validate_num("publish_flag", param, safe, optional=True)

        elif method in ['GET']:
            validate_str("subresource", param, safe, RX_SUBGETTRANSFER, optional=False)
            validate_str("username", param, safe, RX_USERNAME, optional=True)
            validate_str("vogroup", param, safe, RX_VOPARAMS, optional=True)
            validate_str("vorole", param, safe, RX_VOPARAMS, optional=True)
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("destination", param, safe, RX_CMSSITE, optional=True)
            validate_str("source", param, safe, RX_CMSSITE, optional=True)
            validate_str("asoworker", param, safe, RX_ASO_WORKERNAME, optional=True)
            validate_num("grouping", param, safe, optional=False)
            validate_num("limit", param, safe, optional=True)
        elif method in ['DELETE']:
            # This one I don`t really like to have implemented
            # There is some security concerns
            # But I still have one idea what we should clean up and where.
            # So leave it for the future.
            pass
Exemplo n.º 13
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()
        if not (authz_operator_without_raise('aso', 'operator') or
                authz_operator_without_raise('crab3', 'operator')):
            # TODO: do not forget to uncomment this
            # so far just print a warning
            print ('WARNING. NOT AUTHORIZED')
            #raise ForbiddenAccess('Access is restricted to this API')
        if method in ['PUT']:
            raise UnsupportedMethod('This method is not supported in this API!')
        elif method in ['POST']:
            # POST is for update, so we should allow anyone anything?
            # Of Course no, but there are multiple combinations, so we are not validating here
            # and all validation is in post function
            validate_str("subresource", param, safe, RX_SUBPOSTTRANSFER, optional=False)
            validate_str("asoworker", param, safe, RX_ASO_WORKERNAME, optional=False)
            validate_str("username", param, safe, RX_USERNAME, optional=True)
            validate_str("list_of_ids", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_transfer_state", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_failure_reason", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_retry_value", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_fts_instance", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_fts_id", param, safe, RX_ANYTHING, optional=True)
            validate_str("list_of_publication_state", param, safe, RX_ANYTHING, optional=True)
            validate_num("time_to", param, safe, optional=True)
            validate_num("publish_flag", param, safe, optional=True)

        elif method in ['GET']:
            validate_str("subresource", param, safe, RX_SUBGETTRANSFER, optional=False)
            validate_str("username", param, safe, RX_USERNAME, optional=True)
            validate_str("vogroup", param, safe, RX_VOPARAMS, optional=True)
            validate_str("vorole", param, safe, RX_VOPARAMS, optional=True)
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("destination", param, safe, RX_CMSSITE, optional=True)
            validate_str("source", param, safe, RX_CMSSITE, optional=True)
            validate_str("asoworker", param, safe, RX_ASO_WORKERNAME, optional=True)
            validate_num("grouping", param, safe, optional=False)
            validate_num("limit", param, safe, optional=True)
        elif method in ['DELETE']:
            # This one I don`t really like to have implemented
            # There is some security concerns
            # But I still have one idea what we should clean up and where.
            # So leave it for the future.
            pass
Exemplo n.º 14
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid() #TODO: should we also call authz_operator here ? Otherwise anybody can get tasks from here.
                            #      Actually, maybe something even more strict is necessary (only the prod TW machine can access this resource)

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=False)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("substatus", param, safe, RX_STATUS, optional=False)
            validate_strlist("subblocks", param, safe, RX_BLOCK)
            validate_str("subfailure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=False)
        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("jobset", param, safe, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_numlist("resubmittedjobs", param, safe)
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("subresource", param, safe, RX_SUBPOSTWORKER, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ['GET']:
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource", param, safe, RX_SUBGETWORKER, optional=True)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=True)
            # possible combinations to check
            # 1) workername + getstatus + limit
            # 2) subresource + subjobdef + subuser
        elif method in ['DELETE']:
            pass
Exemplo n.º 15
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=False)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("substatus", param, safe, RX_STATUS, optional=False)
            validate_strlist("subblocks", param, safe, RX_BLOCK)
            validate_str("subfailure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=False)
        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("jobset", param, safe, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_numlist("resubmittedjobs", param, safe)
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("subresource", param, safe, RX_SUBPOSTWORKER, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            validate_strlist("outputdataset", param, safe, RX_OUT_DATASET)
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ['GET']:
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource", param, safe, RX_SUBGETWORKER, optional=True)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=True)
            # possible combinations to check
            # 1) workername + getstatus + limit
            # 2) subresource + subjobdef + subuser
        elif method in ['DELETE']:
            pass
Exemplo n.º 16
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=False)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("substatus", param, safe, RX_STATUS, optional=False)
            validate_strlist("subblocks", param, safe, RX_BLOCK)
            validate_str("subfailure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=False)
        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("jobset", param, safe, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_numlist("resubmittedjobs", param, safe)
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("subresource", param, safe, RX_SUBPOSTWORKER, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ['GET']:
            validate_str("workername", param, safe, RX_WORKER_NAME, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource", param, safe, RX_SUBGETWORKER, optional=True)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=True)
            # possible combinations to check
            # 1) workername + getstatus + limit
            # 2) subresource + subjobdef + subuser
        elif method in ['DELETE']:
            pass
Exemplo n.º 17
0
 def validate(self, apiobj, method, api, param, safe):
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     authz_login_valid()
     if method in ['GET']:
         validate_str('subresource',
                      param,
                      safe,
                      RX_SUBRES_CACHE,
                      optional=False)
         validate_str('objecttype',
                      param,
                      safe,
                      RX_CACHE_OBJECTTYPE,
                      optional=True)
         validate_str('taskname', param, safe, RX_TASKNAME, optional=True)
         validate_str('username', param, safe, RX_USERNAME, optional=True)
         validate_str('tarballname',
                      param,
                      safe,
                      RX_TARBALLNAME,
                      optional=True)
Exemplo n.º 18
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)
            validate_strlist("workflow", param, safe, RX_WORKFLOW)

        elif method in ['POST']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)

        elif method in ['GET']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=True)
            validate_num('age', param, safe, optional=True)
            validate_str('subresource', param, safe, RX_SUBRESTAT, optional=True)
            validate_num('limit', param, safe, optional=True)
            if not safe.kwargs['campaign'] and not safe.kwargs['age']:
                raise InvalidParameter("Invalid input parameters")
            if not safe.kwargs['campaign'] and safe.kwargs['subresource']:
                raise InvalidParameter("Invalid input parameters")

        elif method in ['DELETE']:
            validate_str("campaign", param, safe, RX_CAMPAIGN, optional=False)
            validate_num("force", param, safe, optional=True)
Exemplo n.º 19
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(
                    safe.kwargs["outfilelumis"]):
                raise InvalidParameter(
                    "The number of runs and the number of lumis lists are different"
                )
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_num("pandajobid", param, safe, optional=False)
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname",
                         param,
                         safe,
                         RX_PUBLISH,
                         optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumcksum",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumadler32",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("outlocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("outtmplocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("acquisitionera",
                         param,
                         safe,
                         RX_TASKNAME,
                         optional=False)  #TODO Do we really need this?
            validate_str(
                "outdatasetname", param, safe, RX_OUTDSLFN,
                optional=False)  #TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_PARENTLFN, optional=False)
            validate_str("outtmplfn", param, safe, RX_PARENTLFN, optional=True)
            validate_num("events", param, safe, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=True)
            validate_num("directstageout", param, safe, optional=True)
            safe.kwargs["directstageout"] = 'T' if safe.kwargs[
                "directstageout"] else 'F'  #'F' if not provided
        elif method in ['POST']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_str("filestate",
                         param,
                         safe,
                         RX_FILESTATE,
                         optional=False)
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
        elif method in ['DELETE']:
            authz_operator()
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("hours", param, safe, RX_HOURS, optional=True)
            if bool(safe.kwargs["taskname"]) == bool(safe.kwargs["hours"]):
                raise InvalidParameter("You have to specify a taskname or a number of hours. Files of this task or created before the number of hours"+\
                                         " will be deleted. Only one of the two parameters can be specified.")
Exemplo n.º 20
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid(
        )  #TODO: should we also call authz_operator here ? Otherwise anybody can get tasks from here.
        #      Actually, maybe something even more strict is necessary (only the prod TW machine can access this resource)

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_TASKNAME, optional=False)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("substatus", param, safe, RX_STATUS, optional=False)
            validate_strlist("subblocks", param, safe, RX_BLOCK)
            validate_str("subfailure",
                         param,
                         safe,
                         RX_TEXT_FAIL,
                         optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=False)
        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_TASKNAME, optional=True)
            validate_str("status", param, safe, RX_STATUS, optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("jobset", param, safe, optional=True)
            validate_str("failure", param, safe, RX_TEXT_FAIL, optional=True)
            validate_numlist("resubmittedjobs", param, safe)
            validate_str("workername",
                         param,
                         safe,
                         RX_WORKER_NAME,
                         optional=True)
            validate_str("subresource",
                         param,
                         safe,
                         RX_SUBPOSTWORKER,
                         optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            # possible combinations to check
            # 1) taskname + status
            # 2) taskname + status + failure
            # 3) taskname + status + resubmitted + jobsetid
            # 4) taskname + status == (1)
            # 5)            status + limit + getstatus + workername
            # 6) taskname + runs + lumis
        elif method in ['GET']:
            validate_str("workername",
                         param,
                         safe,
                         RX_WORKER_NAME,
                         optional=True)
            validate_str("getstatus", param, safe, RX_STATUS, optional=True)
            validate_num("limit", param, safe, optional=True)
            validate_str("subresource",
                         param,
                         safe,
                         RX_SUBGETWORKER,
                         optional=True)
            validate_num("subjobdef", param, safe, optional=True)
            validate_str("subuser", param, safe, RX_DN, optional=True)
            # possible combinations to check
            # 1) workername + getstatus + limit
            # 2) subresource + subjobdef + subuser
        elif method in ['DELETE']:
            pass
Exemplo n.º 21
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=False)
            validate_str("jobtype", param, safe, RX_JOBTYPE, optional=False)
            validate_str("jobsw", param, safe, RX_CMSSW, optional=False)
            validate_str("jobarch", param, safe, RX_ARCH, optional=False)
            jobtype = safe.kwargs.get('jobtype', None)
            if jobtype == 'Analysis':
                validate_str("inputdata",
                             param,
                             safe,
                             RX_DATASET,
                             optional=False)
            validate_strlist("siteblacklist", param, safe, RX_CMSSITE)
            safe.kwargs['siteblacklist'] = self._expandSites(
                safe.kwargs['siteblacklist'])
            validate_strlist("sitewhitelist", param, safe, RX_CMSSITE)
            safe.kwargs['sitewhitelist'] = self._expandSites(
                safe.kwargs['sitewhitelist'])
            validate_str("splitalgo", param, safe, RX_SPLIT, optional=False)
            validate_num("algoargs", param, safe, optional=False)
            validate_str("cachefilename",
                         param,
                         safe,
                         RX_CACHENAME,
                         optional=False)
            validate_str("cacheurl", param, safe, RX_CACHEURL, optional=False)
            #validate_str("userisburl", param, safe, re.compile(r"^[A-Za-z]*$"), optional=False)
            validate_strlist("addoutputfiles", param, safe, RX_ADDFILE)
            validate_num("savelogsflag", param, safe, optional=False)
            validate_str("vorole", param, safe, RX_VOPARAMS, optional=True)
            validate_str("vogroup", param, safe, RX_VOPARAMS, optional=True)
            validate_str("publishname", param, safe, RX_PUBLISH, optional=True)
            validate_str("publishdbsurl",
                         param,
                         safe,
                         RX_DBSURL,
                         optional=True)
            validate_num("publication", param, safe, optional=False)
            #if publication is set as true both publishDataName and publishDbsUrl are needed
            if safe.kwargs["publication"] and not (
                    bool(safe.kwargs["publishname"])
                    and bool(safe.kwargs["publishdbsurl"])):
                raise InvalidParameter(
                    "You need to set both publishDataName and publishDbsUrl parameters if you need the automatic publication"
                )
            #if one and only one between publishDataName and publishDbsUrl is set raise an error (we need both or none of them)
            if bool(safe.kwargs["publishname"]) != bool(
                    safe.kwargs["publishdbsurl"]):
                raise InvalidParameter(
                    "You need to set both publishDataName and publishDbsUrl parameters if you need the automatic publication"
                )
            validate_str("asyncdest", param, safe, RX_CMSSITE, optional=False)
            self._checkSite(safe.kwargs['asyncdest'])
            validate_num("blacklistT1", param, safe, optional=False)
            validate_str("dbsurl", param, safe, RX_DBSURL, optional=True)
            validate_strlist("tfileoutfiles", param, safe, RX_OUTFILES)
            validate_strlist("edmoutfiles", param, safe, RX_OUTFILES)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            if len(safe.kwargs["runs"]) != len(safe.kwargs["lumis"]):
                raise InvalidParameter(
                    "The number of runs and the number of lumis lists are different"
                )

        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=False)
            validate_strlist("siteblacklist", param, safe, RX_CMSSITE)
            safe.kwargs['siteblacklist'] = self._expandSites(
                safe.kwargs['siteblacklist'])
            validate_strlist("sitewhitelist", param, safe, RX_CMSSITE)
            safe.kwargs['sitewhitelist'] = self._expandSites(
                safe.kwargs['sitewhitelist'])

        elif method in ['GET']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=True)
            validate_str('subresource',
                         param,
                         safe,
                         RX_SUBRESTAT,
                         optional=True)

            #parameters of subresources calls has to be put here
            #used by get latest
            validate_num('age', param, safe, optional=True)

            #used by get log, get data
            validate_num('limit', param, safe, optional=True)
            validate_num('exitcode', param, safe, optional=True)
            validate_numlist('jobids', param, safe)

            #used by errors
            validate_num('shortformat', param, safe, optional=True)

            #validation parameters
            if not safe.kwargs['workflow'] and safe.kwargs['subresource']:
                raise InvalidParameter("Invalid input parameters")
            if safe.kwargs['subresource'] in [
                    'data', 'logs'
            ] and not safe.kwargs['limit'] and not safe.kwargs['jobids']:
                raise InvalidParameter(
                    "You need to specify the number of jobs to retrieve or their ids."
                )

        elif method in ['DELETE']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=False)
            validate_num("force", param, safe, optional=True)
Exemplo n.º 22
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(
                    safe.kwargs["outfilelumis"]):
                raise InvalidParameter(
                    "The number of runs and the number of lumis lists are different"
                )
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_str("jobid", param, safe, RX_JOBID, optional=True)
            #TODO: for backward compatibility. Get rid of the pandajobid once all jobs using it are done (one month after this gets released)
            #(The following five lines can be deleted)
            validate_num("pandajobid", param, safe, optional=True)
            if bool(safe.kwargs["jobid"]) == bool(safe.kwargs["pandajobid"]):
                raise InvalidParameter(
                    "Only one among jobid and pandajobid should be set")
            #Oracle/cx_oracle/python stack does not like None for numbers, even if they are nullable
            if safe.kwargs["pandajobid"] == None:
                safe.kwargs["pandajobid"] = 0
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname",
                         param,
                         safe,
                         RX_PUBLISH,
                         optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumcksum",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumadler32",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("outlocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("outtmplocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("acquisitionera",
                         param,
                         safe,
                         RX_TASKNAME,
                         optional=False)  #TODO Do we really need this?
            validate_str(
                "outdatasetname", param, safe, RX_OUTDSLFN,
                optional=False)  #TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_PARENTLFN, optional=False)
            validate_str("outtmplfn", param, safe, RX_PARENTLFN, optional=True)
            validate_num("events", param, safe, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=True)
            validate_num("directstageout", param, safe, optional=True)
            safe.kwargs["directstageout"] = 'T' if safe.kwargs[
                "directstageout"] else 'F'  #'F' if not provided
        elif method in ['POST']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_str("filestate",
                         param,
                         safe,
                         RX_FILESTATE,
                         optional=False)
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
            validate_num("howmany", param, safe, optional=True)
            validate_strlist("lfn", param, safe, RX_LFN)
        elif method in ['DELETE']:
            authz_operator()
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("hours", param, safe, RX_HOURS, optional=True)
            if bool(safe.kwargs["taskname"]) == bool(safe.kwargs["hours"]):
                raise InvalidParameter("You have to specify a taskname or a number of hours. Files of this task or created before the number of hours"+\
                                         " will be deleted. Only one of the two parameters can be specified.")
Exemplo n.º 23
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("workflow", param, safe, RX_WORKFLOW, optional=False)
            validate_str("jobtype", param, safe, RX_JOBTYPE, optional=False)
            validate_str("jobsw", param, safe, RX_CMSSW, optional=False)
            validate_str("jobarch", param, safe, RX_ARCH, optional=False)
            jobtype = safe.kwargs.get('jobtype', None)
            if jobtype == 'Analysis':
                validate_str("inputdata", param, safe, RX_DATASET, optional=False)
            validate_strlist("siteblacklist", param, safe, RX_CMSSITE)
            safe.kwargs['siteblacklist'] = self._expandSites(safe.kwargs['siteblacklist'])
            validate_strlist("sitewhitelist", param, safe, RX_CMSSITE)
            safe.kwargs['sitewhitelist'] = self._expandSites(safe.kwargs['sitewhitelist'])
            validate_str("splitalgo", param, safe, RX_SPLIT, optional=False)
            validate_num("algoargs", param, safe, optional=False)
            validate_str("cachefilename", param, safe, RX_CACHENAME, optional=False)
            validate_str("cacheurl", param, safe, RX_CACHEURL, optional=False)
            #validate_str("userisburl", param, safe, re.compile(r"^[A-Za-z]*$"), optional=False)
            validate_strlist("addoutputfiles", param, safe, RX_ADDFILE)
            validate_num("savelogsflag", param, safe, optional=False)
            validate_str("vorole", param, safe, RX_VOPARAMS, optional=True)
            validate_str("vogroup", param, safe, RX_VOPARAMS, optional=True)
            validate_str("publishname", param, safe, RX_PUBLISH, optional=True)
            validate_str("publishdbsurl", param, safe, RX_DBSURL, optional=True)
            validate_num("publication", param, safe, optional=False)
            #if publication is set as true both publishDataName and publishDbsUrl are needed
            if safe.kwargs["publication"] and not (bool(safe.kwargs["publishname"]) and bool(safe.kwargs["publishdbsurl"])):
                raise InvalidParameter("You need to set both publishDataName and publishDbsUrl parameters if you need the automatic publication")
            #if one and only one between publishDataName and publishDbsUrl is set raise an error (we need both or none of them)
            if bool(safe.kwargs["publishname"]) != bool(safe.kwargs["publishdbsurl"]):
                raise InvalidParameter("You need to set both publishDataName and publishDbsUrl parameters if you need the automatic publication")
            validate_str("asyncdest", param, safe, RX_CMSSITE, optional=False)
            self._checkSite(safe.kwargs['asyncdest'])
            validate_num("blacklistT1", param, safe, optional=False)
            validate_str("dbsurl", param, safe, RX_DBSURL, optional=True)
            validate_strlist("tfileoutfiles", param, safe, RX_OUTFILES)
            validate_strlist("edmoutfiles", param, safe, RX_OUTFILES)
            validate_strlist("runs", param, safe, RX_RUNS)
            validate_strlist("lumis", param, safe, RX_LUMIRANGE)
            if len(safe.kwargs["runs"]) != len(safe.kwargs["lumis"]):
                raise InvalidParameter("The number of runs and the number of lumis lists are different")

        elif method in ['POST']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=False)
            validate_strlist("siteblacklist", param, safe, RX_CMSSITE)
            safe.kwargs['siteblacklist'] = self._expandSites(safe.kwargs['siteblacklist'])
            validate_strlist("sitewhitelist", param, safe, RX_CMSSITE)
            safe.kwargs['sitewhitelist'] = self._expandSites(safe.kwargs['sitewhitelist'])

        elif method in ['GET']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=True)
            validate_str('subresource', param, safe, RX_SUBRESTAT, optional=True)

            #parameters of subresources calls has to be put here
            #used by get latest
            validate_num('age', param, safe, optional=True)

            #used by get log, get data
            validate_num('limit', param, safe, optional=True)
            validate_num('exitcode', param, safe, optional=True)
            validate_numlist('jobids', param, safe)

            #used by errors
            validate_num('shortformat', param, safe, optional=True)

            #validation parameters
            if not safe.kwargs['workflow'] and safe.kwargs['subresource']:
                raise InvalidParameter("Invalid input parameters")
            if safe.kwargs['subresource'] in ['data', 'logs'] and not safe.kwargs['limit'] and not safe.kwargs['jobids']:
                raise InvalidParameter("You need to specify the number of jobs to retrieve or their ids.")

        elif method in ['DELETE']:
            validate_str("workflow", param, safe, RX_UNIQUEWF, optional=False)
            validate_num("force", param, safe, optional=True)
Exemplo n.º 24
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            #TODO check optional parameter
            #TODO check all the regexp
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_numlist("outfileruns", param, safe)
            if len(safe.kwargs["outfileruns"]) != len(
                    safe.kwargs["outfilelumis"]):
                raise InvalidParameter(
                    "The number of runs and the number of lumis lists are different"
                )
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_num("pandajobid", param, safe, optional=False)
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname",
                         param,
                         safe,
                         RX_PUBLISH,
                         optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumcksum",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("checksumadler32",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("outlocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("outtmplocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("acquisitionera",
                         param,
                         safe,
                         RX_WORKFLOW,
                         optional=False)  #TODO Do we really need this?
            validate_str(
                "outdatasetname", param, safe, RX_OUTDSLFN,
                optional=False)  #TODO temporary, need to come up with a regex
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_num("events", param, safe, optional=False)
        elif method in ['POST']:
            raise NotImplementedError
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_WORKFLOW, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
        elif method in ['DELETE']:
            raise NotImplementedError
Exemplo n.º 25
0
 def validate(self, apiobj, method, api, param, safe ):
     """Validating all the input parameter as enforced by the WMCore.REST module"""
     authz_login_valid()
     if method in ['GET']:
         validate_str('subresource' , param, safe, RX_SUBRES_SI, optional=False)
Exemplo n.º 26
0
    def validate(self, apiobj, method, api, param, safe):
        """Validating all the input parameter as enforced by the WMCore.REST module"""
        authz_login_valid()

        if method in ['PUT']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_strlist("outfilelumis", param, safe, RX_LUMILIST)
            validate_strlist("outfileruns", param, safe, RX_RUNS)
            if len(safe.kwargs["outfileruns"]) != len(
                    safe.kwargs["outfilelumis"]):
                raise InvalidParameter(
                    "The number of runs and the number of lumis lists are different"
                )
            validate_strlist("inparentlfns", param, safe, RX_PARENTLFN)
            # inparentlfns will be inserted in Oracle as CLOB, so it must be a string
            safe.kwargs['inparentlfns'] = str(safe.kwargs['inparentlfns'])
            validate_str("globalTag", param, safe, RX_GLOBALTAG, optional=True)
            validate_str("jobid", param, safe, RX_JOBID, optional=True)
            safe.kwargs["pandajobid"] = 0
            validate_num("outsize", param, safe, optional=False)
            validate_str("publishdataname",
                         param,
                         safe,
                         RX_PUBLISH,
                         optional=False)
            validate_str("appver", param, safe, RX_CMSSW, optional=False)
            validate_str("outtype", param, safe, RX_OUTTYPES, optional=False)
            validate_str("checksummd5",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_num("checksumcksum", param, safe, optional=False)
            validate_str("checksumadler32",
                         param,
                         safe,
                         RX_CHECKSUM,
                         optional=False)
            validate_str("outlocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("outtmplocation",
                         param,
                         safe,
                         RX_CMSSITE,
                         optional=False)
            validate_str("acquisitionera",
                         param,
                         safe,
                         RX_TASKNAME,
                         optional=False)
            validate_str("outdatasetname",
                         param,
                         safe,
                         RX_OUTDSLFN,
                         optional=False)
            # need to use RX_PARENTLFN becasue same API is also used for input metadata
            validate_str("outlfn", param, safe, RX_PARENTLFN, optional=False)
            validate_str("outtmplfn", param, safe, RX_LFN, optional=True)
            validate_num("events", param, safe, optional=False)
            validate_str("filestate", param, safe, RX_FILESTATE, optional=True)
            validate_num("directstageout", param, safe, optional=True)
            safe.kwargs["directstageout"] = 'T' if safe.kwargs[
                "directstageout"] else 'F'  #'F' if not provided
        elif method in ['POST']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("outlfn", param, safe, RX_LFN, optional=False)
            validate_str("filestate",
                         param,
                         safe,
                         RX_FILESTATE,
                         optional=False)
        elif method in ['GET']:
            validate_str("taskname", param, safe, RX_TASKNAME, optional=False)
            validate_str("filetype", param, safe, RX_OUTTYPES, optional=False)
            validate_num("howmany", param, safe, optional=True)
            validate_strlist("lfn", param, safe, RX_LFN)
        elif method in ['DELETE']:
            authz_operator()
            validate_str("taskname", param, safe, RX_TASKNAME, optional=True)
            validate_str("hours", param, safe, RX_HOURS, optional=True)
            if bool(safe.kwargs["taskname"]) == bool(safe.kwargs["hours"]):
                raise InvalidParameter("You have to specify a taskname or a number of hours. Files of this task or created before the number of hours"+\
                                        " will be deleted. Only one of the two parameters can be specified.")