]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: add `ceph fs subvolumegroup getpath` command
authorRamana Raja <rraja@redhat.com>
Wed, 17 Jul 2019 12:01:22 +0000 (17:31 +0530)
committerRamana Raja <rraja@redhat.com>
Mon, 5 Aug 2019 12:43:13 +0000 (18:13 +0530)
... to return the path of a FS subvolume group.

Fixes: http://tracker.ceph.com/issues/40617
Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit 4ac6c2acc2b8d08dd00cf1463a62246bb8128ff4)

qa/tasks/cephfs/test_volumes.py
src/pybind/mgr/volumes/fs/volume.py
src/pybind/mgr/volumes/module.py

index 30756e99506c7b6ecfc86dbfdfa72906e737d164..be747e52b4f8b19a92580120f8de22cc3f4f92bf 100644 (file)
@@ -47,6 +47,12 @@ class TestVolumes(CephFSTestCase):
         else:
             self.volname = result[0]['name']
 
+    def  _get_subvolume_group_path(self, vol_name, group_name):
+        args = ("subvolumegroup", "getpath", vol_name, group_name)
+        path = self._fs_cmd(*args)
+        # remove the leading '/', and trailing whitespaces
+        return path[1:].rstrip()
+
     def  _get_subvolume_path(self, vol_name, subvol_name, group_name=None):
         args = ["subvolume", "getpath", vol_name, subvol_name]
         if group_name:
@@ -178,7 +184,7 @@ class TestVolumes(CephFSTestCase):
 
         # create group
         self._fs_cmd("subvolumegroup", "create", self.volname, group1)
-        group1_path = os.path.join('volumes', group1)
+        group1_path = self._get_subvolume_group_path(self.volname, group1)
 
         default_pool = self.mount_a.getfattr(group1_path, "ceph.dir.layout.pool")
         new_pool = "new_pool"
@@ -190,7 +196,7 @@ class TestVolumes(CephFSTestCase):
         # create group specifying the new data pool as its pool layout
         self._fs_cmd("subvolumegroup", "create", self.volname, group2,
                      "--pool_layout", new_pool)
-        group2_path = os.path.join('volumes', group2)
+        group2_path = self._get_subvolume_group_path(self.volname, group2)
 
         desired_pool = self.mount_a.getfattr(group2_path, "ceph.dir.layout.pool")
         self.assertEqual(desired_pool, new_pool)
@@ -242,8 +248,8 @@ class TestVolumes(CephFSTestCase):
         self._fs_cmd("subvolumegroup", "create", self.volname, group1)
         self._fs_cmd("subvolumegroup", "create", self.volname, group2, "--mode", "777")
 
-        group1_path = os.path.join('volumes', group1)
-        group2_path = os.path.join('volumes', group2)
+        group1_path = self._get_subvolume_group_path(self.volname, group1)
+        group2_path = self._get_subvolume_group_path(self.volname, group2)
 
         # check group's mode
         actual_mode1 = self.mount_a.run_shell(['stat', '-c' '%a', group1_path]).stdout.getvalue().strip()
index e3e4501c252875420cba502226fd82867bbdc84c..5cfb4fcb3e54dfd4d0227cecbd80e3c05af7c105 100644 (file)
@@ -507,6 +507,20 @@ class VolumeClient(object):
             ret = self.volume_exception_to_retval(ve)
         return ret
 
+    @connection_pool_wrap
+    def getpath_subvolume_group(self, fs_handle, **kwargs):
+        groupname  = kwargs['group_name']
+        try:
+            with SubVolume(self.mgr, fs_handle) as sv:
+                spec = SubvolumeSpec("", groupname)
+                path = sv.get_group_path(spec)
+                if path is None:
+                    raise VolumeException(
+                        -errno.ENOENT, "Subvolume group '{0}' not found".format(groupname))
+                return 0, path, ""
+        except VolumeException as ve:
+            return self.volume_exception_to_retval(ve)
+
     ### group snapshot
 
     @connection_pool_wrap
index 167b7e0044b17136cc9ca2dd75565275c9f85376..5d63fc56d216491883b0188ac0618c3975986a99 100644 (file)
@@ -83,6 +83,13 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                     "in a specific subvolume group",
             'perm': 'rw'
         },
+        {
+            'cmd': 'fs subvolumegroup getpath '
+                   'name=vol_name,type=CephString '
+                   'name=group_name,type=CephString ',
+            'desc': "Get the mountpath of a CephFS subvolume group in a volume",
+            'perm': 'r'
+        },
         {
             'cmd': 'fs subvolume getpath '
                    'name=vol_name,type=CephString '
@@ -231,6 +238,10 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                                         group_name=cmd.get('group_name', None),
                                         force=cmd.get('force', False))
 
+    def _cmd_fs_subvolumegroup_getpath(self, inbuf, cmd):
+        return self.vc.getpath_subvolume_group(
+                None, vol_name=cmd['vol_name'], group_name=cmd['group_name'])
+
     def _cmd_fs_subvolume_getpath(self, inbuf, cmd):
         return self.vc.subvolume_getpath(None, vol_name=cmd['vol_name'],
                                          sub_name=cmd['sub_name'],