Skip to content

Commit

Permalink
cephadm:expose gather-facts orch api
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/51209

This PR intends to expose host metadata(gather-facts) orch api

Signed-off-by: Avan Thakkar <athakkar@redhat.com>
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
  • Loading branch information
Avan Thakkar authored and Aashish Sharma committed Jun 15, 2021
1 parent 9dabec8 commit 821eaa6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/pybind/mgr/cephadm/module.py
Expand Up @@ -1490,6 +1490,22 @@ def get_hosts(self):
"""
return list(self.inventory.all_specs())

@handle_orch_error
def get_gather_facts(self, hostname: Optional[str] = None):
# type: (str) -> 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)
gather_facts = []
for h in self.cache.get_hosts():
gather_facts.append(self.cache.get_facts(h))
return gather_facts

@handle_orch_error
def add_host_label(self, host: str, label: str) -> str:
self.inventory.add_label(host, label)
Expand Down
4 changes: 4 additions & 0 deletions src/pybind/mgr/dashboard/services/orchestrator.py
Expand Up @@ -62,6 +62,10 @@ def get(self, hostname: str) -> Optional[HostSpec]:
hosts = [host for host in self.list() if host.hostname == hostname]
return hosts[0] if hosts else None

@wait_api_result
def get_gather_facts(self, host: Optional[str] = None) -> List[Dict[str, Any]]:
return self.api.get_gather_facts(host)

@wait_api_result
def add(self, hostname: str, addr: str, labels: List[str], status: str):
return self.api.add_host(HostSpec(hostname, addr=addr, labels=labels, status=status))
Expand Down
8 changes: 8 additions & 0 deletions src/pybind/mgr/orchestrator/_interface.py
Expand Up @@ -368,6 +368,14 @@ def get_hosts(self) -> OrchResult[List[HostSpec]]:
"""
raise NotImplementedError()

def get_gather_facts(self, hostname: str) -> OrchResult[List[Dict[str, Any]]]:
"""
Return hosts metadata(gather_facts).
:param host: hostname
"""
raise NotImplementedError()

def add_host_label(self, host: str, label: str) -> OrchResult[str]:
"""
Add a host label
Expand Down

0 comments on commit 821eaa6

Please sign in to comment.