def do_trace(self, context, rsc_id, op, interval=None): 'usage: trace <rsc> <op> [<interval>]' rsc = self._get_trace_rsc(rsc_id) if not rsc: return False if not interval: interval = op == "monitor" and "non-0" or "0" if op == "probe": op = "monitor" op_node = xmlutil.find_operation(rsc.node, op, interval) if op_node is None and utils.crm_msec(interval) != 0: common_err("not allowed to create non-0 interval operation %s" % op) return False if op_node is None: head_pl = ["op", []] head_pl[1].append(["name", op]) head_pl[1].append(["interval", interval]) head_pl[1].append([vars.trace_ra_attr, "1"]) cli_list = [] cli_list.append(head_pl) if not rsc.add_operation(cli_list): return False else: op_node = rsc.set_op_attr(op_node, vars.trace_ra_attr, "1") if not cib_factory.commit(): return False if op == "monitor" and utils.crm_msec(interval) != 0: common_warn("please CLEANUP the RA trace directory %s regularly!" % config.path.heartbeat_dir) else: common_info("restart %s to get the trace" % rsc_id) return True
def _trace_op_interval(self, context, rsc_id, rsc, op, interval): op_node = xmlutil.find_operation(rsc.node, op, interval) if op_node is None and utils.crm_msec(interval) != 0: context.err("Operation %s with interval %s not found in %s" % (op, interval, rsc_id)) if op_node is None: if not self._add_trace_op(rsc, op, interval): context.err("Failed to add trace for %s:%s" % (rsc_id, op)) else: rsc.set_op_attr(op_node, constants.trace_ra_attr, "1")
def _trace_op_interval(self, context, rsc_id, rsc, op, interval): op_node = xmlutil.find_operation(rsc.node, op, interval) if op_node is None and utils.crm_msec(interval) != 0: context.fatal_error("Operation %s with interval %s not found in %s" % (op, interval, rsc_id)) if op_node is None: if not self._add_trace_op(rsc, op, interval): context.fatal_error("Failed to add trace for %s:%s" % (rsc_id, op)) else: rsc.set_op_attr(op_node, constants.trace_ra_attr, "1")
def do_untrace(self, context, rsc_id, op, interval=None): 'usage: untrace <rsc> <op> [<interval>]' rsc = self._get_trace_rsc(rsc_id) if not rsc: return False if not interval: interval = op == "monitor" and "non-0" or "0" if op == "probe": op = "monitor" op_node = xmlutil.find_operation(rsc.node, op, interval) if op_node is None: common_err("operation %s does not exist in %s" % (op, rsc.obj_id)) return False op_node = rsc.del_op_attr(op_node, vars.trace_ra_attr) if rsc.is_dummy_operation(op_node): rsc.del_operation(op_node) return cib_factory.commit()
def do_untrace(self, context, rsc_id, op=None, interval=None): 'usage: untrace <rsc> [<op>] [<interval>]' rsc = self._get_trace_rsc(rsc_id) if not rsc: return False if op == "probe": op = "monitor" if op is None: n = 0 for tn in rsc.node.xpath('.//*[@%s]' % (constants.trace_ra_attr)): self._remove_trace(rsc, tn) n += 1 for tn in rsc.node.xpath('.//*[@name="%s"]' % (constants.trace_ra_attr)): if tn.getparent().getparent().tag == 'op': self._remove_trace(rsc, tn.getparent().getparent()) n += 1 else: op_node = xmlutil.find_operation(rsc.node, op, interval=interval) if op_node is None: common_err("operation %s does not exist in %s" % (op, rsc.obj_id)) return False self._remove_trace(rsc, op_node) return cib_factory.commit()