From: Venky Shankar Date: Tue, 14 Jan 2020 09:10:22 +0000 (-0500) Subject: mgr/volumes: helper for looking up a clone entry index X-Git-Tag: v15.2.0~26^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2dc41ea2db423b1e8178d41ce2fef6ca0eeccf32;p=ceph.git mgr/volumes: helper for looking up a clone entry index ... this would be used when canceling a clone operation to find the clone index for a given clone. Signed-off-by: Venky Shankar --- diff --git a/src/pybind/mgr/volumes/fs/operations/clone_index.py b/src/pybind/mgr/volumes/fs/operations/clone_index.py index 068a97a9de58b..a2b31f858e067 100644 --- a/src/pybind/mgr/volumes/fs/operations/clone_index.py +++ b/src/pybind/mgr/volumes/fs/operations/clone_index.py @@ -67,6 +67,20 @@ class CloneIndex(Index): raise IndexException(-e.args[0], e.args[1]) return None + def find_clone_entry_index(self, sink_path): + try: + for entry in list_one_entry_at_a_time(self.fs, self.path): + dname = entry.d_name + dpath = os.path.join(self.path, dname) + st = self.fs.lstat(dpath) + if stat.S_ISLNK(st.st_mode): + target_path = self.fs.readlink(dpath, CloneIndex.PATH_MAX) + if sink_path == target_path[:st.st_size]: + return dname + return None + except cephfs.Error as e: + raise IndexException(-e.args[0], e.args[1]) + def create_clone_index(fs, vol_spec): clone_index = CloneIndex(fs, vol_spec) try: