コード例 #1
0
def main():
    """
    qselect main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    opts = {}  # old map
    opt2spec = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>           <cb args>
        [cb_debug, ()],
        [cb_nodes, (False, )],  # return string
        [cb_time, (False, False, False)]
    ]  # no delta time, return minutes, return string

    # 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 for the query:
    query = {
        'tag': 'job',
        'jobid': '*',
        'nodes': '*',
        'walltime': '*',
        'mode': '*',
        'project': '*',
        'state': '*',
        'queue': '*'
    }

    parser.parse_it()  # parse the command line

    if not parser.no_args():
        client_utils.logger.error("qselect takes no arguments")
        sys.exit(1)

    client_utils.get_options(query, opts, opt2spec, parser)
    response = client_utils.component_call(QUEMGR, False, 'get_jobs',
                                           ([query], ))
    if not response:
        client_utils.logger.error("Failed to match any jobs")
    else:
        client_utils.logger.debug(response)
        client_utils.logger.info("   The following jobs matched your query:")
        for job in response:
            client_utils.logger.info("      %d" % job.get('jobid'))
コード例 #2
0
ファイル: nodeadm.py プロジェクト: ido/cobalt
def validate_args(parser):
    """
    Validate nodeadm arguments. 
    """
    spec     = {} # map of destination option strings and parsed values
    opts     = {} # old map
    opt2spec = {}

    opt_count = client_utils.get_options(spec,opts,opt2spec,parser)

    if (parser.no_args() and not parser.options.list_nstates) or opt_count == 0:
        client_utils.print_usage(parser)
        sys.exit(1)

    impl = client_utils.component_call(SYSMGR, False, 'get_implementation', ())

    # make sure we're on a cluster-system
    if impl not in ['cluster_system', 'alps_system']:
        client_utils.logger.error("nodeadm is only supported on cluster systems.  Try partlist instead.")
        sys.exit(0)

    # Check mutually exclusive options
    mutually_exclusive_option_lists = [['down', 'up', 'list_nstates',
        'list_details', 'queue']]

    if opt_count > 1:
        client_utils.validate_conflicting_options(parser, mutually_exclusive_option_lists)
コード例 #3
0
ファイル: nodeadm.py プロジェクト: benmcclelland/cobalt
def validate_args(parser):
    """
    Validate nodeadm arguments. 
    """
    spec = {}  # map of destination option strings and parsed values
    opts = {}  # old map
    opt2spec = {}

    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    if (parser.no_args()
            and not parser.options.list_nstates) or opt_count == 0:
        client_utils.print_usage(parser)
        sys.exit(1)

    impl = client_utils.component_call(SYSMGR, False, 'get_implementation', ())

    # make sure we're on a cluster-system
    if "cluster_system" != impl:
        client_utils.logger.error(
            "nodeadm is only supported on cluster systems.  Try partlist instead."
        )
        sys.exit(0)

    # Check mutually exclusive options
    mutually_exclusive_option_lists = [['down', 'up', 'list_nstates', 'queue']]

    if opt_count > 1:
        client_utils.validate_conflicting_options(
            parser, mutually_exclusive_option_lists)
コード例 #4
0
ファイル: partadm.py プロジェクト: benmcclelland/cobalt-orcm
def validate_args(parser):
    """
    Validate arguments
    """
    spec     = {} 
    opts     = {} 
    opt2spec = {}

    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    if opt_count == 0:
        client_utils.print_usage(parser)
        sys.exit(1)

    opts_wo_args = ['list_blocks', 'xml', 'dump', 'savestate', 'boot_stop', 'boot_start', 'boot_status', 'list_io',
                    'autoboot_start', 'autoboot_stop', 'autoboot_status']

    # Make sure jobid or queue is supplied for the appropriate commands
    if parser.no_args() and not [opt for opt in spec if opt in opts_wo_args]:
        client_utils.logger.error("At least one partition must be supplied")
        sys.exit(1)

    # Check mutually exclusive options
    base_list  = ['add', 'delete', 'enable', 'disable', 'activate', 'deactivate', 'fail', 'unfail', 'xml',
                  'savestate', 'list_blocks', 'dump', 'boot_stop', 'boot_start', 'boot_status']
    list_1  = base_list + ['queue'] 
    list_2  = base_list + ['rmq','appq']
    list_3  = ['pg_list', 'blockinfo','clean_block', 'list_blocks', 'rmq','appq']
    list_4  = ['list_io', 'rmq', 'appq']
    
    mux_option_lists = [list_1, list_2, list_3, list_4]

    if opt_count > 1:
        client_utils.validate_conflicting_options(parser, mux_option_lists)
コード例 #5
0
ファイル: qsub.py プロジェクト: ido/cobalt
def parse_options(parser, spec, opts, opt2spec, def_spec):
    """
    Will initialize the specs and then parse the command line options
    """
    opts.clear()
    for item in def_spec:
        spec[item] = def_spec[item]

    parser.parse_it() # parse the command line
    opt_count               = client_utils.get_options(spec, opts, opt2spec, parser)
    opts['disable_preboot'] = not spec['script_preboot']
    return opt_count
コード例 #6
0
ファイル: qsub.py プロジェクト: samnickolay/cobalt-master
def parse_options(parser, spec, opts, opt2spec, def_spec):
    """
    Will initialize the specs and then parse the command line options
    """
    opts.clear()
    for item in def_spec:
        spec[item] = def_spec[item]

    parser.parse_it()  # parse the command line
    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)
    opts['disable_preboot'] = not spec['script_preboot']
    return opt_count
コード例 #7
0
ファイル: setres.py プロジェクト: benmcclelland/cobalt
def main():
    """
    setres 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_time, (False, True, True)],  # no delta time, Seconds, return int
        [cb_date, (True, )],  # Allow to set the date to 'now'
        [cb_passthrough, ()],
        [cb_debug, ()],
        [cb_res_users, ()]
    ]

    # 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()

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

    # if continue to process options then
    if validate_args(parser, spec, opt_count):

        # modify an existing reservation
        if parser.options.modify_res != None:
            modify_reservation(parser)

        # add new reservation
        else:
            add_reservation(parser, spec, user)
