]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_volume_client: create/delete VMeta for create/delete volume
authorRamana Raja <rraja@redhat.com>
Thu, 23 Jun 2016 11:01:23 +0000 (16:31 +0530)
committerRamana Raja <rraja@redhat.com>
Tue, 2 Aug 2016 10:57:57 +0000 (16:27 +0530)
Create and delete volume meta files during creation and deletion of
volumes.

Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit 37fbfc7aa8f10d37f5202603a906425507271ff5)

src/pybind/ceph_volume_client.py

index 174b4b85cceedbb37228d5c22f09c8f5c2c0961e..1a5b3dc21d4b569124cd50542eff69c52036bf69 100644 (file)
@@ -231,7 +231,6 @@ class CephFSVolumeClient(object):
         # UUID
         self._id = struct.unpack(">Q", uuid.uuid1().get_bytes()[0:8])[0]
 
-        # TODO: remove .meta files on volume deletion
         # TODO: remove .meta files on last rule for an auth ID deletion
         # TODO: version the on-disk structures
 
@@ -608,6 +607,12 @@ class CephFSVolumeClient(object):
         log.info("create_volume: {0}, using rados namespace {1} to isolate data.".format(volume_path, namespace))
         self.fs.setxattr(path, 'ceph.dir.layout.pool_namespace', namespace, 0)
 
+        # Create a volume meta file, if it does not already exist, to store
+        # data about auth ids having access to the volume
+        fd = self.fs.open(self._volume_metadata_path(volume_path),
+                          os.O_CREAT, 0755)
+        self.fs.close(fd)
+
         return {
             'mount_path': path
         }
@@ -641,6 +646,13 @@ class CephFSVolumeClient(object):
         else:
             self.fs.rename(path, trashed_volume)
 
+        # Delete the volume meta file, if it's not already deleted
+        vol_meta_path = self._volume_metadata_path(volume_path)
+        try:
+            self.fs.unlink(vol_meta_path)
+        except cephfs.ObjectNotFound:
+            pass
+
     def purge_volume(self, volume_path, data_isolated=False):
         """
         Finish clearing up a volume that was previously passed to delete_volume.  This