Beispiel #1
0
def _set_instance_attrs_local_node(lib_env, attrs, wait):
    if not lib_env.is_cib_live:
        # If we are not working with a live cluster we cannot get the local node
        # name.
        raise LibraryError(reports.live_environment_required_for_local_node())

    with cib_runner_nodes(lib_env, wait) as (cib, runner, state_nodes):
        update_node_instance_attrs(cib, get_local_node_name(runner), attrs,
                                   state_nodes)
Beispiel #2
0
def _set_instance_attrs_local_node(lib_env, attrs, wait):
    if not lib_env.is_cib_live:
        # If we are not working with a live cluster we cannot get the local node
        # name.
        raise LibraryError(reports.live_environment_required_for_local_node())

    with cib_runner_nodes(lib_env, wait) as (cib, runner, state_nodes):
        update_node_instance_attrs(
            cib,
            get_local_node_name(runner),
            attrs,
            state_nodes
        )
Beispiel #3
0
 def test_error_not_connected(self):
     stderr = (
         "error: Could not connect to controller: Transport endpoint is "
         "not connected\n")
     self.config.runner.pcmk.local_node_name(
         stderr=stderr,
         returncode=_EXITCODE_NOT_CONNECTED,
     )
     env = self.env_assist.get_env()
     with self.assertRaises(lib.PacemakerNotConnectedException) as cm:
         lib.get_local_node_name(env.cmd_runner())
     assert_report_item_list_equal(
         cm.exception.args,
         [
             (
                 Severity.ERROR,
                 report_codes.PACEMAKER_LOCAL_NODE_NAME_NOT_FOUND,
                 {
                     "reason": stderr.strip(),
                 },
             ),
         ],
     )
Beispiel #4
0
def _set_instance_attrs_local_node(lib_env, attrs, wait):
    if not lib_env.is_cib_live:
        # If we are not working with a live cluster we cannot get the local node
        # name.
        raise LibraryError(
            ReportItem.error(
                reports.messages.LiveEnvironmentRequiredForLocalNode()))

    with cib_runner_nodes(lib_env, wait) as (cib, runner, state_nodes):
        update_node_instance_attrs(
            cib,
            IdProvider(cib),
            get_local_node_name(runner),
            attrs,
            state_nodes=state_nodes,
        )
Beispiel #5
0
 def test_error(self):
     self.config.runner.pcmk.local_node_name(stdout="some info",
                                             stderr="some error",
                                             returncode=1)
     env = self.env_assist.get_env()
     self.env_assist.assert_raise_library_error(
         lambda: lib.get_local_node_name(env.cmd_runner()),
         [
             fixture.error(
                 report_codes.PACEMAKER_LOCAL_NODE_NAME_NOT_FOUND,
                 force_code=None,
                 reason="some error\nsome info",
             )
         ],
         expected_in_processor=False,
     )
Beispiel #6
0
 def test_success(self):
     expected_name = "node-name"
     self.config.runner.pcmk.local_node_name(node_name=expected_name)
     env = self.env_assist.get_env()
     real_name = lib.get_local_node_name(env.cmd_runner())
     self.assertEqual(expected_name, real_name)