From afb991e7431b42f096b57e4693c33b11f1082ed9 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Sat, 29 Aug 2020 21:21:56 +0200 Subject: [PATCH] mgr/cephadm: CephadmDaemonSpec: add ceph_conf attribute * `extra_config` should actually be called `extra_files` * Special treatment for `ceph_conf` to ease refactorization Signed-off-by: Sebastian Wagner (cherry picked from commit 75aa97ee3fec290682afde9eb5a3254db2104ece) --- .../mgr/cephadm/services/cephadmservice.py | 22 ++++++++++++++----- src/pybind/mgr/cephadm/services/iscsi.py | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index 70d4be20f55dc..1abf63e5dadba 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -29,7 +29,8 @@ class CephadmDaemonSpec(Generic[ServiceSpecs]): network: Optional[str] = None, keyring: Optional[str] = None, extra_args: Optional[List[str]] = None, - extra_config: Optional[Dict[str, Any]] = None, + ceph_conf: str = '', + extra_files: Optional[Dict[str, Any]] = None, daemon_type: Optional[str] = None, ports: Optional[List[int]] = None,): """ @@ -56,7 +57,9 @@ class CephadmDaemonSpec(Generic[ServiceSpecs]): # For run_cephadm. Would be great to have more expressive names. self.extra_args: List[str] = extra_args or [] - self.extra_config: Dict[str, Any] = extra_config or {} + + self.ceph_conf = ceph_conf + self.extra_files = extra_files or {} # TCP ports used by the daemon self.ports: List[int] = ports or [] @@ -64,6 +67,13 @@ class CephadmDaemonSpec(Generic[ServiceSpecs]): def name(self) -> str: return '%s.%s' % (self.daemon_type, self.daemon_id) + def config_get_files(self): + files = self.extra_files + if self.ceph_conf: + files['config'] = self.ceph_conf + + return files + class CephadmService(metaclass=ABCMeta): """ @@ -235,10 +245,10 @@ class CephService(CephadmService): daemon_spec.daemon_id, host=daemon_spec.host, keyring=daemon_spec.keyring, - extra_ceph_config=daemon_spec.extra_config.pop('config', '')) + extra_ceph_config=daemon_spec.ceph_conf) - if daemon_spec.extra_config: - cephadm_config.update({'files': daemon_spec.extra_config}) + if daemon_spec.config_get_files(): + cephadm_config.update({'files': daemon_spec.config_get_files()}) return cephadm_config, [] @@ -353,7 +363,7 @@ class MonService(CephService): 'public_network is set but does not look like a CIDR network: \'%s\'' % network) extra_config += 'public network = %s\n' % network - daemon_spec.extra_config = {'config': extra_config} + daemon_spec.ceph_conf = extra_config daemon_spec.keyring = keyring return daemon_spec diff --git a/src/pybind/mgr/cephadm/services/iscsi.py b/src/pybind/mgr/cephadm/services/iscsi.py index d32210504c7d1..77cdf01a76aba 100644 --- a/src/pybind/mgr/cephadm/services/iscsi.py +++ b/src/pybind/mgr/cephadm/services/iscsi.py @@ -68,7 +68,7 @@ class IscsiService(CephService): igw_conf = self.mgr.template.render('services/iscsi/iscsi-gateway.cfg.j2', context) daemon_spec.keyring = keyring - daemon_spec.extra_config = {'iscsi-gateway.cfg': igw_conf} + daemon_spec.extra_files = {'iscsi-gateway.cfg': igw_conf} return daemon_spec -- 2.39.5