def rsc_set_constraint(node, obj_type): col = [] cnt = 0 for n in node.findall("resource_set"): sequential = boolean_maybe(n.get("sequential")) require_all = boolean_maybe(n.get("require-all")) if require_all is False: col.append("[") elif sequential is False: col.append("(") role = n.get("role") action = n.get("action") for r in n.findall("resource_ref"): rsc = clidisplay.rscref(r.get("id")) q = (obj_type == "order") and action or role col.append(q and "%s:%s" % (rsc, q) or rsc) cnt += 1 if require_all is False: if sequential in (None, True): col.append(nvpair_format('sequential', 'true')) col.append("]") elif sequential is False: if require_all is False: col.append(nvpair_format('require-all', 'false')) col.append(")") is_ticket = obj_type == 'rsc_ticket' is_location = obj_type == 'location' is_seq_all = sequential in (None, True) and require_all in (None, True) if not is_location and ((is_seq_all and not is_ticket and cnt <= 2) or (is_ticket and cnt <= 1)): # a degenerate thingie col.insert(0, "_rsc_set_") return col
def mkrscaction(node, n): rsc = clidisplay.rscref(node.get(n)) rsc_action = node.get(n + "-action") rsc_instance = node.get(n + "-instance") if rsc_action: return "%s:%s" % (rsc, rsc_action) elif rsc_instance: return "%s:%s" % (rsc, rsc_instance) else: return rsc
def mkrscrole(node, n): rsc = clidisplay.rscref(node.get(n)) rsc_role = node.get(n + "-role") rsc_instance = node.get(n + "-instance") if rsc_role: return "%s:%s" % (rsc, rsc_role) elif rsc_instance: return "%s:%s" % (rsc, rsc_instance) else: return rsc