]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ssh: move some code around
authorSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 14:01:30 +0000 (09:01 -0500)
committerSage Weil <sage@redhat.com>
Thu, 31 Oct 2019 19:25:05 +0000 (14:25 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/ssh/module.py

index 88918463df037ce0786a2a2c00f1416e5b84ac12..e78b83256bdb591e798a7055f8d7c8cfca40d51c 100644 (file)
@@ -351,6 +351,54 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
             executable_path))
         return executable_path
 
+    def _run_ceph_daemon(self, host, entity, command, args,
+                         stdin=None,
+                         no_fsid=False):
+        """
+        Run ceph-daemon on the remote host with the given command + args
+        """
+        conn = self._get_connection(host)
+
+        try:
+            # get container image
+            ret, image, err = self.mon_command({
+                'prefix': 'config get',
+                'who': entity,
+                'key': 'container_image',
+            })
+            image = image.strip()
+            self.log.debug('%s container image %s' % (entity, image))
+
+            final_args = [
+                '--image', image,
+                command
+            ]
+            if not no_fsid:
+                final_args += ['--fsid', self._cluster_fsid]
+            final_args += args
+            self.log.debug('args: %s' % final_args)
+            self.log.debug('stdin: %s' % stdin)
+
+            script = 'injected_argv = ' + json.dumps(final_args) + '\n'
+            if stdin:
+                script += 'injected_stdin = ' + json.dumps(stdin) + '\n'
+            script += self._ceph_daemon
+            #self.log.debug('script is %s' % script)
+
+            out, err, code = remoto.process.check(
+                conn,
+                ['/usr/bin/python', '-u'],
+                stdin=script.encode('utf-8'))
+            self.log.debug('exit code %s out %s err %s' % (code, out, err))
+            return out, code
+
+        except Exception as ex:
+            self.log.exception(ex)
+            raise
+
+        finally:
+            conn.exit()
+
     def _get_hosts(self, wanted=None):
         return self.inventory_cache.items_filtered(wanted)
 
@@ -445,54 +493,6 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
         result = self._get_services(service_type, service_id, node_name)
         return orchestrator.TrivialReadCompletion(result)
 
-    def _run_ceph_daemon(self, host, entity, command, args,
-                         stdin=None,
-                         no_fsid=False):
-        """
-        Run ceph-daemon on the remote host with the given command + args
-        """
-        conn = self._get_connection(host)
-
-        try:
-            # get container image
-            ret, image, err = self.mon_command({
-                'prefix': 'config get',
-                'who': entity,
-                'key': 'container_image',
-            })
-            image = image.strip()
-            self.log.debug('%s container image %s' % (entity, image))
-
-            final_args = [
-                '--image', image,
-                command
-            ]
-            if not no_fsid:
-                final_args += ['--fsid', self._cluster_fsid]
-            final_args += args
-            self.log.debug('args: %s' % final_args)
-            self.log.debug('stdin: %s' % stdin)
-
-            script = 'injected_argv = ' + json.dumps(final_args) + '\n'
-            if stdin:
-                script += 'injected_stdin = ' + json.dumps(stdin) + '\n'
-            script += self._ceph_daemon
-            #self.log.debug('script is %s' % script)
-
-            out, err, code = remoto.process.check(
-                conn,
-                ['/usr/bin/python', '-u'],
-                stdin=script.encode('utf-8'))
-            self.log.debug('exit code %s out %s err %s' % (code, out, err))
-            return out, code
-
-        except Exception as ex:
-            self.log.exception(ex)
-            raise
-
-        finally:
-            conn.exit()
-
     def get_inventory(self, node_filter=None, refresh=False):
         """
         Return the storage inventory of nodes matching the given filter.