def main():
    """
    schedctl main function.
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    use_cwd = False
    options = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        [ cb_debug        , () ],
        [ cb_score        , () ],
        [ cb_path         , (options, use_cwd) ] ]

    # Get the version information
    opt_def =  __doc__.replace('__revision__', __revision__)
    opt_def =  opt_def.replace('__version__', __version__)

    parser = ArgParse(opt_def, callbacks)

    # Set required default values: None

    parser.parse_it() # parse the command line
    args  = parser.args
    opt   = parser.options

    whoami = client_utils.getuid()

    validate_args(parser, args)

    if opt.stop != None:
        client_utils.component_call(SCHMGR, False, 'disable', (whoami,))
        client_utils.logger.info("Job Scheduling: DISABLED")
        sys.exit(0)
    elif opt.start != None:
        client_utils.component_call(SCHMGR, False, 'enable', (whoami,))
        client_utils.logger.info("Job Scheduling: ENABLED")
        sys.exit(0)
    elif opt.stat != None:
        if client_utils.component_call(SCHMGR, False, 'sched_status', ()):
            client_utils.logger.info("Job Scheduling: ENABLED")
        else:
            client_utils.logger.info("Job Scheduling: DISABLED")
        sys.exit(0)
    elif opt.reread != None:
        client_utils.logger.info("Attempting to reread utility functions.")
        client_utils.component_call(QUEMGR, False, 'define_user_utility_functions', (whoami,))
        sys.exit(0)
    elif opt.savestate != None:
        response = client_utils.component_call(SCHMGR, False, 'save', (opt.savestate,))
        client_utils.logger.info(response)
        sys.exit(0)

    if opt.adjust != None:
        client_utils.set_scores(opt.adjust, args, whoami)

    if opt.dep_frac != None:
        specs = [{'jobid':jobid} for jobid in args]
        response = client_utils.component_call(QUEMGR, False, 'set_jobs', (specs, {"dep_frac": opt.dep_frac}, whoami))

        if not response:
            client_utils.logger.info("no jobs matched")
        else:
            dumb = [str(r["jobid"]) for r in response]
            client_utils.logger.info("updating inheritance fraction for jobs: %s" % ", ".join(dumb))
Exemple #2
0
def main():
    """
    qalter main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    spec     = {} # map of destination option strings and parsed values
    opts     = {} # old map
    opt2spec = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>           <cb args>
        [ cb_debug               , () ],
        [ cb_gtzero              , (True,) ], # return int
        [ cb_nodes               , (True,) ], # return int
        [ cb_time                , (True, False, False) ], # delta time allowed, return minutes, return string
        [ cb_upd_dep             , () ],
        [ cb_attrs               , () ],
        [ cb_user_list           , (opts,) ],
        [ cb_geometry            , (opts,) ],
        [ cb_mode                , () ]]

    # Get the version information
    opt_def =  __doc__.replace('__revision__', __revision__)
    opt_def =  opt_def.replace('__version__', __version__)

    parser = ArgParse(opt_def, callbacks)

    user = client_utils.getuid()

    # Set required default values: None

    parser.parse_it() # parse the command line
    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    # if run_project set then set run users to current user
    if parser.options.run_project != None:
        spec['user_list'] = [user]

    jobids  = validate_args(parser, opt_count)
    filters = client_utils.get_filters()

    jobdata = get_jobdata(jobids, parser, user)

    if parser.options.defer != None:
        client_utils.set_scores(0, jobids, user)
        if opt_count == 1:
            return

    response = []
    # for every job go update the spec info
    for job in jobdata:
        # append the parsed spec to the updates list
        new_spec          = spec.copy()
        new_spec['jobid'] = job['jobid']
        if parser.options.walltime is not None:
            update_time(job, new_spec, parser)
        if parser.options.nodes is not None or parser.options.mode is not None:
            if parser.options.nodes is None:
                new_spec['nodes'] = job['nodes']
            if parser.options.mode is None:
                new_spec['mode'] = job['mode']
            update_procs(new_spec, parser)
        if parser.options.geometry is not None:
            client_utils.validate_geometry(opts['geometry'], job['nodes'])

        del job['is_active']
        orig_job = job.copy()
        job.update(new_spec)

        client_utils.process_filters(filters, job)
        response = client_utils.component_call(QUEMGR, False, 'set_jobs', ([orig_job], job, user))
        do_some_logging(job, orig_job, parser)

    if not response:
        client_utils.logger.error("Failed to match any jobs or queues")
    else:
        client_utils.logger.debug(response)
Exemple #3
0
def main():
    """
    schedctl main function.
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    use_cwd = False
    options = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        [cb_debug, ()],
        [cb_score, ()],
        [cb_path, (options, use_cwd)]
    ]

    # Get the version information
    opt_def = __doc__.replace('__revision__', __revision__)
    opt_def = opt_def.replace('__version__', __version__)

    parser = ArgParse(opt_def, callbacks)

    # Set required default values: None

    parser.parse_it()  # parse the command line
    args = parser.args
    opt = parser.options

    whoami = client_utils.getuid()

    validate_args(parser, args)

    if opt.stop != None:
        client_utils.component_call(SCHMGR, False, 'disable', (whoami, ))
        client_utils.logger.info("Job Scheduling: DISABLED")
        sys.exit(0)
    elif opt.start != None:
        client_utils.component_call(SCHMGR, False, 'enable', (whoami, ))
        client_utils.logger.info("Job Scheduling: ENABLED")
        sys.exit(0)
    elif opt.stat != None:
        if client_utils.component_call(SCHMGR, False, 'sched_status', ()):
            client_utils.logger.info("Job Scheduling: ENABLED")
        else:
            client_utils.logger.info("Job Scheduling: DISABLED")
        sys.exit(0)
    elif opt.reread != None:
        client_utils.logger.info("Attempting to reread utility functions.")
        client_utils.component_call(QUEMGR, False,
                                    'define_user_utility_functions',
                                    (whoami, ))
        sys.exit(0)
    elif opt.savestate != None:
        response = client_utils.component_call(SCHMGR, False, 'save',
                                               (opt.savestate, ))
        client_utils.logger.info(response)
        sys.exit(0)

    if opt.adjust != None:
        client_utils.set_scores(opt.adjust, args, whoami)

    if opt.dep_frac != None:
        specs = [{'jobid': jobid} for jobid in args]
        response = client_utils.component_call(QUEMGR, False, 'set_jobs',
                                               (specs, {
                                                   "dep_frac": opt.dep_frac
                                               }, whoami))

        if not response:
            client_utils.logger.info("no jobs matched")
        else:
            dumb = [str(r["jobid"]) for r in response]
            client_utils.logger.info(
                "updating inheritance fraction for jobs: %s" % ", ".join(dumb))