Пример #1
0
def make_default_nodeset():
    '''take the (temporary) DEFAULT_NODESET and expand it to
    the definitive DEFAULT_NODESET
    Return value: none, exit the program on error'''

    temp_set = synctool.param.DEFAULT_NODESET
    synctool.param.DEFAULT_NODESET = set()
    nodeset = synctool.nodeset.NodeSet()
    errors = 0
    for elem in temp_set:
        if elem in synctool.param.NODES:
            nodeset.add_node(elem)
        elif elem in synctool.param.ALL_GROUPS:
            nodeset.add_group(elem)
        else:
            stderr("config error: unknown node or group '%s' "
                   "in default_nodeset" % elem)
            errors += 1

    if not errors:
        if not nodeset.addresses():
            # error message already printed
            errors += 1
        else:
            synctool.param.DEFAULT_NODESET = nodeset.nodelist

    if errors > 0:
        sys.exit(-1)
Пример #2
0
def list_nodes(nodelist):
    '''display node definition'''

    nodeset = synctool.nodeset.NodeSet()
    try:
        nodeset.add_node(nodelist)
    except synctool.range.RangeSyntaxError as err:
        print 'error:', err
        sys.exit(1)

    if nodeset.addresses() == None:
        # error message already printed
        sys.exit(1)

    groups = []

    for node in nodeset.nodelist:
        if OPT_IPADDRESS or OPT_HOSTNAME or OPT_RSYNC:
            out = ''

            if OPT_IPADDRESS:
                out += ' ' + synctool.config.get_node_ipaddress(node)

            if OPT_HOSTNAME:
                out += ' ' + synctool.config.get_node_hostname(node)

            if OPT_RSYNC:
                if node in synctool.param.NO_RSYNC:
                    out += ' no'
                else:
                    out += ' yes'

            print out[1:]

        else:
            for group in synctool.config.get_groups(node):
                # extend groups, but do not have duplicates
                if not group in groups:
                    groups.append(group)

    # group order is important, so don't sort
    # however, when you list multiple nodes at once, the groups will have
    # been added to the end
    # So the order is important, but may be incorrect when listing
    # multiple nodes at once
#    groups.sort()

    for group in groups:
        if OPT_FILTER_IGNORED and group in synctool.param.IGNORE_GROUPS:
            continue

        if group in synctool.param.IGNORE_GROUPS:
            group += ' (ignored)'

        print group
Пример #3
0
def list_nodes(nodelist):
    # type: (str) -> None
    '''display node definition'''

    nodeset = synctool.nodeset.NodeSet()
    try:
        nodeset.add_node(nodelist)
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if nodeset.addresses() is None:
        # error message already printed
        sys.exit(1)

    groups = []  # type: List[str]
    for node in nodeset.nodelist:
        if OPT_IPADDRESS or OPT_RSYNC:
            out = ''
            if OPT_IPADDRESS:
                out += ' ' + config.get_node_ipaddress(node)

            if OPT_RSYNC:
                if node in param.NO_RSYNC:
                    out += ' no'
                else:
                    out += ' yes'

            print out[1:]
        else:
            for group in config.get_groups(node):
                # extend groups, but do not have duplicates
                if group not in groups:
                    groups.append(group)

    # group order is important, so don't sort
    # however, when you list multiple nodes at once, the groups will have
    # been added to the end
    # So the order is important, but may be incorrect when listing
    # multiple nodes at once


#    groups.sort()

    for group in groups:
        if OPT_FILTER_IGNORED and group in param.IGNORE_GROUPS:
            continue

        if group in param.IGNORE_GROUPS:
            group += ' (ignored)'

        print group
Пример #4
0
def expand(nodelist):
    '''display expanded argument'''

    nodeset = synctool.nodeset.NodeSet()
    try:
        nodeset.add_node(nodelist)
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    # don't care if the nodes do not exist

    arr = list(nodeset.nodelist)
    arr.sort()

    for elem in arr:
        print elem,
    print
Пример #5
0
def expand(nodelist):
    '''display expanded argument'''

    nodeset = synctool.nodeset.NodeSet()
    try:
        nodeset.add_node(nodelist)
    except synctool.range.RangeSyntaxError as err:
        print 'error:', err
        sys.exit(1)

    # don't care if the nodes do not exist

    arr = list(nodeset.nodelist)
    arr.sort()

    for elem in arr:
        print elem,
    print