def acl_cmd(argv): if len(argv) == 0: argv = ["show"] sub_cmd = argv.pop(0) # If we're using help or show we don't upgrade, otherwise upgrade if necessary if sub_cmd not in ["help","show"]: utils.checkAndUpgradeCIB(2,0,0) if (sub_cmd == "help"): usage.acl(argv) elif (sub_cmd == "show"): acl_show(argv) # elif (sub_cmd == "grant"): # acl_grant(argv) elif (sub_cmd == "enable"): acl_enable(argv) elif (sub_cmd == "disable"): acl_disable(argv) elif (sub_cmd == "role"): acl_role(argv) elif (sub_cmd == "target" or sub_cmd == "user"): acl_target(argv) elif sub_cmd == "group": acl_target(argv, True) elif sub_cmd == "permission": acl_permission(argv) else: usage.acl() sys.exit(1)
def acl_cmd(argv): if len(argv) == 0: argv = ["show"] sub_cmd = argv.pop(0) # If we're using help or show we don't upgrade, otherwise upgrade if necessary if sub_cmd not in ["help", "show"]: utils.checkAndUpgradeCIB(2, 0, 0) if (sub_cmd == "help"): usage.acl(argv) elif (sub_cmd == "show"): acl_show(argv) # elif (sub_cmd == "grant"): # acl_grant(argv) elif (sub_cmd == "enable"): acl_enable(argv) elif (sub_cmd == "disable"): acl_disable(argv) elif (sub_cmd == "role"): acl_role(argv) elif (sub_cmd == "target" or sub_cmd == "user"): acl_target(argv) elif sub_cmd == "group": acl_target(argv, True) elif sub_cmd == "permission": acl_permission(argv) else: usage.acl() sys.exit(1)
def location_rule(argv): if len(argv) < 3: usage.constraint(["location", "rule"]) sys.exit(1) res_name = argv.pop(0) resource_valid, resource_error, correct_id \ = utils.validate_constraint_resource(utils.get_cib_dom(), res_name) if "--autocorrect" in utils.pcs_options and correct_id: res_name = correct_id elif not resource_valid: utils.err(resource_error) argv.pop(0) # pop "rule" options, rule_argv = rule_utils.parse_argv(argv, { "constraint-id": None, "resource-discovery": None, }) # If resource-discovery is specified, we use it with the rsc_location # element not the rule if "resource-discovery" in options and options["resource-discovery"]: utils.checkAndUpgradeCIB(2, 2, 0) cib, constraints = getCurrentConstraints(utils.get_cib_dom()) lc = cib.createElement("rsc_location") lc.setAttribute("resource-discovery", options.pop("resource-discovery")) else: cib, constraints = getCurrentConstraints(utils.get_cib_dom()) lc = cib.createElement("rsc_location") constraints.appendChild(lc) if options.get("constraint-id"): id_valid, id_error = utils.validate_xml_id(options["constraint-id"], 'constraint id') if not id_valid: utils.err(id_error) if utils.does_id_exist(cib, options["constraint-id"]): utils.err("id '%s' is already in use, please specify another one" % options["constraint-id"]) lc.setAttribute("id", options["constraint-id"]) del options["constraint-id"] else: lc.setAttribute("id", utils.find_unique_id(cib, "location-" + res_name)) lc.setAttribute("rsc", res_name) rule_utils.dom_rule_add(lc, options, rule_argv) location_rule_check_duplicates(constraints, lc) utils.replace_cib_configuration(cib)
def location_rule(argv): if len(argv) < 3: usage.constraint(["location", "rule"]) sys.exit(1) res_name = argv.pop(0) resource_valid, resource_error, correct_id \ = utils.validate_constraint_resource(utils.get_cib_dom(), res_name) if "--autocorrect" in utils.pcs_options and correct_id: res_name = correct_id elif not resource_valid: utils.err(resource_error) argv.pop(0) # pop "rule" options, rule_argv = rule_utils.parse_argv(argv, {"constraint-id": None, "resource-discovery": None,}) # If resource-discovery is specified, we use it with the rsc_location # element not the rule if "resource-discovery" in options and options["resource-discovery"]: utils.checkAndUpgradeCIB(2,2,0) cib, constraints = getCurrentConstraints(utils.get_cib_dom()) lc = cib.createElement("rsc_location") lc.setAttribute("resource-discovery", options.pop("resource-discovery")) else: cib, constraints = getCurrentConstraints(utils.get_cib_dom()) lc = cib.createElement("rsc_location") constraints.appendChild(lc) if options.get("constraint-id"): id_valid, id_error = utils.validate_xml_id( options["constraint-id"], 'constraint id' ) if not id_valid: utils.err(id_error) if utils.does_id_exist(cib, options["constraint-id"]): utils.err( "id '%s' is already in use, please specify another one" % options["constraint-id"] ) lc.setAttribute("id", options["constraint-id"]) del options["constraint-id"] else: lc.setAttribute("id", utils.find_unique_id(cib, "location-" + res_name)) lc.setAttribute("rsc", res_name) rule_utils.dom_rule_add(lc, options, rule_argv) location_rule_check_duplicates(constraints, lc) utils.replace_cib_configuration(cib)