]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
add snap rename in python wrapper
authorxinxin shu <xinxin.shu@intel.com>
Wed, 26 Aug 2015 09:06:26 +0000 (17:06 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Wed, 2 Sep 2015 23:52:28 +0000 (07:52 +0800)
Signed-off-by: xinxin shu <xinxin.shu@intel.com>
src/pybind/rbd.py

index b570a00ebd636880311109c2580b49718faf2031..9b8664ca14c81c1fafa77b75a5c5289706e752f3 100644 (file)
@@ -670,6 +670,24 @@ class Image(object):
         if ret != 0:
             raise make_ex(ret, 'error creating snapshot %s from %s' % (name, self.name))
 
+    def rename_snap(self, srcname, dstname):
+        """
+        rename a snapshot of the image.
+
+        :param srcname: the src name of the snapshot
+        :type srcname: str
+        :param dstname: the dst name of the snapshot
+        :type dstname: str
+        :raises: :class:`ImageExists`
+        """
+        if not isinstance(srcname, str):
+            raise TypeError('src name must be a string')
+        if not isinstance(dstname, str):
+            raise TypeError('dst name must be a string')
+        ret = self.librbd.rbd_snap_rename(self.image, c_char_p(srcname), c_char_p(dstname))
+        if ret != 0:
+            raise make_ex(ret, 'error renaming snapshot of %s from %s to %s' % (self.name, srcname, dstname))
+
     def remove_snap(self, name):
         """
         Delete a snapshot of the image.