def add_res_node(resource, parent, idata, rid=None, discard_disabled=False): if discard_disabled and resource.get("disable", False): return ers = get_ers(idata) rid = resource["rid"] node_res = parent.add_node() node_res.add_column(rid) node_res.add_column(fmt_flags(resource, idata)) node_res.add_column(resource["status"], STATUS_COLOR[resource["status"]]) col = node_res.add_column(resource["label"]) if rid in ers and resource["status"] in ("up", "stdby up", "n/a"): edata = Storage(idata["encap"].get(rid)) encap_notice = instance_notice( overall=edata.overall, frozen=edata.frozen, constraints=edata.get("constraints", True), provisioned=edata.provisioned, monitor={}, ) col.add_text(encap_notice, color.LIGHTBLUE) for line in resource.get("log", []): if line.startswith("warn:"): scolor = STATUS_COLOR["warn"] elif line.startswith("error:"): scolor = STATUS_COLOR["err"] else: scolor = None col.add_text(line, scolor) if rid not in ers or resource["status"] not in ("up", "stdby up", "n/a"): return add_subsets(ers[rid], node_res, idata, discard_disabled=discard_disabled)
def add_instance(node, nodename, path, mon_data): node_child = node.add_node() node_child.add_column(nodename, color.BOLD) node_child.add_column() try: data = mon_data["nodes"][nodename]["services"]["status"][path] avail = data.get("avail", "n/a") node_frozen = mon_data["nodes"][nodename].get("frozen") except (TypeError, KeyError) as exc: avail = "undef" node_frozen = False data = Storage() node_child.add_column(avail, STATUS_COLOR[avail]) notice = instance_notice(overall=data.get("overall", "n/a"), frozen=data.get("frozen"), node_frozen=node_frozen, constraints=data.get("constraints", True), provisioned=data.get("provisioned"), monitor=data.get("monitor")) node_child.add_column(notice, color.LIGHTBLUE)