From: John Mulligan Date: Sat, 4 Nov 2023 23:24:48 +0000 (-0400) Subject: cephadm: add customize_container_mounts method to nfs class X-Git-Tag: v19.0.0~92^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8acdacd789790892b8e958e3d293b3133161ceb6;p=ceph-ci.git cephadm: add customize_container_mounts method to nfs class Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 0ad3bb8b019..48c50e779b8 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -910,7 +910,7 @@ class NFSGanesha(ContainerDaemonForm): def identity(self) -> DaemonIdentity: return DaemonIdentity(self.fsid, self.daemon_type, self.daemon_id) - def get_container_mounts(self, data_dir): + def _get_container_mounts(self, data_dir): # type: (str) -> Dict[str, str] mounts = dict() mounts[os.path.join(data_dir, 'config')] = '/etc/ceph/ceph.conf:z' @@ -923,6 +923,12 @@ class NFSGanesha(ContainerDaemonForm): '/var/lib/ceph/radosgw/%s-%s/keyring:z' % (cluster, rgw_user) return mounts + def customize_container_mounts( + self, ctx: CephadmContext, mounts: Dict[str, str] + ) -> None: + data_dir = self.identity.data_dir(ctx.data_dir) + mounts.update(self._get_container_mounts(data_dir)) + @staticmethod def get_container_envs(): # type: () -> List[str] @@ -2684,8 +2690,8 @@ def get_container_mounts( paths given a daemon identity. Setting `no_config` will skip mapping a daemon specific ceph.conf file. """ - # unpack fsid and daemon_type from ident because they're used very frequently - fsid, daemon_type = ident.fsid, ident.daemon_type + # unpack daemon_type from ident because they're used very frequently + daemon_type = ident.daemon_type mounts: Dict[str, str] = {} assert ident.fsid @@ -2699,9 +2705,8 @@ def get_container_mounts( mounts.update(monitoring.get_container_mounts(data_dir)) if daemon_type == NFSGanesha.daemon_type: - data_dir = ident.data_dir(ctx.data_dir) - nfs_ganesha = NFSGanesha.init(ctx, fsid, ident.daemon_id) - mounts.update(nfs_ganesha.get_container_mounts(data_dir)) + nfs_ganesha = NFSGanesha.create(ctx, ident) + nfs_ganesha.customize_container_mounts(ctx, mounts) if daemon_type == HAproxy.daemon_type: haproxy = HAproxy.create(ctx, ident) diff --git a/src/cephadm/tests/test_nfs.py b/src/cephadm/tests/test_nfs.py index 0649ef934c1..94ab6afcfdf 100644 --- a/src/cephadm/tests/test_nfs.py +++ b/src/cephadm/tests/test_nfs.py @@ -117,7 +117,7 @@ def test_nfsganesha_container_mounts(): "fred", good_nfs_json(), ) - cmounts = nfsg.get_container_mounts("/var/tmp") + cmounts = nfsg._get_container_mounts("/var/tmp") assert len(cmounts) == 3 assert cmounts["/var/tmp/config"] == "/etc/ceph/ceph.conf:z" assert cmounts["/var/tmp/keyring"] == "/etc/ceph/keyring:z" @@ -130,7 +130,7 @@ def test_nfsganesha_container_mounts(): "fred", nfs_json(pool=True, files=True, rgw=True), ) - cmounts = nfsg.get_container_mounts("/var/tmp") + cmounts = nfsg._get_container_mounts("/var/tmp") assert len(cmounts) == 4 assert cmounts["/var/tmp/config"] == "/etc/ceph/ceph.conf:z" assert cmounts["/var/tmp/keyring"] == "/etc/ceph/keyring:z"