Skip to content

Commit 3e70066

Browse files
qa/cephfs: use "snapshot getpath" cmd instead of constructing...
the path to a specific snapshot wherever possible. Signed-off-by: Rishabh Dave <[email protected]>
1 parent 8cecbc2 commit 3e70066

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

qa/tasks/cephfs/test_volumes.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,15 @@ def _wait_for_clone_to_be_in_progress(self, clone, clone_group=None, timo=120):
9595
def _check_clone_canceled(self, clone, clone_group=None):
9696
self.__check_clone_state("canceled", clone, clone_group, timo=1)
9797

98-
def _get_subvolume_snapshot_path(self, subvolume, snapshot, source_group, subvol_path, source_version):
99-
if source_version == 2:
100-
# v2
101-
if subvol_path is not None:
102-
(base_path, uuid_str) = os.path.split(subvol_path)
103-
else:
104-
(base_path, uuid_str) = os.path.split(self._get_subvolume_path(self.volname, subvolume, group_name=source_group))
105-
return os.path.join(base_path, ".snap", snapshot, uuid_str)
98+
def _get_subvolume_snapshot_path(self, subvol_name, snap_name, group_name):
99+
cmd = (f'fs subvolume snapshot getpath {self.volname} {subvol_name} '
100+
f'{snap_name}')
101+
if group_name:
102+
cmd += f' {group_name}'
106103

107-
# v1
108-
base_path = self._get_subvolume_path(self.volname, subvolume, group_name=source_group)
109-
return os.path.join(base_path, ".snap", snapshot)
104+
cephfs_snap_path = self.get_ceph_cmd_stdout(cmd).strip()
105+
# remove leading '/' from cephfs_snap_path
106+
return os.path.join(self.mount_a.hostfs_mntpt, cephfs_snap_path[1:])
110107

111108
def _verify_clone_attrs(self, source_path, clone_path):
112109
path1 = source_path
@@ -168,7 +165,7 @@ def _verify_clone(self, subvolume, snapshot, clone,
168165
subvol_path=None, source_version=2, timo=120):
169166
# pass in subvol_path (subvolume path when snapshot was taken) when subvolume is removed
170167
# but snapshots are retained for clone verification
171-
path1 = self._get_subvolume_snapshot_path(subvolume, snapshot, source_group, subvol_path, source_version)
168+
path1 = self._get_subvolume_snapshot_path(subvolume, snapshot, source_group)
172169
path2 = self._get_subvolume_path(self.volname, clone, group_name=clone_group)
173170

174171
check = 0

0 commit comments

Comments
 (0)