コード例 #8
0
def validate_args(parser):
    """
    Validate arguments
    """
    spec = {}
    opts = {}
    opt2spec = {}

    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    if opt_count == 0:
        client_utils.print_usage(parser)
        sys.exit(1)

    opts_wo_args = [
        'list_blocks', 'xml', 'dump', 'savestate', 'boot_stop', 'boot_start',
        'boot_status', 'list_io', 'autoboot_start', 'autoboot_stop',
        'autoboot_status'
    ]

    # Make sure jobid or queue is supplied for the appropriate commands
    if parser.no_args() and not [opt for opt in spec if opt in opts_wo_args]:
        client_utils.logger.error("At least one partition must be supplied")
        sys.exit(1)

    # Check mutually exclusive options
    base_list = [
        'add', 'delete', 'enable', 'disable', 'activate', 'deactivate', 'fail',
        'unfail', 'xml', 'savestate', 'list_blocks', 'dump', 'boot_stop',
        'boot_start', 'boot_status'
    ]
    list_1 = base_list + ['queue']
    list_2 = base_list + ['rmq', 'appq']
    list_3 = [
        'pg_list', 'blockinfo', 'clean_block', 'list_blocks', 'rmq', 'appq'
    ]
    list_4 = ['list_io', 'rmq', 'appq']

    mux_option_lists = [list_1, list_2, list_3, list_4]

    if opt_count > 1:
        client_utils.validate_conflicting_options(parser, mux_option_lists)
