def post(self, workflow, subresource, publication, jobids, force, siteblacklist, sitewhitelist, maxjobruntime, maxmemory, numcores, priority): """Resubmit or continue an existing workflow. The caller needs to be a CMS user owner of the workflow. :arg str workflow: unique name identifier of the workflow; :arg str list siteblacklist: black list of sites, with CMS name; :arg str list sitewhitelist: white list of sites, with CMS name.""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow], self.Task) if not subresource or subresource == 'resubmit': return self.userworkflowmgr.resubmit(workflow=workflow, publication=publication, jobids=jobids, force=force, siteblacklist=siteblacklist, sitewhitelist=sitewhitelist, maxjobruntime=maxjobruntime, maxmemory=maxmemory, numcores=numcores, priority=priority, userdn=cherrypy.request.headers['Cms-Authn-Dn']) elif subresource == 'resubmit2': return self.userworkflowmgr.resubmit2(workflow=workflow, publication=publication, jobids=jobids, siteblacklist=siteblacklist, sitewhitelist=sitewhitelist, maxjobruntime=maxjobruntime, maxmemory=maxmemory, numcores=numcores, priority=priority) elif subresource == 'proceed': return self.userworkflowmgr.proceed(workflow=workflow)
def deletewarnings(self, **kwargs): """ Deleet warnings from the warning column in the database. Can be tested with: curl -X POST https://mmascher-poc.cern.ch/crabserver/dev/task -k --key /tmp/x509up_u8440 --cert /tmp/x509up_u8440 \ -d 'subresource=deletewarnings&workflow=140710_233424_crab3test-5:mmascher_crab_HCprivate12' -v """ #check if the parameter is there if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") #decoding and setting the parameters workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow # rows = self.api.query(None, None, "SELECT tm_task_warnings FROM tasks WHERE tm_taskname = :workflow", workflow=workflow)#self.Task.TASKSUMMARY_sql) rows = self.api.query(None, None, self.Task.ID_sql, taskname=workflow)#self.Task.TASKSUMMARY_sql) rows = list(rows) #from generator to list if len(rows)==0: raise InvalidParameter("Task %s not found in the task database" % workflow) row = self.Task.ID_tuple(*rows[0]) warnings = literal_eval(row.task_warnings.read() if row.task_warnings else '[]') if len(warnings)<1: raise ExecutionError("No warnings to remove.") self.api.modify(self.Task.DeleteWarnings_sql, workflow=[workflow]) return []
def addwarning(self, **kwargs): """ Add a warning to the wraning column in the database. Can be tested with: curl -X POST https://mmascher-poc.cern.ch/crabserver/dev/task -k --key /tmp/x509up_u8440 --cert /tmp/x509up_u8440 \ -d 'subresource=addwarning&workflow=140710_233424_crab3test-5:mmascher_crab_HCprivate12&warning=blahblah' -v """ #check if the parameters are there if 'warning' not in kwargs or not kwargs['warning']: raise InvalidParameter("Warning message not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") #decoding and setting the parameters workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow try: warning = b64decode(kwargs['warning']) except TypeError: raise InvalidParameter("Failure message is not in the accepted format") # rows = self.api.query(None, None, "SELECT tm_task_warnings FROM tasks WHERE tm_taskname = :workflow", workflow=workflow)#self.Task.TASKSUMMARY_sql) rows = self.api.query(None, None, self.Task.ID_sql, taskname=workflow)#self.Task.TASKSUMMARY_sql) rows = list(rows) #from generator to list if len(rows)==0: raise InvalidParameter("Task %s not found in the task database" % workflow) row = self.Task.ID_tuple(*rows[0]) warnings = literal_eval(row.task_warnings.read() if row.task_warnings else '[]') if len(warnings)>10: raise ExecutionError("You cannot add more than 10 warnings to a task") warnings.append(warning) self.api.modify(self.Task.SetWarnings_sql, warnings=[str(warnings)], workflow=[workflow]) return []
def addoutputdatasets(self, **kwargs): if 'outputdatasets' not in kwargs or not kwargs['outputdatasets']: raise InvalidParameter( "Output datasets not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter( "Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match( self.api, [workflow], self.Task) #check that I am modifying my own workflow row = self.Task.ID_tuple(*self.api.query( None, None, self.Task.ID_sql, taskname=workflow).next()) outputdatasets = literal_eval( row.output_dataset.read() if row.output_dataset else '[]') outputdatasets = str( list(set(outputdatasets + kwargs['outputdatasets']))) self.api.modify(self.Task.SetUpdateOutDataset_sql, tm_output_dataset=[outputdatasets], tm_taskname=[workflow]) return []
def delete(self, workflow, force, killwarning): """Aborts a workflow. The user needs to be a CMS owner of the workflow. :arg str list workflow: list of unique name identifiers of workflows; :arg int force: force to delete the workflows in any case; 0 no, everything else yes; :return: nothing""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow], self.Task) return self.userworkflowmgr.kill(workflow, force, killwarning, userdn=cherrypy.request.headers['Cms-Authn-Dn'])
def delete(self, workflow, force, jobids, killwarning): """Aborts a workflow. The user needs to be a CMS owner of the workflow. :arg str list workflow: list of unique name identifiers of workflows; :arg int force: force to delete the workflows in any case; 0 no, everything else yes; :return: nothing""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow], self.Task) return self.userworkflowmgr.kill(workflow, force, jobids, killwarning, userdn=cherrypy.request.headers['Cms-Authn-Dn'])
def post(self, workflow, siteblacklist, sitewhitelist, jobids): """Resubmit an existing workflow. The caller needs to be a CMS user owner of the workflow. :arg str workflow: unique name identifier of the workflow; :arg str list siteblacklist: black list of sites, with CMS name; :arg str list sitewhitelist: white list of sites, with CMS name.""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow]) return self.userworkflowmgr.resubmit(workflow=workflow, siteblacklist=siteblacklist, sitewhitelist=sitewhitelist, jobids=jobids, \ userdn=cherrypy.request.headers['Cms-Authn-Dn'])
def post(self, workflow, siteblacklist, sitewhitelist): """Resubmit an existing workflow. The caller needs to be a CMS user owner of the workflow. :arg str workflow: unique name identifier of the workflow; :arg str list siteblacklist: black list of sites, with CMS name; :arg str list sitewhitelist: white list of sites, with CMS name.""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow]) self.userworkflowmgr.resubmit(workflow=workflow, siteblacklist=siteblacklist, sitewhitelist=sitewhitelist, userdn=cherrypy.request.headers['Cms-Authn-Dn']) return [{"result":"ok"}]
def post(self, workflow, siteblacklist, sitewhitelist, jobids, maxjobruntime, numcores, maxmemory, priority): """Resubmit an existing workflow. The caller needs to be a CMS user owner of the workflow. :arg str workflow: unique name identifier of the workflow; :arg str list siteblacklist: black list of sites, with CMS name; :arg str list sitewhitelist: white list of sites, with CMS name.""" # strict check on authz: only the workflow owner can modify it authz_owner_match(self.api, [workflow], self.Task) return self.userworkflowmgr.resubmit(workflow=workflow, siteblacklist=siteblacklist, sitewhitelist=sitewhitelist, jobids=jobids, \ maxjobruntime=maxjobruntime, numcores=numcores, maxmemory=maxmemory, priority=priority, userdn=cherrypy.request.headers['Cms-Authn-Dn'])
def updatepublicationtime(self, **kwargs): """ Change last publication time for task. curl -X POST 'https://mmascher-gwms.cern.ch/crabserver/dev/task' -ks --key $X509_USER_PROXY --cert $X509_USER_PROXY --cacert $X509_USER_PROXY \ -d 'subresource=updatepublicationtime&workflow=161128_202743:mmascher_crab_test_preprodaso_preprodorammascher-gwms_0' -v """ if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdatePublicationTime_sql, workflow=[workflow]) return []
def updateschedd(self, **kwargs): """ Change scheduler for task submission. curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -ks --key $X509_USER_PROXY --cert $X509_USER_PROXY --cacert $X509_USER_PROXY \ -d 'subresource=updateschedd&workflow=150316_221646:jbalcas_crab_test_submit-5-274334&scheddname=vocms095.asdadasdasdacern.ch' -v """ if 'scheddname' not in kwargs or not kwargs['scheddname']: raise InvalidParameter("Schedd name not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateSchedd_sql, scheddname=[kwargs['scheddname']], workflow=[workflow]) return []
def addoutputdatasets(self, **kwargs): if 'outputdatasets' not in kwargs or not kwargs['outputdatasets']: raise InvalidParameter("Output datasets not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow row = self.Task.ID_tuple(*next(self.api.query(None, None, self.Task.ID_sql, taskname=workflow))) outputdatasets = literal_eval(row.output_dataset.read() if row.output_dataset else '[]') outputdatasets = str(list(set(outputdatasets + kwargs['outputdatasets']))) self.api.modify(self.Task.SetUpdateOutDataset_sql, tm_output_dataset=[outputdatasets], tm_taskname=[workflow]) return []
def updateschedd(self, **kwargs): """ Change scheduler for task submission. curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -ks --key $X509_USER_PROXY --cert $X509_USER_PROXY --cacert $X509_USER_PROXY \ -d 'subresource=updateschedd&workflow=150316_221646:jbalcas_crab_test_submit-5-274334&scheddname=vocms095.asdadasdasdacern.ch' -v """ if 'scheddname' not in kwargs or not kwargs['scheddname']: raise InvalidParameter("Schedd name not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateSchedd_sql, scheddname=[str(kwargs['scheddname'])], workflow=[workflow]) return []
def addddmreqid(self, **kwargs): """ Add DDM request ID to DDM_reqid column in the database. Can be tested with: curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -k --key $X509_USER_PROXY --cert $X509_USER_PROXY \ -d 'subresource=addddmreqid&workflow=?&taskstatus=TAPERECALL&ddmreqid=d2b715f526e14f91b0c299abb560d5d7' -v """ #check if the parameters are there if 'ddmreqid' not in kwargs or not kwargs['ddmreqid']: raise InvalidParameter("DDM request ID not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateDDMReqId_sql, taskstatus=[kwargs['taskstatus']], ddmreqid=[kwargs['ddmreqid']], workflow=[workflow]) return []
def addddmreqid(self, **kwargs): """ Add DDM request ID to DDM_reqid column in the database. Can be tested with: curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -k --key $X509_USER_PROXY --cert $X509_USER_PROXY \ -d 'subresource=addddmreqid&workflow=?&taskstatus=TAPERECALL&ddmreqid=12345' -v """ #check if the parameters are there if 'ddmreqid' not in kwargs or not kwargs['ddmreqid']: raise InvalidParameter("DDM request ID not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateDDMReqId_sql, taskstatus=[kwargs['taskstatus']], ddmreqid=[kwargs['ddmreqid']], workflow=[workflow]) return []
def addwebdir(self, **kwargs): """ Add web directory to web_dir column in the database. Can be tested with: curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -k --key $X509_USER_PROXY --cert $X509_USER_PROXY \ -d 'subresource=addwebdir&workflow=140710_233424_crab3test-5:mmascher_crab_HCprivate12&webdirurl=http://cmsweb.cern.ch/crabserver/testtask' -v """ #check if the parameters are there if 'webdirurl' not in kwargs or not kwargs['webdirurl']: raise InvalidParameter("Web directory url not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateWebUrl_sql, webdirurl=[str(kwargs['webdirurl'])], workflow=[workflow]) return []
def addwebdir(self, **kwargs): """ Add web directory to web_dir column in the database. Can be tested with: curl -X POST https://balcas-crab.cern.ch/crabserver/dev/task -k --key $X509_USER_PROXY --cert $X509_USER_PROXY \ -d 'subresource=addwebdir&workflow=140710_233424_crab3test-5:mmascher_crab_HCprivate12&webdirurl=http://cmsweb.cern.ch/crabserver/testtask' -v """ #check if the parameters are there if 'webdirurl' not in kwargs or not kwargs['webdirurl']: raise InvalidParameter("Web directory url not found in the input parameters") if 'workflow' not in kwargs or not kwargs['workflow']: raise InvalidParameter("Task name not found in the input parameters") workflow = kwargs['workflow'] authz_owner_match(self.api, [workflow], self.Task) #check that I am modifying my own workflow self.api.modify(self.Task.UpdateWebUrl_sql, webdirurl=[kwargs['webdirurl']], workflow=[workflow]) return []