]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: add customize_container_mounts method to nfs class
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 4 Nov 2023 23:24:48 +0000 (19:24 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 11 Nov 2023 13:10:49 +0000 (08:10 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_nfs.py

index 0ad3bb8b0192389458a0bca4fc8d57573d182970..48c50e779b86c37aa51c33fb76a2872a5d5de1e3 100755 (executable)
@@ -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)
index 0649ef934c1699cb8e55c9ed823bcd393aba3c4b..94ab6afcfdf92a2abc973e0b88b15101c61892f1 100644 (file)
@@ -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"