From 1fd58b318e747c3824ce2ec7f129788450a3c5e7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 3 Oct 2019 16:15:08 -0500 Subject: [PATCH] mgr/ssh: simplify getting the cluster fsid This never changes, so just stash it once. Signed-off-by: Sage Weil --- src/pybind/mgr/ssh/module.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 86519810cc645..6d933261d5acc 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -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: -- 2.39.5