def test_failures(self): resources = etree.fromstring("<resources />") reporter = MockLibraryReportProcessor() lib.verify(reporter, self.get_cib(), resources, []) report = [ ( severity.ERROR, report_codes.STONITH_RESOURCES_DO_NOT_EXIST, { "stonith_ids": [ "d1", "d2", "d3", "d4", "d5", "dR", "dR-special" ], }, None ), ( severity.ERROR, report_codes.NODE_NOT_FOUND, { "node": "nodeA", }, None ), ( severity.ERROR, report_codes.NODE_NOT_FOUND, { "node": "nodeB", }, None ), ] assert_report_item_list_equal(reporter.report_item_list, report)
def verify(env, verbose=False): runner = env.cmd_runner() dummy_stdout, verify_stderr, verify_returncode = verify_cmd( runner, verbose=verbose, ) #1) Do not even try to think about upgrading! #2) We do not need cib management in env (no need for push...). #So env.get_cib is not best choice here (there were considerations to #upgrade cib at all times inside env.get_cib). Go to a lower level here. if verify_returncode != 0: env.report_processor.append(reports.invalid_cib_content(verify_stderr)) #Cib is sometimes loadable even if `crm_verify` fails (e.g. when #fencing topology is invalid). On the other hand cib with id duplication #is not loadable. #We try extra checks when cib is possible to load. cib_xml, dummy_stderr, returncode = get_cib_xml_cmd_results(runner) if returncode != 0: #can raise; raise LibraryError is better but in this case we prefer #be consistent with raising below env.report_processor.send() else: cib_xml = get_cib_xml(runner) cib = get_cib(cib_xml) fencing_topology.verify( env.report_processor, get_fencing_topology(cib), get_resources(cib), ClusterState(get_cluster_status_xml(runner)).node_section.nodes) #can raise env.report_processor.send()
def test_empty(self): resources = etree.fromstring("<resources />") topology = etree.fromstring("<fencing-topology />") reporter = MockLibraryReportProcessor() lib.verify(reporter, topology, resources, self.get_status()) assert_report_item_list_equal(reporter.report_item_list, [])
def test_success(self): resources = etree.fromstring("<resources />") for name in ["d1", "d2", "d3", "d4", "d5", "dR", "dR-special"]: self.fixture_resource(resources, name) reporter = MockLibraryReportProcessor() lib.verify(reporter, self.get_cib(), resources, self.get_status()) assert_report_item_list_equal(reporter.report_item_list, [])
def verify(lib_env): """ Check if all cluster nodes and stonith devices used in fencing levels exist LibraryError lib_env -- environment """ cib = lib_env.get_cib() cib_fencing_topology.verify( lib_env.report_processor, get_fencing_topology(cib), get_resources(cib), ClusterState(get_cluster_status_xml( lib_env.cmd_runner())).node_section.nodes) lib_env.report_processor.send()
def verify(lib_env): """ Check if all cluster nodes and stonith devices used in fencing levels exist LibraryEnvironment lib_env -- environment """ cib = lib_env.get_cib() cib_fencing_topology.verify( lib_env.report_processor, get_fencing_topology(cib), get_resources(cib), ClusterState( get_cluster_status_xml(lib_env.cmd_runner()) ).node_section.nodes ) lib_env.report_processor.send()
def test_empty(self): resources = etree.fromstring("<resources />") topology = etree.fromstring("<fencing-topology />") report_list = lib.verify(topology, resources, self.get_status()) assert_report_item_list_equal(report_list, [])
def test_success(self): resources = etree.fromstring("<resources />") for name in ["d1", "d2", "d3", "d4", "d5", "dR", "dR-special"]: self.fixture_resource(resources, name) report_list = lib.verify(self.tree, resources, self.get_status()) assert_report_item_list_equal(report_list, [])
def verify(lib_env: LibraryEnvironment): """ Check if all cluster nodes and stonith devices used in fencing levels exist LibraryEnvironment lib_env -- environment """ cib = lib_env.get_cib() lib_env.report_processor.report_list( cib_fencing_topology.verify( get_fencing_topology(cib), get_resources(cib), ClusterState(lib_env.get_cluster_state()).node_section.nodes, )) if lib_env.report_processor.has_errors: raise LibraryError()
def test_failures(self): resources = etree.fromstring("<resources />") report_list = lib.verify(self.tree, resources, []) report = [ ( severity.ERROR, report_codes.STONITH_RESOURCES_DO_NOT_EXIST, { "stonith_ids": [ "d1", "d2", "d3", "d4", "d5", "dR", "dR-special", ], }, None, ), ( severity.ERROR, report_codes.NODE_NOT_FOUND, { "node": "nodeA", "searched_types": [], }, None, ), ( severity.ERROR, report_codes.NODE_NOT_FOUND, { "node": "nodeB", "searched_types": [], }, None, ), ] assert_report_item_list_equal(report_list, report)