def _stonith_warnings(cib: _Element, is_sbd_running: bool) -> List[str]: warning_list = [] is_stonith_enabled = stonith.is_stonith_enabled(get_crm_config(cib)) ( stonith_all, stonith_with_action, stonith_with_method_cycle, ) = stonith.get_misconfigured_resources(get_resources(cib)) if is_stonith_enabled and not stonith_all and not is_sbd_running: warning_list.append( "No stonith devices and stonith-enabled is not false") if stonith_with_action: warning_list.append( ("Following stonith devices have the 'action' option set, " "it is recommended to set {0} instead: {1}").format( format_list(list(STONITH_ACTION_REPLACED_BY)), format_list( [str(x.get("id", "")) for x in stonith_with_action]), )) if stonith_with_method_cycle: warning_list.append( "Following stonith devices have the 'method' option set " "to 'cycle' which is potentially dangerous, please consider using " "'onoff': {0}".format( format_list([ str(x.get("id", "")) for x in stonith_with_method_cycle ]), )) return warning_list
def test_set_to_disabled(self): crm_config = etree.fromstring(""" <crm_config> <cluster_property_set> <nvpair name="abc" value="true" /> <nvpair name="stonith-enabled" value="false" /> </cluster_property_set> </crm_config> """) self.assertFalse(stonith.is_stonith_enabled(crm_config))
def test_not_set(self): crm_config = etree.fromstring("<crm_config />") self.assertTrue(stonith.is_stonith_enabled(crm_config))