def main():
    """
    Read the text file, for each workflow try:
    First abort it, then clone it.
    """
    args=sys.argv[1:]
    if not len(args)==3:
        print "usage:abortAndClone file.txt user group"
        sys.exit(0)
    filename = args[0]
    user = args[1]
    group = args[2]

    #reading workflow list
    workflows = [wf.strip() for wf in open(filename).readlines() if wf.strip()]
    for workflow in workflows:
        #abort workflow
        print "Aborting workflow: " + workflow
        reqMgrClient.abortWorkflow(url, workflow)
        print "Aborted. Now cloning workflow..."
            
        #invalidates datasets
        print "Invalidating datasets"
        
        datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
        for dataset in datasets:
            print dataset
            dbs3.setStatusDBS3(dbs3_url, dataset, 'INVALID', None)

        #clone workflow
        clone = resubmit.cloneWorkflow(workflow, user, group)
        print "Cloned workflow: ",   clone
    sys.exit(0);
def main():
    """
    Read the text file, for each workflow try:
    First abort it, then clone it.
    """
    usage = "\n       python %prog [options] [WORKFLOW_NAME] [USER GROUP]\n"\
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"\
            "USER: the user for creating the clone, if empty it will\n"\
            "      use the OS user running the script\n"\
            "GROUP: the group for creating the clone, if empty it will\n"\
            "      use 'DATAOPS' by default"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Abort and Clone', dest='file')
    (options, args) = parser.parse_args()
    
    # Check the arguments, get info from them
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
        if len(args) == 2:
            user = args[0]
            group = args[1]
        elif len(args) == 0:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
    else:
        if len(args) == 3:
            user = args[1]
            group = args[2]
        elif len(args) == 1:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
        else:
            parser.error("Provide the workflow of a file of workflows")
            sys.exit(1)
        #name of workflow
        wfs = [args[0]]

    for wf in wfs:
        #abort workflow
        print "Aborting workflow: " + wf
        reqMgrClient.abortWorkflow(url, wf)
        #invalidates datasets
        print "Invalidating datasets"
        datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
        for ds in datasets:
            print ds
            dbs3.setDatasetStatus(ds, 'INVALID', files=True)

        #clone workflow
        clone = resubmit.cloneWorkflow(wf, user, group)
    sys.exit(0);
Exemple #3
0
def main():
    """
    Read the text file, for each workflow try:
    First abort it, then clone it.
    """
    usage = "\n       python %prog [options] [WORKFLOW_NAME] [USER GROUP]\n"\
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"\
            "USER: the user for creating the clone, if empty it will\n"\
            "      use the OS user running the script\n"\
            "GROUP: the group for creating the clone, if empty it will\n"\
            "      use 'DATAOPS' by default"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Reject and Clone', dest='file')
    (options, args) = parser.parse_args()
    
    # Check the arguments, get info from them
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
        if len(args) == 2:
            user = args[0]
            group = args[1]
        elif len(args) == 0:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
    else:
        if len(args) == 3:
            user = args[1]
            group = args[2]
        elif len(args) == 1:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
        else:
            parser.error("Provide the workflow of a file of workflows")
            sys.exit(1)
        #name of workflow
        wfs = [args[0]]

    for wf in wfs:
        #abort workflow
        print "Rejecting workflow: " + wf
        reqMgrClient.rejectWorkflow(url, wf)
        #invalidates datasets
        print "Invalidating datasets"
        datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
        for ds in datasets:
            print ds
            dbs3.setDatasetStatus(ds, 'INVALID', files=True)

        #clone workflow
        clone = resubmit.cloneWorkflow(wf, user, group)
    sys.exit(0);
