Esempio n. 1
0
def list_property(argv):
    print_all = False
    if len(argv) == 0:
        print_all = True

    if "--all" in utils.pcs_options or "--defaults" in utils.pcs_options:
        if len(argv) != 0:
            utils.err("you cannot specify a property when using --all or --defaults")
        properties = get_default_properties()
    else:
        properties = {}

    if "--defaults" not in utils.pcs_options:
        (output, retVal) = utils.run(["cibadmin", "-Q", "--scope", "crm_config"])
        if retVal != 0:
            utils.err("unable to get crm_config\n" + output)
        dom = parseString(output)
        de = dom.documentElement
        crm_config_properties = de.getElementsByTagName("nvpair")
        for prop in crm_config_properties:
            if print_all == True or (argv[0] == prop.getAttribute("name")):
                properties[prop.getAttribute("name")] = prop.getAttribute("value")

    print "Cluster Properties:"
    for prop, val in sorted(properties.iteritems()):
        print " " + prop + ": " + val

    node_attributes = utils.get_node_attributes()
    if node_attributes:
        print "Node Attributes:"
        for node in sorted(node_attributes):
            print " " + node + ":",
            for attr in node_attributes[node]:
                print attr,
            print
Esempio n. 2
0
File: prop.py Progetto: tradej/pcs
def list_property(argv):
    print_all = False
    if len(argv) == 0:
        print_all = True

    if "--all" in utils.pcs_options or "--defaults" in utils.pcs_options:
        if len(argv) != 0:
            utils.err("you cannot specify a property when using --all or --defaults")
        properties = get_default_properties()
    else:
        properties = {}
        
    if "--defaults" not in utils.pcs_options:
        properties = get_set_properties(
            None if print_all else argv[0],
            properties
        )

    print("Cluster Properties:")
    for prop,val in sorted(properties.items()):
        print(" " + prop + ": " + val)

    node_attributes = utils.get_node_attributes()
    if node_attributes:
        print("Node Attributes:")
        for node in sorted(node_attributes):
            print(" " + node + ":", end=' ')
            for attr in node_attributes[node]:
                print(attr, end=' ')
            print()
Esempio n. 3
0
def list_property(argv):
    print_all = False
    if len(argv) == 0:
        print_all = True

    if "--all" in utils.pcs_options or "--defaults" in utils.pcs_options:
        if len(argv) != 0:
            utils.err("you cannot specify a property when using --all or --defaults")
        properties = get_default_properties()
    else:
        properties = {}
        
    if "--defaults" not in utils.pcs_options:
        (output, retVal) = utils.run(["cibadmin","-Q","--scope", "crm_config"])
        if retVal != 0:
            utils.err("unable to get crm_config\n"+output)
        dom = parseString(output)
        de = dom.documentElement
        crm_config_properties = de.getElementsByTagName("nvpair")
        for prop in crm_config_properties:
            if print_all == True or (argv[0] == prop.getAttribute("name")):
                properties[prop.getAttribute("name")] = prop.getAttribute("value")

    print "Cluster Properties:"
    for prop,val in sorted(properties.iteritems()):
        print " " + prop + ": " + val

    node_attributes = utils.get_node_attributes()
    if node_attributes:
        print "Node Attributes:"
        for node in sorted(node_attributes):
            print " " + node + ":",
            for attr in node_attributes[node]:
                print attr,
            print