Beispiel #1
0
def unset_property(argv):
    if len(argv) < 1:
        usage.property()
        sys.exit(1)

    for arg in argv:
        utils.set_cib_property(arg, "")
Beispiel #2
0
def set_property(argv):
    for arg in argv:
        args = arg.split('=')
        if (len(args) != 2):
            print "Invalid Property: " + arg
            continue
        utils.set_cib_property(args[0],args[1])
Beispiel #3
0
def unset_property(argv):
    if len(argv) < 1:
        usage.property()
        sys.exit(1)

    for arg in argv:
        utils.set_cib_property(arg, "")
Beispiel #4
0
def set_property(argv):
    for arg in argv:
        args = arg.split('=')
        if (len(args) != 2):
            print "Invalid Property: " + arg
            continue
        utils.set_cib_property(args[0], args[1])
Beispiel #5
0
def set_property(argv):
    for arg in argv:
        args = arg.split('=')
        if (len(args) != 2):
            print "Invalid Property: " + arg
            continue
        if ("--force" in utils.pcs_options) or utils.is_valid_property(args[0]):
            utils.set_cib_property(args[0],args[1])
        else:
            utils.err("unknown cluster property: '%s', (use --force to override)" % args[0])
Beispiel #6
0
def unset_property(argv):
    if len(argv) < 1:
        usage.property()
        sys.exit(1)

    if "--node" in utils.pcs_options:
        for arg in argv:
            utils.set_node_attribute(arg, "",utils.pcs_options["--node"])
    else:
        for arg in argv:
            utils.set_cib_property(arg, "")
Beispiel #7
0
def set_property(argv):
    for arg in argv:
        args = arg.split("=")
        if len(args) != 2:
            print "Invalid Property: " + arg
            continue
        if "--node" in utils.pcs_options:
            utils.set_node_attribute(args[0], args[1], utils.pcs_options["--node"])
        elif ("--force" in utils.pcs_options) or utils.is_valid_property(args[0]):
            utils.set_cib_property(args[0], args[1])
        else:
            utils.err("unknown cluster property: '%s', (use --force to override)" % args[0])
Beispiel #8
0
def unset_property(argv):
    if len(argv) < 1:
        usage.property()
        sys.exit(1)

    if "--node" in utils.pcs_options:
        for arg in argv:
            utils.set_node_attribute(arg, "",utils.pcs_options["--node"])
    else:
        cib_dom = utils.get_cib_dom()
        for arg in argv:
            utils.set_cib_property(arg, "", cib_dom)
        utils.replace_cib_configuration(cib_dom)
Beispiel #9
0
def set_property(argv):
    for arg in argv:
        args = arg.split('=')
        if (len(args) != 2):
            print("Invalid Property: " + arg)
            continue
        if "--node" in utils.pcs_options:
            utils.set_node_attribute(args[0], args[1], utils.pcs_options["--node"])
        elif ("--force" in utils.pcs_options) or utils.is_valid_property(args[0]):
            if not args[0]:
                utils.err("property name cannot be empty")
            utils.set_cib_property(args[0],args[1])
        else:
            utils.err("unknown cluster property: '%s', (use --force to override)" % args[0])
Beispiel #10
0
def set_property(argv):
    for arg in argv:
        args = arg.split('=')
        if (len(args) != 2):
            print "Invalid Property: " + arg
            continue
        if "--node" in utils.pcs_options:
            utils.set_node_attribute(args[0], args[1], utils.pcs_options["--node"])
        elif ("--force" in utils.pcs_options) or utils.is_valid_property(args[0]):
            id_valid, id_error = utils.validate_xml_id(args[0], 'property name')
            if not id_valid:
                utils.err(id_error)
            utils.set_cib_property(args[0],args[1])
        else:
            utils.err("unknown cluster property: '%s', (use --force to override)" % args[0])
Beispiel #11
0
def set_property(argv):
    prop_def_dict = utils.get_cluster_properties_definition()
    nodes_attr = "--node" in utils.pcs_options
    failed = False
    forced = "--force" in utils.pcs_options
    properties = {}
    for arg in argv:
        args = arg.split('=')
        if len(args) != 2:
            utils.err("invalid property format: '{0}'".format(arg), False)
            failed = True
        elif not args[0]:
            utils.err("empty property name: '{0}'".format(arg), False)
            failed = True
        elif nodes_attr or forced or args[1].strip() == "":
            properties[args[0]] = args[1]
        else:
            try:
                if utils.is_valid_cluster_property(
                    prop_def_dict, args[0], args[1]
                ):
                    properties[args[0]] = args[1]
                else:
                    utils.err(
                        "invalid value of property: '{0}', (use --force to "
                        "override)".format(arg),
                        False
                    )
                    failed = True
            except utils.UnknownPropertyException:
                utils.err(
                    "unknown cluster property: '{0}', (use --force to "
                    "override)".format(args[0]),
                    False
                )
                failed = True

    if failed:
        sys.exit(1)

    if nodes_attr:
        for prop, value in properties.items():
            utils.set_node_attribute(prop, value, utils.pcs_options["--node"])
    else:
        cib_dom = utils.get_cib_dom()
        for prop, value in properties.items():
            utils.set_cib_property(prop, value, cib_dom)
        utils.replace_cib_configuration(cib_dom)