]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/ssh: factor _run_ceph_daemon out of _get_device_inventory
authorSage Weil <sage@redhat.com>
Tue, 1 Oct 2019 16:35:38 +0000 (11:35 -0500)
committerSage Weil <sage@redhat.com>
Sat, 5 Oct 2019 01:33:35 +0000 (20:33 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/ssh/module.py

index 6bd28519c4648fc6c42dfc15c0bd12ba75505f6e..3139d41ef96f2ee0d25f9e666530da0920e5b294 100644 (file)
@@ -415,34 +415,33 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
         nodes = [orchestrator.InventoryNode(host_name, []) for host_name in self.inventory_cache]
         return orchestrator.TrivialReadCompletion(nodes)
 
-    def _get_device_inventory(self, host):
+    def _run_ceph_daemon(self, host, entity, command, args):
         """
-        Query storage devices on a remote node.
-
-        :return: list of InventoryDevice
+        Run ceph-daemon on the remote host with the given command + args
         """
         conn = self._get_connection(host)
 
         try:
-            ceph_volume_executable = self._executable_path(conn, 'podman')
+            # get container image
+            ret, image, err = self.mon_command({
+                'prefix': 'config get',
+                'who': entity,
+                'key': 'image',
+            })
+            image = image.strip()
+            self.log.debug('%s container image %s' % (entity, image))
+
             command = [
-                ceph_volume_executable,
-                'run',
-                '-it',
-                '--net=host',
-                '--privileged',
-                '--entrypoint',
-                '/usr/sbin/ceph-volume',
-                'ceph/daemon-base',
-                "inventory",
-                "--format=json"
-            ]
+                '/home/sage/src/ceph5/src/ceph-daemon',
+                '--image', image,
+                command,
+                '--fsid', self.get('mon_map')['fsid'],
+            ] + args
 
             out, err, code = remoto.process.check(conn, command)
-            # stdout and stderr get combined; assume last line is the real
-            # output and everything preceding it is an error.
-            host_devices = json.loads(out[-1])
-            return host_devices
+            # ceph-daemon combines stdout and stderr, so ignore err.
+            self.log.debug('code %s out %s' % (code, out))
+            return out, code
 
         except Exception as ex:
             self.log.exception(ex)
@@ -478,7 +477,13 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
 
             if host_info.outdated(timeout_min) or refresh:
                 self.log.info("refresh stale inventory for '{}'".format(host))
-                data = self._get_device_inventory(host)
+                out, code = self._run_ceph_daemon(
+                    host, 'osd',
+                    'ceph-volume',
+                    ['--', 'inventory', '--format=json'])
+                # stdout and stderr get combined; assume last line is the real
+                # output and everything preceding it is an error.
+                data = json.loads(out[-1])
                 host_info = orchestrator.OutdatableData(data)
                 self.inventory_cache[host] = host_info
             else: