"""
return list(self.inventory.all_specs())
+ @handle_orch_error
+ def get_facts(self, hostname: Optional[str] = None) -> List[Dict[str, Any]]:
+ """
+ Return a list of hosts metadata(gather_facts) managed by the orchestrator.
+
+ Notes:
+ - skip async: manager reads from cache.
+ """
+ if hostname:
+ return [self.cache.get_facts(hostname)]
+
+ return [self.cache.get_facts(hostname) for hostname in self.cache.get_hosts()]
+
@handle_orch_error
def add_host_label(self, host: str, label: str) -> str:
self.inventory.add_label(host, label)
--- /dev/null
+import pytest
+
+from ..inventory import HostCache
+from ..import CephadmOrchestrator
+
+
+@pytest.fixture()
+def test_facts():
+ facts = {'node-1.ceph.com', {'bios_version': 'F2', 'cpu_cores': 16}}
+ HostCache.facts = facts
+ ret_facts = CephadmOrchestrator.get_facts('node-1.ceph.com')
+ assert ret_facts == [{'bios_version': 'F2', 'cpu_cores': 16}]
def add(self, hostname: str, addr: str, labels: List[str]):
return self.api.add_host(HostSpec(hostname, addr=addr, labels=labels))
+ @wait_api_result
+ def get_facts(self, hostname: Optional[str] = None) -> List[Dict[str, Any]]:
+ return self.api.get_facts(hostname)
+
@wait_api_result
def remove(self, hostname: str):
return self.api.remove_host(hostname)
"""
raise NotImplementedError()
+ def get_facts(self, hostname: Optional[str] = None) -> OrchResult[List[Dict[str, Any]]]:
+ """
+ Return hosts metadata(gather_facts).
+ """
+ raise NotImplementedError()
+
def add_host_label(self, host: str, label: str) -> OrchResult[str]:
"""
Add a host label