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)
def property_cmd(argv): if len(argv) == 0: argv = ["list"] sub_cmd = argv.pop(0) if sub_cmd == "help": usage.property(argv) elif sub_cmd == "set": set_property(argv) elif sub_cmd == "unset": unset_property(argv) elif sub_cmd == "list" or sub_cmd == "show": list_property(argv) elif sub_cmd == "get_cluster_properties_definition": print(json.dumps(utils.get_cluster_properties_definition())) else: usage.property() sys.exit(1)
def get_default_properties(): parameters = {} prop_def_dict = utils.get_cluster_properties_definition() for name, prop in prop_def_dict.items(): parameters[name] = prop["default"] return parameters