Пример #1
0
 def test_disable_enabled_stonith(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_xvm".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_xvm">
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
     )
     self.assert_effect(
         "stonith disable S".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_xvm">
                 <meta_attributes id="S-meta_attributes">
                     <nvpair id="S-meta_attributes-target-role"
                         name="target-role" value="Stopped"
                     />
                 </meta_attributes>
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
     )
Пример #2
0
 def test_debug_and_verbose_allowed(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_apc ip=i username=u verbose=v debug=d".
         split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_apc">
                 <instance_attributes id="S-instance_attributes">
                     <nvpair id="S-instance_attributes-debug"
                         name="debug" value="d"
                     />
                     <nvpair id="S-instance_attributes-ip"
                         name="ip" value="i"
                     />
                     <nvpair id="S-instance_attributes-username"
                         name="username" value="u"
                     />
                     <nvpair id="S-instance_attributes-verbose"
                         name="verbose" value="v"
                     />
                 </instance_attributes>
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
         output=(
             "Warning: stonith option 'debug' is deprecated and should not "
             "be used, use 'debug_file' instead\n"),
     )
Пример #3
0
 def test_command_simply_puts_stonith_into_group_before_another(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_pcs_success(
         "stonith create S1 fence_xvm --group G".split(),
         stdout_full=self.deprecation_warning,
     )
     self.assert_effect(
         "stonith create S2 fence_xvm --group G --before S1".split(),
         """<resources>
             <group id="G">
                 <primitive class="stonith" id="S2" type="fence_xvm">
                     <operations>
                         <op id="S2-monitor-interval-60s" interval="60s"
                             name="monitor"
                         />
                     </operations>
                 </primitive>
                 <primitive class="stonith" id="S1" type="fence_xvm">
                     <operations>
                         <op id="S1-monitor-interval-60s" interval="60s"
                             name="monitor"
                         />
                     </operations>
                 </primitive>
             </group>
         </resources>""",
         output=self.deprecation_warning,
     )
Пример #4
0
    def test_no_stonith_warning_when_stonith_in_group(self):
        self.assert_pcs_success(
            "stonith create S fence_xvm --group G".split(),
            ("Deprecation Warning: Option to group stonith resource is "
             "deprecated and will be removed in a future release.\n"),
        )
        self.pcs_runner.corosync_conf_opt = self.corosync_conf
        self.pcs_runner.mock_settings = get_mock_settings(
            "crm_resource_binary")
        if PCMK_2_0_3_PLUS:
            self.assert_pcs_success(
                ["status"],
                stdout_start=dedent("""\
                    Cluster name: test99
                    Cluster Summary:
                """),
            )
        else:
            self.assert_pcs_success(
                ["status"],
                stdout_start=dedent("""\
                    Cluster name: test99

                    Stack: unknown
                    Current DC: NONE
                """),
            )
Пример #5
0
 def test_fail_when_intended_after_item_does_not_exist(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_pcs_fail(
         "stonith create S2 fence_xvm --group G --after S1".split(),
         (self.deprecation_warning + "Error: 'S1' does not exist\n" +
          ERRORS_HAVE_OCURRED),
     )
Пример #6
0
 def test_error_when_action_specified(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_pcs_fail(
         "stonith create S fence_xvm action=reboot".split(),
         "Error: stonith option 'action' is deprecated and should not be"
         " used, use 'pcmk_off_action', 'pcmk_reboot_action' instead, "
         "use --force to override\n" + ERRORS_HAVE_OCURRED,
     )
Пример #7
0
 def test_simplest(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_xvm".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_xvm">
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
     )
Пример #8
0
 def test_base_with_agent_that_provides_unfencing(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_scsi".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_scsi">
                 <meta_attributes id="S-meta_attributes">
                     <nvpair id="S-meta_attributes-provides" name="provides"
                         value="unfencing"
                     />
                 </meta_attributes>
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
     )
Пример #9
0
 def test_simplest_with_meta_provides(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_xvm meta provides=something".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_xvm">
                 <meta_attributes id="S-meta_attributes">
                     <nvpair id="S-meta_attributes-provides" name="provides"
                         value="something"
                     />
                 </meta_attributes>
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
     )
Пример #10
0
 def test_warn_when_action_specified_forced(self):
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
     self.assert_effect(
         "stonith create S fence_xvm action=reboot --force".split(),
         """<resources>
             <primitive class="stonith" id="S" type="fence_xvm">
                 <instance_attributes id="S-instance_attributes">
                     <nvpair id="S-instance_attributes-action"
                         name="action" value="reboot"
                     />
                 </instance_attributes>
                 <operations>
                     <op id="S-monitor-interval-60s" interval="60s"
                         name="monitor"
                     />
                 </operations>
             </primitive>
         </resources>""",
         "Warning: stonith option 'action' is deprecated and should not be "
         "used, use 'pcmk_off_action', 'pcmk_reboot_action' instead\n",
     )
Пример #11
0
    def test_no_stonith_warning_when_stonith_in_group(self):
        self.assert_pcs_success("stonith create S fence_xvm --group G".split())
        self.pcs_runner.corosync_conf_opt = self.corosync_conf
        self.pcs_runner.mock_settings = get_mock_settings(
            "crm_resource_binary")
        if PCMK_2_0_3_PLUS:
            self.assert_pcs_success(
                ["status"],
                stdout_start=dedent("""\
                    Cluster name: test99
                    Cluster Summary:
                """),
            )
        else:
            self.assert_pcs_success(
                ["status"],
                stdout_start=dedent("""\
                    Cluster name: test99

                    Stack: unknown
                    Current DC: NONE
                """),
            )
Пример #12
0
 def setUp(self):
     super().setUp()
     self.pcs_runner.corosync_conf_opt = self.corosync_conf
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
Пример #13
0
 def setUp(self):
     shutil.copy(self.empty_cib, self.temp_cib)
     self.pcs_runner = PcsRunner(self.temp_cib)
     self.pcs_runner.mock_settings = get_mock_settings("crm_resource_binary")
Пример #14
0
 def setUp(self):
     super().setUp()
     self.pcs_runner.corosync_conf_opt = self.corosync_conf
     self.pcs_runner.mock_settings = get_mock_settings("crm_resource_binary")
Пример #15
0
 def setUp(self):
     shutil.copy(self.empty_cib, self.temp_cib)
     self.pcs_runner = PcsRunner(self.temp_cib)
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
Пример #16
0
 def setUp(self):
     self.temp_cib = get_tmp_file("tier1_bundle_show")
     write_file_to_tmpfile(self.empty_cib, self.temp_cib)
     self.pcs_runner = PcsRunner(self.temp_cib.name)
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
Пример #17
0
 def setUp(self):
     self.temp_cib = get_tmp_file("tier1_misc")
     write_file_to_tmpfile(rc("cib-empty-1.2.xml"), self.temp_cib)
     self.pcs_runner = PcsRunner(self.temp_cib.name)
     self.pcs_runner.mock_settings = get_mock_settings(
         "crm_resource_binary")
Пример #18
0
 def setUp(self):
     shutil.copy(rc("cib-empty-1.2.xml"), temp_cib)
     self.pcs_runner = PcsRunner(temp_cib)
     self.pcs_runner.mock_settings = get_mock_settings("crm_resource_binary")