]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
orchestrator_cli: add an orchestrator service ls function
authorJeff Layton <jlayton@redhat.com>
Tue, 30 Oct 2018 18:28:02 +0000 (14:28 -0400)
committerJeff Layton <jlayton@redhat.com>
Thu, 15 Nov 2018 12:27:51 +0000 (07:27 -0500)
There's currently no way to enumerate the services that the
orchestrator backend knows about. Add a "service ls" command
that will list them with some basic info, subject to filters
given on the command line.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
doc/mgr/orchestrator_cli.rst
src/pybind/mgr/orchestrator_cli/module.py

index cbd2b317525dd72d30f028dcacdef2e81e675c0b..55a76d7fa37c03049ec48b5268d3788d82fada02 100644 (file)
@@ -43,6 +43,15 @@ filtered to a particular node:
 
     orchestrator device ls [node]
 
+Print a list of services known to the orchestrator. The list can be limited to
+services on a particular host with the optional --host parameter and/or
+services of a particular type via optional --type parameter
+(mon, osd, mgr, mds, rgw):
+
+::
+
+    orchestrator service ls [--host=host] [--type=type]
+
 Query the status of a particular service (mon, osd, mgr, mds, rgw).  For OSDs
 the id is the numeric OSD ID, for MDS services it is the filesystem name:
 
index b727efcfd26d3523bdeedbc53ef3a8d620bfdf5b..d442cb72c13c20e3e775e59f95532377edd65204 100644 (file)
@@ -20,6 +20,13 @@ class OrchestratorCli(MgrModule):
             "desc": "List devices on a node",
             "perm": "r"
         },
+        {
+            'cmd': "orchestrator service ls "
+                   "name=host,type=CephString,req=false "
+                   "name=type,type=CephString,req=false ",
+            "desc": "List services known to orchestrator" ,
+            "perm": "r"
+        },
         {
             'cmd': "orchestrator service status "
                    "name=svc_type,type=CephString "
@@ -118,6 +125,29 @@ class OrchestratorCli(MgrModule):
 
         return 0, result, ""
 
+    def _list_services(self, cmd):
+        hostname = cmd.get('host', None)
+        service_type = cmd.get('type', None)
+
+        completion = self._oremote("describe_service", service_type, None, hostname)
+        self._wait([completion])
+        services = completion.result
+
+        if len(services) == 0:
+            return 0, "", "No services reported"
+        else:
+            # Sort the list for display
+            services.sort(key = lambda s: (s.service_type, s.nodename, s.daemon_name))
+            lines = []
+            for s in services:
+                lines.append("{0}.{1} {2} {3}".format(
+                    s.service_type,
+                    s.daemon_name,
+                    s.nodename,
+                    s.container_id))
+
+            return 0, "\n".join(lines), ""
+
     def _service_status(self, cmd):
         svc_type = cmd['svc_type']
         svc_id = cmd['svc_id']
@@ -125,7 +155,7 @@ class OrchestratorCli(MgrModule):
         # XXX this is kind of confusing for people because in the orchestrator
         # context the service ID for MDS is the filesystem ID, not the daemon ID
 
-        completion = self._oremote("describe_service", svc_type, svc_id)
+        completion = self._oremote("describe_service", svc_type, svc_id, None)
 
         self._wait([completion])
 
@@ -275,6 +305,8 @@ class OrchestratorCli(MgrModule):
     def _handle_command(self, _, cmd):
         if cmd['prefix'] == "orchestrator device ls":
             return self._list_devices(cmd)
+        elif cmd['prefix'] == "orchestrator service ls":
+            return self._list_services(cmd)
         elif cmd['prefix'] == "orchestrator service status":
             return self._service_status(cmd)
         elif cmd['prefix'] == "orchestrator service add":