Exemple #4
0
def main():
    usage = "\n       python %prog [options] [WORKFLOW_NAME]\n" \
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Reject and Clone', dest='file')
    parser.add_option('-c', '--clone', help='Are the workflows going to be cloned? The default value is False',action="store_true", dest='clone', default=False)
    parser.add_option('-i', '--invalidate', help='Invalidate datasets? The default value is False',action="store_true", dest='invalidate', default=False)
    parser.add_option("-u", "--user", dest="user",help="The user for creating the clone, if empty it will use the OS user running the script")
    parser.add_option("-g", "--group", dest="group", default='DATAOPS',help="The group for creating the clone, if empty it will, use 'DATAOPS' by default")
    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) >0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: "+ workflow+" is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: "+ workflow)
        reqMgrClient.invalidateWorkflow(url,workflow,workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, 'INVALID', files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: "+ workflow)
            cloned = resubmit.cloneWorkflow(workflow, user, options.group)
    sys.exit(0);
Exemple #5
0
def main():
    usage = "\n       python %prog [options] [WORKFLOW_NAME]\n" \
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"

    parser = OptionParser(usage=usage)
    parser.add_option('-f',
                      '--file',
                      help='Text file of workflows to Reject and Clone',
                      dest='file')
    parser.add_option(
        '-c',
        '--clone',
        help='Are the workflows going to be cloned? The default value is False',
        action="store_true",
        dest='clone',
        default=False)
    parser.add_option('-i',
                      '--invalidate',
                      help='Invalidate datasets? The default value is False',
                      action="store_true",
                      dest='invalidate',
                      default=False)
    parser.add_option(
        "-u",
        "--user",
        dest="user",
        help=
        "The user for creating the clone, if empty it will use the OS user running the script"
    )
    parser.add_option(
        "-g",
        "--group",
        dest="group",
        default='DATAOPS',
        help=
        "The group for creating the clone, if empty it will, use 'DATAOPS' by default"
    )
    parser.add_option(
        "-m",
        "--memory",
        dest="memory",
        help=
        "Set max memory for the clone. At assignment, this will be used to calculate maxRSS = memory*1024"
    )

    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) > 0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: " + workflow + " is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: " + workflow)
        reqMgrClient.invalidateWorkflow(url, workflow, workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, 'INVALID', files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: " + workflow)
            if options.memory:
                mem = options.memory
            else:
                mem = workflowInfo.info["Memory"]
            cloned = resubmit.cloneWorkflow(workflow,
                                            user,
                                            options.group,
                                            memory=mem)
    sys.exit(0)
Exemple #6
0
def main():
    usage = (
        "\n       python %prog [options] [WORKFLOW_NAME]\n"
        "WORKFLOW_NAME: if the list file is provided this should be empty\n"
    )

    parser = OptionParser(usage=usage)
    parser.add_option("-f", "--file", help="Text file of workflows to Reject and Clone", dest="file")
    parser.add_option(
        "-c",
        "--clone",
        help="Are the workflows going to be cloned? The default value is False",
        action="store_true",
        dest="clone",
        default=False,
    )
    parser.add_option(
        "-i",
        "--invalidate",
        help="Invalidate datasets? The default value is False",
        action="store_true",
        dest="invalidate",
        default=False,
    )
    parser.add_option(
        "-u",
        "--user",
        dest="user",
        help="The user for creating the clone, if empty it will use the OS user running the script",
    )
    parser.add_option(
        "-g",
        "--group",
        dest="group",
        default="DATAOPS",
        help="The group for creating the clone, if empty it will, use 'DATAOPS' by default",
    )
    parser.add_option(
        "-m",
        "--memory",
        dest="memory",
        help="Set max memory for the clone. At assignment, this will be used to calculate maxRSS = memory*1024",
    )

    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) > 0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: " + workflow + " is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: " + workflow)
        reqMgrClient.invalidateWorkflow(url, workflow, workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, "INVALID", files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: " + workflow)
            if options.memory:
                mem = float(options.memory)
            else:
                mem = workflowInfo.info["Memory"]
            cloned = resubmit.cloneWorkflow(workflow, user, options.group, memory=mem)
    sys.exit(0)