本文整理汇总了Python中pcs.lib.env.LibraryEnvironment.get_corosync_conf方法的典型用法代码示例。如果您正苦于以下问题:Python LibraryEnvironment.get_corosync_conf方法的具体用法?Python LibraryEnvironment.get_corosync_conf怎么用?Python LibraryEnvironment.get_corosync_conf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pcs.lib.env.LibraryEnvironment
的用法示例。
在下文中一共展示了LibraryEnvironment.get_corosync_conf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_corosync_conf_set
# 需要导入模块: from pcs.lib.env import LibraryEnvironment [as 别名]
# 或者: from pcs.lib.env.LibraryEnvironment import get_corosync_conf [as 别名]
def test_corosync_conf_set(
self, mock_get_corosync, mock_distribute, mock_reload,
mock_check_offline, mock_qdevice_reload
):
corosync_data = "totem {\n version: 2\n}\n"
new_corosync_data = "totem {\n version: 3\n}\n"
env = LibraryEnvironment(
self.mock_logger,
self.mock_reporter,
corosync_conf_data=corosync_data
)
self.assertFalse(env.is_corosync_conf_live)
self.assertEqual(corosync_data, env.get_corosync_conf_data())
self.assertEqual(corosync_data, env.get_corosync_conf().config.export())
self.assertEqual(0, mock_get_corosync.call_count)
env.push_corosync_conf(
CorosyncConfigFacade.from_string(new_corosync_data)
)
self.assertEqual(0, mock_distribute.call_count)
self.assertEqual(new_corosync_data, env.get_corosync_conf_data())
self.assertEqual(0, mock_get_corosync.call_count)
mock_check_offline.assert_not_called()
mock_reload.assert_not_called()
mock_qdevice_reload.assert_not_called()
示例2: test_corosync_conf_not_set_need_offline_success
# 需要导入模块: from pcs.lib.env import LibraryEnvironment [as 别名]
# 或者: from pcs.lib.env.LibraryEnvironment import get_corosync_conf [as 别名]
def test_corosync_conf_not_set_need_offline_success(
self, mock_get_corosync, mock_distribute, mock_is_running, mock_reload,
mock_check_offline, mock_qdevice_reload
):
corosync_data = open(rc("corosync.conf")).read()
new_corosync_data = corosync_data.replace("version: 2", "version: 3")
mock_get_corosync.return_value = corosync_data
mock_is_running.return_value = False
env = LibraryEnvironment(self.mock_logger, self.mock_reporter)
self.assertTrue(env.is_corosync_conf_live)
self.assertEqual(corosync_data, env.get_corosync_conf_data())
self.assertEqual(corosync_data, env.get_corosync_conf().config.export())
self.assertEqual(2, mock_get_corosync.call_count)
conf_facade = CorosyncConfigFacade.from_string(new_corosync_data)
conf_facade._need_stopped_cluster = True
env.push_corosync_conf(conf_facade)
mock_check_offline.assert_called_once_with(
"mock node communicator",
self.mock_reporter,
"mock node list",
False
)
mock_distribute.assert_called_once_with(
"mock node communicator",
self.mock_reporter,
"mock node list",
new_corosync_data,
False
)
mock_reload.assert_not_called()
mock_qdevice_reload.assert_not_called()
示例3: test_corosync_conf_not_set
# 需要导入模块: from pcs.lib.env import LibraryEnvironment [as 别名]
# 或者: from pcs.lib.env.LibraryEnvironment import get_corosync_conf [as 别名]
def test_corosync_conf_not_set(
self, mock_get_corosync, mock_distribute, mock_reload
):
corosync_data = open(rc("corosync.conf")).read()
new_corosync_data = corosync_data.replace("version: 2", "version: 3")
mock_get_corosync.return_value = corosync_data
env = LibraryEnvironment(self.mock_logger, self.mock_reporter)
self.assertTrue(env.is_corosync_conf_live)
self.assertEqual(corosync_data, env.get_corosync_conf_data())
self.assertEqual(corosync_data, env.get_corosync_conf().config.export())
self.assertEqual(2, mock_get_corosync.call_count)
env.push_corosync_conf(
CorosyncConfigFacade.from_string(new_corosync_data)
)
mock_distribute.assert_called_once_with(
"mock node communicator",
self.mock_reporter,
"mock node list",
new_corosync_data,
False
)
mock_reload.assert_called_once_with("mock cmd runner")
示例4: test_corosync_conf_not_set_need_offline_fail
# 需要导入模块: from pcs.lib.env import LibraryEnvironment [as 别名]
# 或者: from pcs.lib.env.LibraryEnvironment import get_corosync_conf [as 别名]
def test_corosync_conf_not_set_need_offline_fail(
self, mock_get_corosync, mock_distribute, mock_reload,
mock_check_offline, mock_qdevice_reload
):
corosync_data = open(rc("corosync.conf")).read()
new_corosync_data = corosync_data.replace("version: 2", "version: 3")
mock_get_corosync.return_value = corosync_data
def raiser(dummy_communicator, dummy_reporter, dummy_nodes, dummy_force):
raise LibraryError(
reports.corosync_not_running_check_node_error("test node")
)
mock_check_offline.side_effect = raiser
env = LibraryEnvironment(self.mock_logger, self.mock_reporter)
self.assertTrue(env.is_corosync_conf_live)
self.assertEqual(corosync_data, env.get_corosync_conf_data())
self.assertEqual(corosync_data, env.get_corosync_conf().config.export())
self.assertEqual(2, mock_get_corosync.call_count)
conf_facade = CorosyncConfigFacade.from_string(new_corosync_data)
conf_facade._need_stopped_cluster = True
assert_raise_library_error(
lambda: env.push_corosync_conf(conf_facade),
(
severity.ERROR,
report_codes.COROSYNC_NOT_RUNNING_CHECK_NODE_ERROR,
{"node": "test node"}
)
)
mock_check_offline.assert_called_once_with(
"mock node communicator",
self.mock_reporter,
"mock node list",
False
)
mock_distribute.assert_not_called()
mock_reload.assert_not_called()
mock_qdevice_reload.assert_not_called()