]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs_mirror: ceph fs snapshot mirror ls command
authorJos Collin <jcollin@redhat.com>
Wed, 31 Jul 2024 14:38:24 +0000 (20:08 +0530)
committerJos Collin <jcollin@redhat.com>
Tue, 8 Oct 2024 03:18:27 +0000 (08:48 +0530)
Fixes: https://tracker.ceph.com/issues/67292
Signed-off-by: Jos Collin <jcollin@redhat.com>
(cherry picked from commit 1c07a39a94deb7148a5061fa10612d40ea0ae469)

src/pybind/mgr/mirroring/fs/snapshot_mirror.py
src/pybind/mgr/mirroring/module.py

index 2bfb6482674e1b5b27f1bb8ad1d396973f685dda..c348ce82de1f46f3c6dcd8205e11cc3daaac50c0 100644 (file)
@@ -722,6 +722,20 @@ class FSSnapshotMirror:
         except Exception as e:
             return e.args[0], '', 'failed to remove directory'
 
+    def list_dirs(self, filesystem):
+        try:
+            with self.lock:
+                if not self.filesystem_exist(filesystem):
+                    raise MirrorException(-errno.ENOENT, f'filesystem {filesystem} does not exist')
+                fspolicy = self.pool_policy.get(filesystem, None)
+                if not fspolicy:
+                    raise MirrorException(-errno.EINVAL, f'filesystem {filesystem} is not mirrored')
+                return 0, json.dumps(list(fspolicy.policy.dir_states.keys()), indent=4, sort_keys=True), ''
+        except MirrorException as me:
+            return me.args[0], '', me.args[1]
+        except Exception as e:
+            return e.args[0], '', 'failed to list directories'
+
     def status(self,filesystem, dir_path):
         try:
             with self.lock:
index 4b4354ab2b9c4e0ede13153b2cac5d62f560137a..67f0942147e8845aa0896267b115bb7d659289d6 100644 (file)
@@ -84,6 +84,12 @@ class Module(MgrModule):
         """Remove a snapshot mirrored directory"""
         return self.fs_snapshot_mirror.remove_dir(fs_name, path)
 
+    @CLIWriteCommand('fs snapshot mirror ls')
+    def snapshot_mirror_ls(self,
+                           fs_name: str):
+        """List the snapshot mirrored directories"""
+        return self.fs_snapshot_mirror.list_dirs(fs_name)
+
     @CLIReadCommand('fs snapshot mirror dirmap')
     def snapshot_mirror_dirmap(self,
                                fs_name: str,