Exemplo n.º 1
0
def list_sets(args):
    log.debug("entering list_sets, args=%s", args)
    l = []
    if isinstance(args, list):
        for s in args:
            if isinstance(s, str):
                l.extend(cset.find_sets(s))
            elif not isinstance(s, cset.CpuSet):
                raise CpusetException(
                    'list_sets() args=%s, of which "%s" not a string or CpuSet'
                    % (args, s))
            else:
                l.append(s)
    else:
        if isinstance(args, str):
            l.extend(cset.find_sets(args))
        elif not isinstance(args, cset.CpuSet):
            raise CpusetException(
                "list_sets() passed args=%s, which is not a string or CpuSet" %
                args)
        else:
            l.append(args)
    if len(l) == 0:
        raise CpusetException("cpuset(s) to list not specified")
    for s in l:
        if len(s.tasks) > 0:
            if verbose:
                log_detailed_task_table(s, ' ')
            else:
                log_detailed_task_table(s, ' ', 78)
        else:
            log.info(cset.summary(s))
Exemplo n.º 2
0
def list_sets(args):
    log.debug("entering list_sets, args=%s", args)
    l = []
    if isinstance(args, list):
        for s in args: 
            if isinstance(s, str):
                l.extend(cset.find_sets(s))
            elif not isinstance(s, cset.CpuSet):
                raise CpusetException(
                        'list_sets() args=%s, of which "%s" not a string or CpuSet' 
                        % (args, s))
            else:
                l.append(s)
    else:
        if isinstance(args, str):
            l.extend(cset.find_sets(args))
        elif not isinstance(args, cset.CpuSet):
            raise CpusetException(
                    "list_sets() passed args=%s, which is not a string or CpuSet" % args)
        else:
            l.append(args)
    if len(l) == 0:
        raise CpusetException("cpuset(s) to list not specified");
    for s in l:
        if len(s.tasks) > 0:
            if verbose:
                log_detailed_task_table(s, ' ')
            else:
                log_detailed_task_table(s, ' ', 78)
        else:
            log.info(cset.summary(s))
Exemplo n.º 3
0
def list_sets(tset, recurse=None, usehex=False):
    """list cpusets specified in tset as cpuset or list of cpusets, recurse if true"""
    log.debug('entering list_sets, tset=%s recurse=%s', tset, recurse)
    sl = []
    if isinstance(tset, list):
        for s in tset:
            sl.extend(cset.find_sets(s))
    else:
        sl.extend(cset.find_sets(tset))
    log.debug('total unique sets in passed tset: %d', len(sl))
    sl2 = []
    for s in sl:
        sl2.append(s)
        if len(s.subsets) > 0:
            sl2.extend(s.subsets)
        if recurse:
            for node in s.subsets:
                for nd in cset.walk_set(node):
                    sl2.append(nd)
    sl = sl2
    if config.mread:
        pl = ['cpuset_list_start']
    else:
        pl = ['']
        pl.extend(set_header(' '))

    for s in sl:
        if verbose:
            pl.append(set_details(s, ' ', None, usehex))
        else:
            pl.append(set_details(s, ' ', 78, usehex))

    if config.mread:
        pl.append('cpuset_list_end')
    log.info("\n".join(pl))
Exemplo n.º 4
0
def list_sets(tset, recurse=None, usehex=False):
    """list cpusets specified in tset as cpuset or list of cpusets, recurse if true"""
    log.debug('entering list_sets, tset=%s recurse=%s', tset, recurse)
    sl = []
    if isinstance(tset, list):
        for s in tset: sl.extend(cset.find_sets(s))
    else:
        sl.extend(cset.find_sets(tset))
    log.debug('total unique sets in passed tset: %d', len(sl))
    sl2 = []
    for s in sl:
        sl2.append(s)
        if len(s.subsets) > 0:
            sl2.extend(s.subsets)
        if recurse:
            for node in s.subsets:
                for nd in cset.walk_set(node):
                    sl2.append(nd)
    sl = sl2
    if config.mread:
        pl = ['cpuset_list_start']
    else:
        pl = ['']
        pl.extend(set_header(' '))

    for s in sl:
        if verbose:
            pl.append(set_details(s,' ', None, usehex))
        else:
            pl.append(set_details(s,' ', 78, usehex))

    if config.mread:
        pl.append('cpuset_list_end')
    log.info("\n".join(pl))
Exemplo n.º 5
0
 def test_walk_set(self):
     # no special checking ATM
     self.assertEqual(type(cset.unique_set("root")), cset.CpuSet)
     root_set = cset.find_sets("/")
     for node in root_set:
         for x in cset.walk_set(node):
             self.assertEqual(type(x), cset.CpuSet)