mgr/cephadm: move _get_daemons() impl into list_daemons
authorSage Weil <sage@redhat.com>
Fri, 14 Feb 2020 17:13:03 +0000 (11:13 -0600)
committerSage Weil <sage@redhat.com>
Tue, 18 Feb 2020 21:50:00 +0000 (15:50 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py

index c11a9c4ffc0df729e09f8870c6b80483abdb06b1..04f6e414abe25e5bc956b3bc514ab7efcb215a13 100644 (file)
@@ -1302,32 +1302,6 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         }
         return host, dm
 
-    def _get_daemons(self,
-                     daemon_type=None,
-                     daemon_id=None,
-                     service_name=None,
-                     want_host=None,
-                     refresh=False):
-        if refresh:
-            ######### FIXME #########
-            raise NotImplementedError()
-        result = []
-        self.log.debug('_get_daemons')
-        for host, info in self.daemon_cache.items():
-            self.log.debug('_get_daemons info %s' % info)
-            if want_host and host != want_host:
-                continue
-            for name, dd in info.get('daemons', {}).items():
-                if daemon_type and daemon_type != dd.daemon_type:
-                    continue
-                if daemon_id and daemon_id != dd.daemon_id:
-                    continue
-                if service_name and not dd.name().startswith(service_name + '.'):
-                    continue
-                result.append(dd)
-        self.log.debug('_get_daemons returns %s' % result)
-        return trivial_result(result)
-
 #    def describe_service(self, service_type=None, service_id=None,
 #                         node_name=None, refresh=False):
 #        if service_type not in ("mds", "osd", "mgr", "mon", 'rgw', "nfs", None):
@@ -1341,11 +1315,20 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
 
     def list_daemons(self, daemon_type=None, daemon_id=None,
                      host=None, refresh=False):
-        result = self._get_daemons(daemon_type=daemon_type,
-                                   daemon_id=daemon_id,
-                                   want_host=host,
-                                   refresh=refresh)
-        return result
+        if refresh:
+            ######### FIXME #########
+            raise NotImplementedError()
+        result = []
+        for h, di in self.daemon_cache.items():
+            if host and h != host:
+                continue
+            for name, dd in di['daemons'].items():
+                if daemon_type and daemon_type != dd.daemon_type:
+                    continue
+                if daemon_id and daemon_id != dd.daemon_id:
+                    continue
+                result.append(dd)
+        return trivial_result(result)
 
     def service_action(self, action, service_type, service_name):
         self.log.debug('service_action action %s type %s name %s' % (