示例#1
0
    def test_success_filter_whitespace(self):
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        agents = [
            "",
            "ocf",
            "  lsb",
            "service  ",
            "systemd",
            "  nagios  ",
            "",
            "stonith",
            "",
        ]
        # retval is number of providers found
        mock_runner.run.return_value = (
            "\n".join(agents) + "\n",
            "",
            len(agents)
        )

        self.assertEqual(
            lib_ra.list_resource_agents_standards(mock_runner),
            [
                "lsb",
                "nagios",
                "ocf",
                "service",
                "systemd",
            ]
        )

        mock_runner.run.assert_called_once_with([
            "/usr/sbin/crm_resource", "--list-standards"
        ])
示例#2
0
    def test_empty(self):
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        mock_runner.run.return_value = ("", "", 0)

        self.assertEqual(
            lib_ra.list_resource_agents_standards(mock_runner),
            []
        )

        mock_runner.run.assert_called_once_with([
            "/usr/sbin/crm_resource", "--list-standards"
        ])
示例#3
0
def list_agents_for_standard_and_provider(lib_env, standard_provider=None):
    """
    List resource agents for specified standard on the local host
    string standard_provider standard[:provider], e.g. None, ocf, ocf:pacemaker
    """
    if standard_provider:
        standards = [standard_provider]
    else:
        standards = resource_agent.list_resource_agents_standards(lib_env.cmd_runner())
    agents = []
    for std in standards:
        agents += resource_agent.list_resource_agents(lib_env.cmd_runner(), std)
    return sorted(
        agents,
        # works with both str and unicode in both python 2 and 3
        key=lambda x: x.lower(),
    )
示例#4
0
def list_standards(lib_env):
    """
    List resource agents standards (ocf, lsb, ... ) on the local host
    """
    return resource_agent.list_resource_agents_standards(lib_env.cmd_runner())