]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: introduce volume specification module
authorVenky Shankar <vshankar@redhat.com>
Wed, 20 Nov 2019 13:27:11 +0000 (08:27 -0500)
committerRamana Raja <rraja@redhat.com>
Wed, 12 Feb 2020 10:11:59 +0000 (05:11 -0500)
unlike existing subvolume specification, this is just a
minimal set of globally available configurations. bulk
of other configurations will be moved to the respective
entity modules (subsequent commits).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 0039b5d90142c9eedd23af3c5dbf2c21bcb56823)

src/pybind/mgr/volumes/fs/vol_spec.py [new file with mode: 0644]

diff --git a/src/pybind/mgr/volumes/fs/vol_spec.py b/src/pybind/mgr/volumes/fs/vol_spec.py
new file mode 100644 (file)
index 0000000..e18ab06
--- /dev/null
@@ -0,0 +1,37 @@
+import os
+
+class VolSpec(object):
+    """
+    specification of a "volume" -- base directory and various prefixes.
+    """
+
+    # where shall we (by default) create subvolumes
+    DEFAULT_SUBVOL_PREFIX = "/volumes"
+    # and the default namespace
+    DEFAULT_NS_PREFIX = "fsvolumens_"
+
+    def __init__(self, snapshot_prefix, subvolume_prefix=None, pool_ns_prefix=None):
+        self.snapshot_prefix = snapshot_prefix
+        self.subvolume_prefix = subvolume_prefix if subvolume_prefix else VolSpec.DEFAULT_SUBVOL_PREFIX
+        self.pool_ns_prefix = pool_ns_prefix if pool_ns_prefix else VolSpec.DEFAULT_NS_PREFIX
+
+    @property
+    def snapshot_dir_prefix(self):
+        """
+        Return the snapshot directory prefix
+        """
+        return self.snapshot_prefix
+
+    @property
+    def base_dir(self):
+        """
+        Return the top level directory under which subvolumes/groups are created
+        """
+        return self.subvolume_prefix
+
+    @property
+    def fs_namespace(self):
+        """
+        return a filesystem namespace by stashing pool namespace prefix and subvolume-id
+        """
+        return self.pool_ns_prefix