示例#1
0
def disable_sbd(lib_env, ignore_offline_nodes=False):
    """
    Disable SBD on all nodes in cluster.

    lib_env -- LibraryEnvironment
    ignore_offline_nodes -- if True, omit offline nodes
    """
    node_list = _get_online_nodes(lib_env, _get_cluster_nodes(lib_env),
                                  ignore_offline_nodes)

    if lib_env.is_cman_cluster:
        nodes_task.check_corosync_offline_on_nodes(lib_env.node_communicator(),
                                                   lib_env.report_processor,
                                                   node_list,
                                                   ignore_offline_nodes)

    sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
        lib_env.node_communicator(), node_list)
    sbd.disable_sbd_service_on_all_nodes(lib_env.report_processor,
                                         lib_env.node_communicator(),
                                         node_list)

    if not lib_env.is_cman_cluster:
        lib_env.report_processor.process(
            reports.cluster_restart_required_to_apply_changes())
示例#2
0
文件: sbd.py 项目: HideoYamauchi/pcs
def disable_sbd(lib_env, ignore_offline_nodes=False):
    """
    Disable SBD on all nodes in cluster.

    lib_env -- LibraryEnvironment
    ignore_offline_nodes -- if True, omit offline nodes
    """
    node_list = _get_online_nodes(
        lib_env, _get_cluster_nodes(lib_env), ignore_offline_nodes
    )

    if lib_env.is_cman_cluster:
        nodes_task.check_corosync_offline_on_nodes(
            lib_env.node_communicator(),
            lib_env.report_processor,
            node_list,
            ignore_offline_nodes
        )

    sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
        lib_env.node_communicator(), node_list
    )
    sbd.disable_sbd_service_on_all_nodes(
        lib_env.report_processor,
        lib_env.node_communicator(),
        node_list
    )

    if not lib_env.is_cman_cluster:
        lib_env.report_processor.process(
            reports.cluster_restart_required_to_apply_changes()
        )
示例#3
0
 def test_success(self, mock_func):
     lib_sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
         self.mock_com, self.node_list
     )
     func_calls = [mock.call(self.mock_com, node) for node in self.node_list]
     self.assertEqual(mock_func.call_count, len(func_calls))
     mock_func.assert_has_calls(func_calls)
示例#4
0
 def test_success(self, mock_func):
     lib_sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
         self.mock_com, self.node_list
     )
     func_calls = [mock.call(self.mock_com, node) for node in self.node_list]
     self.assertEqual(mock_func.call_count, len(func_calls))
     mock_func.assert_has_calls(func_calls)
示例#5
0
    def test_communication_error(self, mock_func):
        def raiser(_, node):
            if node == self.node_list[1]:
                raise NodeConnectionException(self.node_list[1], "command",
                                              "reason")
            elif node == self.node_list[4]:
                raise NodeCommunicationException(self.node_list[4], "command",
                                                 "reason")

        mock_func.side_effect = raiser
        assert_raise_library_error(
            lambda: lib_sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
                self.mock_com, self.node_list),
            (Severities.ERROR,
             report_codes.NODE_COMMUNICATION_ERROR_UNABLE_TO_CONNECT, {
                 "node": self.node_list[1],
                 "command": "command",
                 "reason": "reason"
             }), (Severities.ERROR, report_codes.NODE_COMMUNICATION_ERROR, {
                 "node": self.node_list[4],
                 "command": "command",
                 "reason": "reason"
             }))
        func_calls = [
            mock.call(self.mock_com, node) for node in self.node_list
        ]
        self.assertEqual(mock_func.call_count, len(func_calls))
        mock_func.assert_has_calls(func_calls)
示例#6
0
    def test_communication_error(self, mock_func):
        def raiser(_, node):
            if node == self.node_list[1]:
                raise NodeConnectionException(
                    self.node_list[1], "command", "reason"
                )
            elif node == self.node_list[4]:
                raise NodeCommunicationException(
                    self.node_list[4], "command", "reason"
                )

        mock_func.side_effect = raiser
        assert_raise_library_error(
            lambda: lib_sbd.set_stonith_watchdog_timeout_to_zero_on_all_nodes(
                self.mock_com, self.node_list
            ),
            (
                Severities.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR_UNABLE_TO_CONNECT,
                {
                    "node": self.node_list[1],
                    "command": "command",
                    "reason": "reason"
                }
            ),
            (
                Severities.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR,
                {
                    "node": self.node_list[4],
                    "command": "command",
                    "reason": "reason"
                }
            )
        )
        func_calls = [mock.call(self.mock_com, node) for node in self.node_list]
        self.assertEqual(mock_func.call_count, len(func_calls))
        mock_func.assert_has_calls(func_calls)