예제 #1
0
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
예제 #2
0
 def test_no_stonith(self):
     resources = etree.fromstring("""
         <resources>
             <primitive id="R" class="ocf" provider="pacemaker" type="Dummy">
                 <instance_attributes>
                     <nvpair name="action" value="value" />
                     <nvpair name="method" value="cycle" />
                 </instance_attributes>
             </primitive>
         </resources>
     """)
     self.assertEqual(stonith.get_misconfigured_resources(resources),
                      ([], [], []))
예제 #3
0
 def test_all_ok(self):
     resources = etree.fromstring("""
         <resources>
             <primitive id="S1" class="stonith" type="fence_something">
                 <instance_attributes>
                     <nvpair name="name" value="value" />
                 </instance_attributes>
             </primitive>
         </resources>
     """)
     self.assertEqual(
         stonith.get_misconfigured_resources(resources),
         (
             resources.findall("primitive[@id='S1']"),
             [],
             [],
         ),
     )
예제 #4
0
 def test_issues(self):
     resources = etree.fromstring(
         """
         <resources>
             <primitive id="S1" class="stonith" type="fence_something">
                 <instance_attributes>
                     <nvpair name="name" value="value" />
                     <nvpair name="method" value="onoff" />
                 </instance_attributes>
             </primitive>
             <primitive id="S2" class="stonith" type="fence_something">
                 <instance_attributes>
                     <nvpair name="action" value="value" />
                 </instance_attributes>
             </primitive>
             <primitive id="S3" class="stonith" type="fence_something">
                 <instance_attributes>
                     <nvpair name="method" value="cycle" />
                 </instance_attributes>
             </primitive>
             <primitive id="S4" class="stonith" type="fence_something">
                 <instance_attributes>
                     <nvpair name="action" value="value" />
                     <nvpair name="method" value="cycle" />
                 </instance_attributes>
             </primitive>
         </resources>
     """
     )
     stonith1 = resources.find("primitive[@id='S1']")
     stonith2 = resources.find("primitive[@id='S2']")
     stonith3 = resources.find("primitive[@id='S3']")
     stonith4 = resources.find("primitive[@id='S4']")
     self.assertEqual(
         stonith.get_misconfigured_resources(resources),
         (
             [stonith1, stonith2, stonith3, stonith4],
             [stonith2, stonith4],
             [stonith3, stonith4],
         ),
     )