コード例 #1
0
ファイル: resource.py プロジェクト: tomjelinek/pcs
def unmove_unban(
    env, resource_id, node=None, master=False, expired=False, wait=False
):
    """
    Remove all constraints created by move and ban

    LibraryEnvironment env
    string resource_id -- id of a resource to be unmoved/unbanned
    string node -- node to limit unmoving/unbanning to, all nodes if None
    bool master -- only remove constraints for Master role
    bool expired -- only remove constrains which have already expired
    mixed wait -- flag for controlling waiting for pacemaker idle mechanism
    """
    # validate
    env.ensure_wait_satisfiable(wait) # raises on error

    report_list = []
    resource_el = resource.common.find_one_resource_and_report(
        get_resources(env.get_cib()),
        resource_id,
        report_list,
    )
    if resource_el is not None:
        report_list.extend(
            resource.common.validate_unmove_unban(resource_el, master)
        )
    if (
        expired
        and
        not has_resource_unmove_unban_expired_support(env.cmd_runner())
    ):
        report_list.append(
            reports.resource_unmove_unban_pcmk_expired_not_supported()
        )
    env.report_processor.process_list(report_list) # raises on error

    # run the action
    stdout, stderr, retval = resource_unmove_unban(
        env.cmd_runner(), resource_id, node=node, master=master, expired=expired
    )
    if retval != 0:
        raise LibraryError(
            reports.resource_unmove_unban_pcmk_error(
                resource_id, stdout, stderr
            )
        )
    env.report_processor.process(
        reports.resource_unmove_unban_pcmk_success(resource_id, stdout, stderr)
    )

    # process wait
    if wait is not False:
        wait_for_idle(env.cmd_runner(), env.get_wait_timeout(wait))
        env.report_processor.process(
            info_resource_state(env.get_cluster_state(), resource_id)
        )
コード例 #2
0
 def assert_running_info_transform(self, run_info, report):
     self.get_primitives_for_state_check.return_value = ["elem1", "elem2"]
     self.get_primitive_roles_with_nodes.return_value = run_info
     assert_report_item_equal(
         state.info_resource_state(self.cluster_state, self.resource_id),
         report)
     self.get_primitives_for_state_check.assert_called_once_with(
         self.cluster_state, self.resource_id, expected_running=True)
     self.get_primitive_roles_with_nodes.assert_called_once_with(
         ["elem1", "elem2"])
コード例 #3
0
ファイル: resource.py プロジェクト: visioncritical/pcs
def unmove_unban(env,
                 resource_id,
                 node=None,
                 master=False,
                 expired=False,
                 wait=False):
    """
    Remove all constraints created by move and ban

    LibraryEnvironment env
    string resource_id -- id of a resource to be unmoved/unbanned
    string node -- node to limit unmoving/unbanning to, all nodes if None
    bool master -- only remove constraints for Master role
    bool expired -- only remove constrains which have already expired
    mixed wait -- flag for controlling waiting for pacemaker idle mechanism
    """
    # validate
    env.ensure_wait_satisfiable(wait)  # raises on error

    report_list = []
    resource_el = resource.common.find_one_resource_and_report(
        get_resources(env.get_cib()),
        resource_id,
        report_list,
    )
    if resource_el is not None:
        report_list.extend(
            resource.common.validate_unmove_unban(resource_el, master))
    if (expired and
            not has_resource_unmove_unban_expired_support(env.cmd_runner())):
        report_list.append(
            reports.resource_unmove_unban_pcmk_expired_not_supported())
    env.report_processor.process_list(report_list)  # raises on error

    # run the action
    stdout, stderr, retval = resource_unmove_unban(env.cmd_runner(),
                                                   resource_id,
                                                   node=node,
                                                   master=master,
                                                   expired=expired)
    if retval != 0:
        raise LibraryError(
            reports.resource_unmove_unban_pcmk_error(resource_id, stdout,
                                                     stderr))
    env.report_processor.process(
        reports.resource_unmove_unban_pcmk_success(resource_id, stdout,
                                                   stderr))

    # process wait
    if wait is not False:
        wait_for_idle(env.cmd_runner(), env.get_wait_timeout(wait))
        env.report_processor.process(
            info_resource_state(env.get_cluster_state(), resource_id))