def test_no_match_in_obj_ref(self): with self.assertRaises(lib.ElementNotFound): lib.get_element_by_id(cib_element_lookup, "RX1")
def create_in_group( env: LibraryEnvironment, stonith_id: str, stonith_agent_name: str, group_id: str, operations: Iterable[Mapping[str, str]], meta_attributes: Mapping[str, str], instance_attributes: Mapping[str, str], allow_absent_agent: bool = False, allow_invalid_operation: bool = False, allow_invalid_instance_attributes: bool = False, use_default_operations: bool = True, ensure_disabled: bool = False, adjacent_resource_id: Optional[str] = None, put_after_adjacent: bool = False, wait: WaitType = False, ): # pylint: disable=too-many-arguments, too-many-locals """ DEPRECATED Create stonith as resource in a cib and put it into defined group. env -- provides all for communication with externals stonith_id --an identifier of stonith resource stonith_agent_name -- contains name for the identification of agent group_id -- identificator for group to put stonith inside operations -- contains attributes for each entered operation meta_attributes -- contains attributes for primitive/meta_attributes instance_attributes -- contains attributes for primitive/instance_attributes allow_absent_agent -- a flag for allowing agent not installed in a system allow_invalid_operation -- a flag for allowing to use operations that are not listed in a stonith agent metadata allow_invalid_instance_attributes -- a flag for allowing to use instance attributes that are not listed in a stonith agent metadata or for allowing to not use the instance_attributes that are required in stonith agent metadata use_default_operations -- a flag for stopping of adding default cib operations (specified in a stonith agent) ensure_disabled -- flag that keeps resource in target-role "Stopped" adjacent_resource_id -- identify neighbor of a newly created stonith put_after_adjacent -- is flag to put a newly create resource befor/after adjacent stonith wait -- flag for controlling waiting for pacemaker idle mechanism """ runner = env.cmd_runner() agent_factory = ResourceAgentFacadeFactory(runner, env.report_processor) stonith_agent = _get_agent_facade( env.report_processor, agent_factory, stonith_agent_name, allow_absent_agent, ) if stonith_agent.metadata.provides_unfencing: meta_attributes = dict(meta_attributes, provides="unfencing") with resource_environment( env, wait, [stonith_id], _ensure_disabled_after_wait( ensure_disabled or resource.common.are_meta_disabled(meta_attributes), ), ) as resources_section: id_provider = IdProvider(resources_section) adjacent_resource_element = None if adjacent_resource_id: try: adjacent_resource_element = get_element_by_id( get_root(resources_section), adjacent_resource_id) except ElementNotFound: # We cannot continue without adjacent element because # the validator might produce misleading reports if env.report_processor.report( ReportItem.error( reports.messages.IdNotFound( adjacent_resource_id, []))).has_errors: raise LibraryError() from None try: group_element = get_element_by_id(get_root(resources_section), group_id) except ElementNotFound: group_id_reports: List[ReportItem] = [] validate_id(group_id, description="group name", reporter=group_id_reports) env.report_processor.report_list(group_id_reports) group_element = resource.group.append_new(resources_section, group_id) stonith_element = resource.primitive.create( env.report_processor, resources_section, id_provider, stonith_id, stonith_agent, operations, meta_attributes, instance_attributes, allow_invalid_operation, allow_invalid_instance_attributes, use_default_operations, ) if ensure_disabled: resource.common.disable(stonith_element, id_provider) if env.report_processor.report_list( resource.validations.validate_move_resources_to_group( group_element, [stonith_element], adjacent_resource_element, )).has_errors: raise LibraryError() resource.hierarchy.move_resources_to_group( group_element, [stonith_element], adjacent_resource_element, put_after_adjacent, )
def test_no_match_in_status(self): with self.assertRaises(lib.ElementNotFound): lib.get_element_by_id(cib_element_lookup, "R2")
def test_id_not_in_cib(self): with self.assertRaises(lib.ElementNotFound): lib.get_element_by_id(cib_element_lookup, "X")
def test_tag_id_same_as_resource_id(self): with self.assertRaises(AssertionError): lib.get_element_by_id(cib_element_lookup, "T")
def test_duplicate_ids(self): with self.assertRaises(AssertionError): lib.get_element_by_id(cib_element_lookup, "RX2")
def test_one_match_ignore_reference(self): found_element = lib.get_element_by_id(cib_element_lookup, "R3") self.assertEqual( found_element, cib_element_lookup.find('.//resources/primitive[@id="R3"]'), )