From: Sebastian Wagner Date: Fri, 26 Nov 2021 17:00:10 +0000 (+0100) Subject: mgr/cephadm: simplify HostCache.get_daemon_types X-Git-Tag: v17.1.0~343^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44118%2Fhead;p=ceph.git mgr/cephadm: simplify HostCache.get_daemon_types Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/configchecks.py b/src/pybind/mgr/cephadm/configchecks.py index af80bd2619f..6e7b53f09e4 100644 --- a/src/pybind/mgr/cephadm/configchecks.py +++ b/src/pybind/mgr/cephadm/configchecks.py @@ -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') diff --git a/src/pybind/mgr/cephadm/inventory.py b/src/pybind/mgr/cephadm/inventory.py index c0673f1c504..3fa28ef0514 100644 --- a/src/pybind/mgr/cephadm/inventory.py +++ b/src/pybind/mgr/cephadm/inventory.py @@ -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]