コード例 #9
0
def validate_args(parser, args):
    """
    Validate arguments
    """
    spec = {}
    opts = {}
    opt2spec = {}

    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    if opt_count == 0:
        client_utils.print_usage(parser, "No required options provided")
        sys.exit(1)

    # Make sure jobid or queue is supplied for the appropriate commands
    args_opts = [opt for opt in spec if opt in ['adjust', 'dep_frac']]
    if parser.no_args() and args_opts:
        client_utils.logger.error("At least one jobid must be supplied")
        sys.exit(1)

    elif not parser.no_args():
        if not args_opts:
            client_utils.logger.error("No arguments needed")
        else:
            for i in range(len(args)):
                if args[i] == '*':
                    continue
                try:
                    args[i] = int(args[i])
                except ValueError:
                    client_utils.logger.error(
                        "jobid must be an integer, found '%s'" % args[i])
                    sys.exit(1)

    # Check mutually exclusive options
    mutually_exclusive_option_lists = [[
        'stop', 'start', 'stat', 'reread', 'savestate', 'adjust'
    ], ['stop', 'start', 'stat', 'reread', 'savestate', 'dep_frac']]

    if opt_count > 1:
        client_utils.validate_conflicting_options(
            parser, mutually_exclusive_option_lists)
コード例 #10
0
ファイル: setres.py プロジェクト: ido/cobalt
def main():
    """
    setres 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_time                , (False, True, True) ], # no delta time, Seconds, return int
        [ cb_date                , (True,) ], # Allow to set the date to 'now'
        [ cb_passthrough         , () ],
        [ cb_debug               , () ],
        [ cb_res_users           , () ]] 

    # 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()

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

    # if continue to process options then
    if validate_args(parser,spec,opt_count):

        # modify an existing reservation
        if parser.options.modify_res != None:
            modify_reservation(parser)
        
        # add new reservation
        else:
            add_reservation(parser,spec,user)
コード例 #11
0
ファイル: cqadm.py プロジェクト: samnickolay/cobalt-master
def main():
    """
    cqadm main function.
    """
    # 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 (tuple) >
        (cb_debug, ()),
        (cb_gtzero, (True, )),  # return int
        (cb_time, (False, False,
                   False)),  # no delta time, minutes, return string
        (cb_path, (opts, False)),  # do not use CWD
        (cb_setqueues, ()),
        (cb_hold, ())
    ]

    # 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)

    jobs = validate_args(parser, spec, opt_count)

    process_cqadm_options(jobs, parser, spec, user)
コード例 #12
0
ファイル: schedctl.py プロジェクト: benmcclelland/cobalt-orcm
def validate_args(parser, args):
    """
    Validate arguments
    """
    spec     = {} 
    opts     = {} 
    opt2spec = {}
    
    opt_count = client_utils.get_options(spec, opts, opt2spec, parser)

    if opt_count == 0:
        client_utils.print_usage(parser, "No required options provided")
        sys.exit(1)

    # Make sure jobid or queue is supplied for the appropriate commands
    args_opts =  [opt for opt in spec if opt in ['adjust','dep_frac']]
    if parser.no_args() and args_opts:
        client_utils.logger.error("At least one jobid must be supplied")
        sys.exit(1)

    elif not parser.no_args():
        if not args_opts:
            client_utils.logger.error("No arguments needed")
        else:
            for i in range(len(args)):
                if args[i] == '*':
                    continue
                try:
                    args[i] = int(args[i])
                except ValueError:
                    client_utils.logger.error("jobid must be an integer, found '%s'" % args[i])
                    sys.exit(1)

    # Check mutually exclusive options
    mutually_exclusive_option_lists = [['stop', 'start', 'stat', 'reread', 'savestate', 'adjust'],
                                       ['stop', 'start', 'stat', 'reread', 'savestate', 'dep_frac']]

    if opt_count > 1:
        client_utils.validate_conflicting_options(parser, mutually_exclusive_option_lists)
コード例 #13
0
ファイル: cqadm.py プロジェクト: ido/cobalt
def main():
    """
    cqadm main function.
    """
    # 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 (tuple) >
        (cb_debug, ()),
        (cb_gtzero, (True,)),  # return int
        (cb_time, (False, False, False)),  # no delta time, minutes, return string
        (cb_path, (opts, False)),  # do not use CWD
        (cb_setqueues, ()),
        (cb_hold, ()),
    ]

    # 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)

    jobs = validate_args(parser, spec, opt_count)

    process_cqadm_options(jobs, parser, spec, user)
コード例 #14
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)