]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ssh: simplify getting the cluster fsid
authorSage Weil <sage@redhat.com>
Thu, 3 Oct 2019 21:15:08 +0000 (16:15 -0500)
committerSage Weil <sage@redhat.com>
Sat, 5 Oct 2019 01:33:35 +0000 (20:33 -0500)
This never changes, so just stash it once.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/ssh/module.py

index 86519810cc6459e85ec5d5fe023d0d23a4bed509..6d933261d5accd811f706aad1e7adb4b2bd7bc3e 100644 (file)
@@ -129,7 +129,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
 
     def __init__(self, *args, **kwargs):
         super(SSHOrchestrator, self).__init__(*args, **kwargs)
-        self._cluster_fsid = None
+        self._cluster_fsid = self.get('mon_map')['fsid']
 
         path = self.get_ceph_option('ceph_daemon_path')
         try:
@@ -234,15 +234,6 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
 
         return complete
 
-    def _get_cluster_fsid(self):
-        """
-        Fetch and cache the cluster fsid.
-        """
-        if not self._cluster_fsid:
-            self._cluster_fsid = self.get("mon_map")["fsid"]
-        assert isinstance(self._cluster_fsid, six.string_types)
-        return self._cluster_fsid
-
     def _require_hosts(self, hosts):
         """
         Raise an error if any of the given hosts are unregistered.
@@ -372,7 +363,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
             final_args = [
                 '--image', image,
                 command,
-                '--fsid', self.get('mon_map')['fsid'],
+                '--fsid', self._cluster_fsid,
             ] + args
 
             script = 'injected_argv = ' + json.dumps(final_args) + '\n'
@@ -476,7 +467,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
                     '--config-and-keyring', '-',
                     '--',
                     'lvm', 'prepare',
-                    "--cluster-fsid", self._get_cluster_fsid(),
+                    "--cluster-fsid", self._cluster_fsid,
                     "--{}".format(drive_group.objectstore),
                     "--data", device,
                 ],
@@ -494,7 +485,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
         self.log.debug('code %s out %s' % (code, out))
         j = json.loads('\n'.join(out))
         self.log.debug('j %s' % j)
-        fsid = self.get('mon_map')['fsid']
+        fsid = self._cluster_fsid
         for osd_id, osds in j.items():
             for osd in osds:
                 if osd['tags']['ceph.cluster_fsid'] != fsid: