From: Sage Weil Date: Tue, 16 Feb 2021 23:05:37 +0000 (-0500) Subject: mgr/cephadm: use get_foreign_ceph_option() instead of 'config get' mon command X-Git-Tag: v17.1.0~2900^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9b5cbf40f8328060d7c6d04a474ee87d5bf03ca3;p=ceph.git mgr/cephadm: use get_foreign_ceph_option() instead of 'config get' mon command Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index c2737505b3ff..5d90ac542f07 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1136,12 +1136,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, daemon_type == 'nfs' or \ daemon_type == 'iscsi': # get container image - ret, image, err = self.check_mon_command({ - 'prefix': 'config get', - 'who': utils.name_to_config_section(daemon_name), - 'key': 'container_image', - }) - image = image.strip() + image = str(self.get_foreign_ceph_option( + utils.name_to_config_section(daemon_name), + 'container_image' + )).strip() elif daemon_type == 'prometheus': image = self.container_image_prometheus elif daemon_type == 'grafana': diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 93b48b5d3ca2..9fb9ffc324ee 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -471,11 +471,7 @@ class CephadmServe: public_network = None if service_type == 'mon': - ret, out, err = self.mgr.check_mon_command({ - 'prefix': 'config get', - 'who': 'mon', - 'key': 'public_network', - }) + out = str(self.mgr.get_foreign_ceph_option('mon', 'public_network')) if '/' in out: public_network = out.strip() self.log.debug('mon public_network is %s' % public_network) diff --git a/src/pybind/mgr/tests/__init__.py b/src/pybind/mgr/tests/__init__.py index 8afdbe32e1c0..d4ab4d52de6f 100644 --- a/src/pybind/mgr/tests/__init__.py +++ b/src/pybind/mgr/tests/__init__.py @@ -147,6 +147,15 @@ if 'UNITTEST' in os.environ: res.complete(0, outb, '') + def _ceph_get_foreign_option(self, entity, name): + who = entity.split('.') + whos = ['global'] + ['.'.join(who[:i+1]) for i in range(len(who))] + for attepmt in reversed(whos): + val = self.mock_store_get('config', f'{attepmt}/{name}', None) + if val is not None: + return val + return None + def assert_issued_mon_command(self, command): assert command in self._mon_commands_sent, self._mon_commands_sent