예제 #1
0
 def command(self, force_flags=()):
     return lambda: stonith.update_scsi_devices_add_remove(
         self.env_assist.get_env(),
         SCSI_STONITH_ID,
         [DEV_2],
         [],
         force_flags=force_flags,
     )
예제 #2
0
 def command(self, **kwargs):
     return lambda: stonith.update_scsi_devices_add_remove(
         self.env_assist.get_env(),
         self.stonith_id,
         kwargs.get("devices_add", [DEV_2]),
         kwargs.get("devices_remove", ()),
         force_flags=kwargs.get("force_flags", ()),
     )
예제 #3
0
 def test_stonith_resource_is_running_on_more_than_one_node(self):
     self.config.runner.cib.load(resources=fixture_scsi())
     self.config.runner.pcmk.is_resource_digests_supported()
     self.config.runner.pcmk.load_state(
         resources=FIXTURE_CRM_MON_RES_RUNNING_2, nodes=FIXTURE_CRM_MON_NODES
     )
     self.env_assist.assert_raise_library_error(
         lambda: stonith.update_scsi_devices_add_remove(
             self.env_assist.get_env(), SCSI_STONITH_ID, [DEV_2], []
         ),
         [
             fixture.error(
                 reports.codes.STONITH_RESTARTLESS_UPDATE_UNABLE_TO_PERFORM,
                 reason=(
                     f"resource '{SCSI_STONITH_ID}' is running on more than "
                     "1 node"
                 ),
                 reason_type=reports.const.STONITH_RESTARTLESS_UPDATE_UNABLE_TO_PERFORM_REASON_OTHER,
             )
         ],
         expected_in_processor=False,
     )
예제 #4
0
 def test_not_supported_resource_type(self):
     """
     lower level tested in
     pcs_test.tier0.lib.cib.test_stonith.ValidateStonithRestartlessUpdate
     """
     self.config.runner.cib.load(resources=fixture_scsi())
     self.config.runner.pcmk.is_resource_digests_supported()
     self.env_assist.assert_raise_library_error(
         lambda: stonith.update_scsi_devices_add_remove(
             self.env_assist.get_env(), "dummy", [DEV_2], [DEV_1]
         )
     )
     self.env_assist.assert_reports(
         [
             fixture.error(
                 reports.codes.STONITH_RESTARTLESS_UPDATE_UNSUPPORTED_AGENT,
                 resource_id="dummy",
                 resource_type="Dummy",
                 supported_stonith_types=["fence_scsi"],
             )
         ]
     )
예제 #5
0
 def test_add_remove_are_empty(self):
     """
     lower level tested in
     pcs_test/tier0/lib/test_validate.ValidateAddRemoveItems
     """
     self.config.runner.cib.load(resources=fixture_scsi())
     self.config.runner.pcmk.is_resource_digests_supported()
     self.env_assist.assert_raise_library_error(
         lambda: stonith.update_scsi_devices_add_remove(
             self.env_assist.get_env(), SCSI_STONITH_ID, (), ()
         )
     )
     self.env_assist.assert_reports(
         [
             fixture.error(
                 reports.codes.ADD_REMOVE_ITEMS_NOT_SPECIFIED,
                 container_type=reports.const.ADD_REMOVE_CONTAINER_TYPE_STONITH_RESOURCE,
                 item_type="device",
                 container_id=SCSI_STONITH_ID,
             )
         ]
     )
예제 #6
0
    def assert_command_success(
        self,
        devices_before=DEVICES_1,
        devices_updated=DEVICES_2,
        devices_add=(),
        devices_remove=(),
        unfence=None,
        resource_ops=DEFAULT_OPS,
        lrm_monitor_ops=DEFAULT_LRM_MONITOR_OPS,
        lrm_start_ops=DEFAULT_LRM_START_OPS,
        lrm_monitor_ops_updated=DEFAULT_LRM_MONITOR_OPS_UPDATED,
        lrm_start_ops_updated=DEFAULT_LRM_START_OPS_UPDATED,
    ):
        # pylint: disable=too-many-arguments
        # pylint: disable=too-many-locals
        devices_value = ",".join(sorted(devices_updated))
        self.config.runner.cib.load(
            resources=fixture_scsi(
                devices=devices_before, resource_ops=resource_ops
            ),
            status=_fixture_status_lrm_ops(
                SCSI_STONITH_ID,
                lrm_start_ops=lrm_start_ops,
                lrm_monitor_ops=lrm_monitor_ops,
            ),
        )
        self.config.runner.pcmk.is_resource_digests_supported()
        self.config.runner.pcmk.load_state(
            resources=FIXTURE_CRM_MON_RES_RUNNING_1, nodes=FIXTURE_CRM_MON_NODES
        )
        devices_opt = "devices={}".format(devices_value)
        self.config.runner.pcmk.resource_digests(
            SCSI_STONITH_ID,
            SCSI_NODE,
            name="start.op.digests",
            stdout=fixture_digests_xml(
                SCSI_STONITH_ID, SCSI_NODE, devices=devices_value
            ),
            args=[devices_opt],
        )

        for num, op in enumerate(resource_ops, 1):
            name, interval, timeout, _ = op
            if name != "monitor":
                continue
            args = [devices_opt]
            args.append(
                "CRM_meta_interval={}".format(
                    1000 * timeout_to_seconds(interval)
                )
            )
            if timeout:
                args.append(
                    "CRM_meta_timeout={}".format(
                        1000 * timeout_to_seconds(timeout)
                    )
                )
            self.config.runner.pcmk.resource_digests(
                SCSI_STONITH_ID,
                SCSI_NODE,
                name=f"{name}-{num}.op.digests",
                stdout=fixture_digests_xml(
                    SCSI_STONITH_ID,
                    SCSI_NODE,
                    devices=devices_value,
                ),
                args=args,
            )
        if unfence:
            self.config.corosync_conf.load_content(
                corosync_conf_fixture(
                    self.existing_corosync_nodes,
                    get_two_node(len(self.existing_corosync_nodes)),
                )
            )
            self.config.http.corosync.get_corosync_online_targets(
                node_labels=self.existing_nodes
            )
            self.config.http.scsi.unfence_node(
                original_devices=devices_before,
                updated_devices=devices_updated,
                node_labels=self.existing_nodes,
            )
        self.config.env.push_cib(
            resources=fixture_scsi(
                devices=devices_updated, resource_ops=resource_ops
            ),
            status=_fixture_status_lrm_ops(
                SCSI_STONITH_ID,
                lrm_start_ops=lrm_start_ops_updated,
                lrm_monitor_ops=lrm_monitor_ops_updated,
            ),
        )
        if devices_add or devices_remove:
            stonith.update_scsi_devices_add_remove(
                self.env_assist.get_env(),
                SCSI_STONITH_ID,
                devices_add,
                devices_remove,
            )
        else:
            stonith.update_scsi_devices(
                self.env_assist.get_env(), SCSI_STONITH_ID, devices_updated
            )
        self.env_assist.assert_reports([])