]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: add support for image create timestamp
authorrunsisi <runsisi@zte.com.cn>
Fri, 21 Apr 2017 08:59:21 +0000 (16:59 +0800)
committerrunsisi <runsisi@zte.com.cn>
Tue, 20 Jun 2017 05:52:06 +0000 (13:52 +0800)
Signed-off-by: runsisi <runsisi@zte.com.cn>
src/pybind/rbd/rbd.pyx

index ec090dba86190ab706d47754099585a2148fb34f..8de6b3cab844fdbe24d14ec2fae30dd48243f099 100644 (file)
@@ -228,6 +228,7 @@ cdef extern from "rbd/librbd.h" nogil:
                             uint8_t enabled)
     int rbd_get_stripe_unit(rbd_image_t image, uint64_t *stripe_unit)
     int rbd_get_stripe_count(rbd_image_t image, uint64_t *stripe_count)
+    int rbd_get_create_timestamp(rbd_image_t image, timespec *timestamp)
     int rbd_get_overlap(rbd_image_t image, uint64_t *overlap)
     int rbd_get_id(rbd_image_t image, char *id, size_t id_len)
     int rbd_get_block_name_prefix(rbd_image_t image, char *prefix,
@@ -2166,6 +2167,18 @@ written." % (self.name, ret, length))
             raise make_ex(ret, 'error getting stripe count for image %s' % (self.name))
         return stripe_count
 
+    def create_timestamp(self):
+        """
+        Returns the create timestamp for the image.
+        """
+        cdef:
+            timespec timestamp
+        with nogil:
+            ret = rbd_get_create_timestamp(self.image, &timestamp)
+        if ret != 0:
+            raise make_ex(ret, 'error getting create timestamp for image: %s' % (self.name))
+        return datetime.fromtimestamp(timestamp.tv_sec)
+
     def flatten(self):
         """
         Flatten clone image (copy all blocks from parent to child)