def test_success(self): mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = ( "\n".join([ "fence_xvm", "fence_wti", "fence_vmware_soap", "fence_virt", "fence_scsi", "", ]), "", 0 ) self.assertEqual( lib_ra.list_stonith_agents(mock_runner), [ "fence_scsi", "fence_virt", "fence_vmware_soap", "fence_wti", "fence_xvm", ] ) mock_runner.run.assert_called_once_with([ "/usr/sbin/crm_resource", "--list-agents", "stonith" ])
def test_filter_hidden_agents(self): mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = ("\n".join([ "fence_na", "fence_wti", "fence_scsi", "fence_vmware_helper", "fence_nss_wrapper", "fence_node", "fence_vmware_soap", "fence_virt", "fence_pcmk", "fence_sanlockd", "fence_xvm", "fence_ack_manual", "fence_legacy", "fence_check", "fence_tool", "fence_kdump_send", "fence_virtd", "", ]), "", 0) self.assertEqual(lib_ra.list_stonith_agents(mock_runner), [ "fence_scsi", "fence_virt", "fence_vmware_soap", "fence_wti", "fence_xvm", ]) mock_runner.run.assert_called_once_with( ["/usr/sbin/crm_resource", "--list-agents", "stonith"])
def test_no_agents(self): mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = ( "", "No agents found for standard=stonith provider=*", 1) self.assertEqual(lib_ra.list_stonith_agents(mock_runner), []) mock_runner.run.assert_called_once_with( ["/usr/sbin/crm_resource", "--list-agents", "stonith"])
def list_agents(lib_env, describe=True, search=None): """ List all stonith agents on the local host, optionally filtered and described bool describe load and return agents' description as well string search return only agents which name contains this string """ runner = lib_env.cmd_runner() agent_names = resource_agent.list_stonith_agents(runner) return _complete_agent_list(runner, agent_names, describe, search, resource_agent.StonithAgent)
def list_agents(lib_env, describe=True, search=None): """ List all stonith agents on the local host, optionally filtered and described bool describe load and return agents' description as well string search return only agents which name contains this string """ runner = lib_env.cmd_runner() agent_names = resource_agent.list_stonith_agents(runner) return _complete_agent_list( runner, agent_names, describe, search, resource_agent.StonithAgent )
def list_agents( lib_env: LibraryEnvironment, describe: bool = True, search: Optional[str] = None, ) -> List[Dict[str, Any]]: """ List all stonith agents on the local host, optionally filtered and described describe -- load and return agents' description as well search -- return only agents which name contains this string """ runner = lib_env.cmd_runner() agent_names = resource_agent.list_stonith_agents(runner) return _complete_agent_list( runner, agent_names, describe, search, resource_agent.StonithAgent )
def test_no_agents(self): mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = ( "", "No agents found for standard=stonith provider=*", 1 ) self.assertEqual( lib_ra.list_stonith_agents(mock_runner), [] ) mock_runner.run.assert_called_once_with([ "/usr/sbin/crm_resource", "--list-agents", "stonith" ])
def test_filter_hidden_agents(self): mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = ( "\n".join([ "fence_na", "fence_wti", "fence_scsi", "fence_vmware_helper", "fence_nss_wrapper", "fence_node", "fence_vmware_soap", "fence_virt", "fence_pcmk", "fence_sanlockd", "fence_xvm", "fence_ack_manual", "fence_legacy", "fence_check", "fence_tool", "fence_kdump_send", "fence_virtd", "", ]), "", 0 ) self.assertEqual( lib_ra.list_stonith_agents(mock_runner), [ "fence_scsi", "fence_virt", "fence_vmware_soap", "fence_wti", "fence_xvm", ] ) mock_runner.run.assert_called_once_with([ "/usr/sbin/crm_resource", "--list-agents", "stonith" ])