def do_rsctest(self, context, *args): "usage: rsctest <rsc_id> [<rsc_id> ...] [<node_id> ...]" if not cib_factory.is_cib_sane(): return False rc = True rsc_l = [] node_l = [] current = "r" for ident in args: el = cib_factory.find_object(ident) if not el: common_err("element %s does not exist" % ident) rc = False elif current == "r" and xmlutil.is_resource(el.node): if xmlutil.is_container(el.node): rsc_l += el.node.findall("primitive") else: rsc_l.append(el.node) elif xmlutil.is_normal_node(el.node): current = "n" node_l.append(el.node.get("uname")) else: syntax_err((context.get_command_name(), ident), context='rsctest') return False if not rc: return False if not rsc_l: common_err("specify at least one resource") return False all_nodes = cib_factory.node_id_list() if not node_l: node_l = all_nodes return rsctest.test_resources(rsc_l, node_l, all_nodes)
def do_action(self, context, resource, action, ssh=None): ''' Issue action out-of-band to the given resource, making sure that the resource is in maintenance mode first ''' obj = cib_factory.find_object(resource) if not obj: context.fatal_error("Resource not found: %s" % (resource)) if not xmlutil.is_resource(obj.node): context.fatal_error("Not a resource: %s" % (resource)) if not self._in_maintenance_mode(obj): context.fatal_error("Not in maintenance mode.") if ssh is None: if action not in ('start', 'monitor'): if not self._runs_on_this_node(resource): context.fatal_error("Resource %s must be running on this node (%s)" % (resource, utils.this_node())) import rsctest return rsctest.call_resource(obj.node, action, [utils.this_node()], local_only=True) elif ssh == "ssh": import rsctest if action in ('start', 'promote', 'demote', 'recover', 'meta-data'): return rsctest.call_resource(obj.node, action, [utils.this_node()], local_only=True) else: all_nodes = cib_factory.node_id_list() return rsctest.call_resource(obj.node, action, all_nodes, local_only=False) else: context.fatal_error("Unknown argument: %s" % (ssh))
def do_action(self, context, resource, action, ssh=None): ''' Issue action out-of-band to the given resource, making sure that the resource is in maintenance mode first ''' obj = cib_factory.find_object(resource) if not obj: context.fatal_error("Resource not found: %s" % (resource)) if not xmlutil.is_resource(obj.node): context.fatal_error("Not a resource: %s" % (resource)) if not self._in_maintenance_mode(obj): context.fatal_error("Not in maintenance mode.") if ssh is None: if action not in ('start', 'monitor'): if not self._runs_on_this_node(resource): context.fatal_error( "Resource %s must be running on this node (%s)" % (resource, utils.this_node())) import rsctest return rsctest.call_resource(obj.node, action, [utils.this_node()], local_only=True) elif ssh == "ssh": import rsctest if action in ('start', 'promote', 'demote', 'recover', 'meta-data'): return rsctest.call_resource(obj.node, action, [utils.this_node()], local_only=True) else: all_nodes = cib_factory.node_id_list() return rsctest.call_resource(obj.node, action, all_nodes, local_only=False) else: context.fatal_error("Unknown argument: %s" % (ssh))
def resources(args): cib_el = xmlutil.resources_xml() if cib_el is None: return [] nodes = xmlutil.get_interesting_nodes(cib_el, []) return [x.get("id") for x in nodes if xmlutil.is_resource(x)]
def is_resource(obj): return xmlutil.is_resource(obj.node)