def sanity_check_ops(self, id, ops, default_timeout): ''' ops is a list of operations - do all operations exist - are timeouts sensible ''' rc = 0 n_ops = {} for op in ops: n_op = op[0] == "monitor" and monitor_name_pl(op[1]) or op[0] n_ops[n_op] = {} for p, v in op[1]: if p in self.skip_op_attr: continue n_ops[n_op][p] = v for req_op in self.required_ops: if req_op not in n_ops: if not (self.ra_class == "stonith" and req_op in ("start", "stop")): n_ops[req_op] = {} intervals = {} for op in n_ops: if self.ra_class == "stonith" and op in ("start", "stop"): continue if op not in self.actions(): common_warn("%s: action %s not advertised in meta-data, it may not be supported by the RA" % (id, op)) rc |= 1 if "interval" in n_ops[op]: v = n_ops[op]["interval"] v_msec = crm_msec(v) if op in ("start", "stop") and v_msec != 0: common_warn("%s: Specified interval for %s is %s, it must be 0" % (id, op, v)) rc |= 1 if op.startswith("monitor") and v_msec != 0: if v_msec not in intervals: intervals[v_msec] = 1 else: common_warn("%s: interval in %s must be unique" % (id, op)) rc |= 1 try: adv_timeout = self.actions()[op]["timeout"] except: continue if "timeout" in n_ops[op]: v = n_ops[op]["timeout"] timeout_string = "specified timeout" else: v = default_timeout timeout_string = "default timeout" if crm_msec(v) < 0: continue if crm_time_cmp(adv_timeout, v) > 0: common_warn("%s: %s %s for %s is smaller than the advised %s" % (id, timeout_string, v, op, adv_timeout)) rc |= 1 return rc
def find_operation(rsc_node, name, interval="0"): ''' Setting interval to "non-0" means get the first op with interval different from 0. ''' op_node_l = rsc_node.findall("operations") for ops in op_node_l: for c in ops.iterchildren("op"): if c.get("name") != name: continue if (interval == "non-0" and crm_msec(c.get("interval")) > 0) or \ crm_time_cmp(c.get("interval"), interval) == 0: return c
def find_operation(rsc_node, name, interval=None): ''' Setting interval to "non-0" means get the first op with interval different from 0. Not setting interval at all means get the only matching op, or the 0 op (if any) ''' matching_name = [] for ops in rsc_node.findall("operations"): matching_name.extend( [op for op in ops.iterchildren("op") if op.get("name") == name]) if interval is None and len(matching_name) == 1: return matching_name[0] interval = interval or "0" for op in matching_name: opint = op.get("interval") if interval == "non-0" and crm_msec(opint) > 0: return op if crm_time_cmp(opint, interval) == 0: return op return None
def find_operation(rsc_node, name, interval=None): ''' Setting interval to "non-0" means get the first op with interval different from 0. Not setting interval at all means get the only matching op, or the 0 op (if any) ''' matching_name = [] for ops in rsc_node.findall("operations"): matching_name.extend([op for op in ops.iterchildren("op") if op.get("name") == name]) if interval is None and len(matching_name) == 1: return matching_name[0] interval = interval or "0" for op in matching_name: opint = op.get("interval") if interval == "non-0" and crm_msec(opint) > 0: return op if crm_time_cmp(opint, interval) == 0: return op return None