mgr/cephadm: simplify HostCache.get_daemon_types

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
This commit is contained in:
Sebastian Wagner 2021-11-26 18:00:10 +01:00
parent d770bb5c45
commit 32fdb84956
No known key found for this signature in database
GPG Key ID: 8D2442807E6979F8
2 changed files with 3 additions and 7 deletions

View File

@ -671,7 +671,7 @@ class CephadmConfigChecks:
self.log.warning(f"Host gather facts for {hostname} is missing kernel information")
# NOTE: if daemondescription had systemd enabled state, we could check for systemd 'tampering'
self.host_to_role[hostname] = self.mgr.cache.get_daemon_types(hostname)
self.host_to_role[hostname] = list(self.mgr.cache.get_daemon_types(hostname))
def run_checks(self) -> None:
checks_enabled = self.mgr.get_module_option('config_checks_enabled')

View File

@ -870,13 +870,9 @@ class HostCache():
return [d for d in daemons if d.daemon_type in service_to_daemon_types(service_type)]
def get_daemon_types(self, hostname: str) -> List[str]:
def get_daemon_types(self, hostname: str) -> Set[str]:
"""Provide a list of the types of daemons on the host"""
result = set()
for _d, dm in self.daemons[hostname].items():
assert dm.daemon_type is not None, f'no daemon type for {dm!r}'
result.add(dm.daemon_type)
return list(result)
return cast(Set[str], {d.daemon_type for d in self.daemons[hostname].values()})
def get_daemon_names(self):
# type: () -> List[str]