Example #1
0
def update_procs(spec, parser):
    """
    Will update 'proc' according to what system we are running on given the number of nodes
    """
    sysinfo = client_utils.system_info()
    if ((parser.options.nodes is not None or parser.options.mode is not None) and 
            parser.options.procs is None):
        if sysinfo[0] == 'bgq':
            if spec['mode'] == 'script':
                spec['procs'] = spec['nodes']
            else:
                rpn_re  = re.compile(r'c(?P<pos>[0-9]*)')
                mode_size = int(rpn_re.match(spec['mode']).group(1))
                spec['procs'] = spec['nodes'] * mode_size
        else:
            if parser.options.mode == 'vn':
                # set procs to 2 x nodes
                if sysinfo[0] == 'bgl':
                    spec['procs'] = 2 * spec['nodes']
                elif sysinfo[0] == 'bgp':
                    spec['procs'] = 4 * spec['nodes']
                else:
                    client_utils.logger.error("Unknown bgtype %s" % (sysinfo[0]))
                    sys.exit(1)
            else:
                spec['procs'] = spec['nodes']
Example #2
0
def main():
    """
    partlist main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

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

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

    parser = ArgParse(opt_def, callbacks)

    parser.parse_it()  # parse the command line

    if not parser.no_args():
        client_utils.logger.error("No arguments required")
        sys.exit(1)

    sys_info = client_utils.system_info()

    sys_type = sys_info[0]

    if sys_type == 'bgq':
        spec = [{
            'tag': 'partition',
            'name': '*',
            'queue': '*',
            'state': '*',
            'size': '*',
            'functional': '*',
            'scheduled': '*',
            'children': '*',
            'backfill_time': "*",
            'draining': "*",
            'node_geometry': "*"
        }]
    else:
        spec = [{
            'tag': 'partition',
            'name': '*',
            'queue': '*',
            'state': '*',
            'size': '*',
            'functional': '*',
            'scheduled': '*',
            'children': '*',
            'backfill_time': "*",
            'draining': "*"
        }]

    parts = client_utils.component_call(SYSMGR, True, 'get_partitions',
                                        (spec, ))
    reservations = client_utils.component_call(SCHMGR, False,
                                               'get_reservations',
                                               ([{
                                                   'queue': '*',
                                                   'partitions': '*',
                                                   'active': True
                                               }], ))

    expanded_parts = {}
    for res in reservations:
        for res_part in res['partitions'].split(':'):
            for p in parts:
                if p['name'] == res_part:
                    if expanded_parts.has_key(res['queue']):
                        expanded_parts[res['queue']].update(p['children'])
                    else:
                        expanded_parts[res['queue']] = set(p['children'])
                    expanded_parts[res['queue']].add(p['name'])

    for res in reservations:
        for p in parts:
            if p['name'] in expanded_parts.get(res['queue'], []):
                p['queue'] += ":%s" % res['queue']

    def my_cmp(left, right):
        val = -cmp(int(left['size']), int(right['size']))
        if val == 0:
            return cmp(left['name'], right['name'])
        else:
            return val

    parts.sort(my_cmp)
    now = time.time()
    for part in parts:
        if part['draining'] and part['state'] == "idle":
            # remove a little extra, to make sure that users can just type the number
            # that is output by partlist to get their job to backfill
            remaining = max(0, part['backfill_time'] - now - 90)
            hours, seconds = divmod(remaining, 3600.0)
            minutes = seconds / 60.0
            part['backfill'] = "%d:%0.2d" % (int(hours), int(minutes))
        else:
            part['backfill'] = "-"

    if sys_type == 'bgq':
        header = [['Name', 'Queue', 'State', 'Backfill', 'node_geometry']]
        #build output list, adding
        output = [[part.get(x) for x in [y.lower() for y in header[0]]]
                  for part in parts
                  if part['functional'] and part['scheduled']]
        #Hack to make the display cleaner.
        header[0][4] = 'Geometry'
        for o in output:
            if o[4] != None:
                o[4] = 'x'.join([str(i) for i in o[4]])
    else:
        header = [['Name', 'Queue', 'State', 'Backfill']]
        #build output list, adding
        output = [[part.get(x) for x in [y.lower() for y in header[0]]]
                  for part in parts
                  if part['functional'] and part['scheduled']]
    client_utils.printTabular(header + output)
Example #3
0
def main():
    """
    partadm main function.
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    # get the system info
    sysinfo = client_utils.system_info()
    sys_type = sysinfo[0]

    print_block = print_block_bgp
    if sys_type == 'bgq':
        print_block = print_block_bgq

    use_cwd = False
    options = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        [cb_debug, ()],
        [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
    opts = parser.options

    whoami = client_utils.getuid()

    validate_args(parser)
    parts = []

    if parser.options.recursive:
        parts = recursive(args)
    else:
        parts = args

    parts = handle_mux_options(opts, parts, whoami, sys_type)

    # make sure parts is an a list even if it is an empty list
    if parts is None:
        parts = []

    if opts.pg_list:
        print_pg_info(None)
        sys.exit(0)

    if opts.blockinfo:
        handle_blockinfo_option(parts, sys_type, print_block)

    if opts.clean_block:
        handle_clean_block_option(parts, whoami, sys_type)

    if opts.list_blocks:
        handle_list_blocks_option(parts, sys_type)

    elif opts.boot_start or opts.boot_stop or opts.list_io:
        pass

    else:
        client_utils.logger.info(parts)

    if opts.list_io:
        handle_list_io_option(sys_type)
Example #4
0
def main():
    """
    partlist main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

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

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

    parser = ArgParse(opt_def,callbacks)

    parser.parse_it() # parse the command line

    if not parser.no_args():
        client_utils.logger.error("No arguments required")
        sys.exit(1)
    
    sys_info = client_utils.system_info()
    
    sys_type = sys_info[0]

    if sys_type == 'bgq':
        spec = [{'tag':'partition', 'name':'*', 'queue':'*', 'state':'*',
                 'size':'*', 'functional':'*', 'scheduled':'*', 'children':'*',
                 'backfill_time':"*", 'draining':"*",'node_geometry':"*"}]
    else:
        spec = [{'tag':'partition', 'name':'*', 'queue':'*', 'state':'*',
                 'size':'*', 'functional':'*', 'scheduled':'*', 'children':'*',
                 'backfill_time':"*", 'draining':"*"}]

    parts        = client_utils.component_call(SYSMGR, True, 'get_partitions', (spec,))
    reservations = client_utils.component_call(SCHMGR, False, 'get_reservations', 
                                               ([{'queue':'*','partitions':'*','active':True}],))

    expanded_parts = {}
    for res in reservations:
        for res_part in res['partitions'].split(':'):
            for p in parts:
                if p['name'] == res_part:
                    if expanded_parts.has_key(res['queue']):
                        expanded_parts[res['queue']].update(p['children'])
                    else:
                        expanded_parts[res['queue']] = set( p['children'] )
                    expanded_parts[res['queue']].add(p['name'])    
    
    for res in reservations:
        for p in parts:
            if p['name'] in expanded_parts.get(res['queue'], []):
                p['queue'] += ":%s" % res['queue']

    def my_cmp(left, right):
        val = -cmp(int(left['size']), int(right['size']))
        if val == 0:
            return cmp(left['name'], right['name'])
        else:
            return val

    parts.sort(my_cmp)
    now = time.time()
    for part in parts:
        if part['draining'] and part['state'] == "idle":
            # remove a little extra, to make sure that users can just type the number
            # that is output by partlist to get their job to backfill
            remaining = max(0, part['backfill_time'] - now - 90)
            hours, seconds = divmod(remaining, 3600.0)
            minutes = seconds/60.0
            part['backfill'] = "%d:%0.2d" % (int(hours), int(minutes))
        else:
            part['backfill'] = "-"

    if sys_type == 'bgq':
        header = [['Name', 'Queue', 'State', 'Backfill', 'node_geometry']]
        #build output list, adding
        output = [[part.get(x) for x in [y.lower() for y in header[0]]] for part in parts 
                  if part['functional'] and part['scheduled']]
        #Hack to make the display cleaner.
        header[0][4] = 'Geometry'
        for o in output:
            if o[4] != None:
                o[4] = 'x'.join([str(i) for i in o[4]])
    else:
        header = [['Name', 'Queue', 'State', 'Backfill']]
        #build output list, adding
        output = [[part.get(x) for x in [y.lower() for y in header[0]]] for part in parts 
                  if part['functional'] and part['scheduled']]
    client_utils.printTabular(header + output)
Example #5
0
def main():
    """
    partadm main function.
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    # get the system info
    sysinfo  = client_utils.system_info()
    sys_type =  sysinfo[0]

    print_block = print_block_bgp
    if sys_type == 'bgq':
        print_block = print_block_bgq

    use_cwd = False
    options = {}

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        [ cb_debug        , () ],
        [ 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
    opts  = parser.options

    whoami = client_utils.getuid()

    validate_args(parser)
    parts = []

    if parser.options.recursive:
        parts = recursive(args)
    else:
        parts = args

    parts = handle_mux_options(opts, parts, whoami, sys_type)

    # make sure parts is an a list even if it is an empty list
    if parts is None:
        parts = []

    if opts.pg_list:
        print_pg_info(None)
        sys.exit(0)

    if opts.blockinfo:
        handle_blockinfo_option(parts, sys_type, print_block)

    if opts.clean_block:
        handle_clean_block_option(parts, whoami, sys_type)

    if opts.list_blocks:
        handle_list_blocks_option(parts, sys_type)

    elif opts.boot_start or opts.boot_stop or opts.list_io:
        pass

    else:
        client_utils.logger.info(parts)

    if opts.list_io:
        handle_list_io_option(sys_type)