From 32fdb84956afe926253bc6f390701bbf56b1aaa7 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 26 Nov 2021 18:00:10 +0100 Subject: [PATCH] mgr/cephadm: simplify HostCache.get_daemon_types Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/configchecks.py | 2 +- src/pybind/mgr/cephadm/inventory.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) 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] -- 2.47.3