Change in vdsm[master]: gluster: volume snapshot create and delete verbs.

dnarayan at redhat.com dnarayan at redhat.com
Tue Oct 28 09:28:51 UTC 2014


Darshan N has uploaded a new change for review.

Change subject: gluster: volume snapshot create and delete verbs.
......................................................................

gluster: volume snapshot create and delete verbs.

This patch adds two new verbs to create and delete
gluster volume snapshots.

*glusterSnapshotCreate: creates gluster volume
snapshot. It returns uuid of the created snapshot.

*glusterSnapshotDelete: deletes gluster volume
snapshot. Returns success/failure.

Change-Id: Ia2d1f1b2f2a675c5407222cb267a7560927ae84f
Signed-off-by: Darshan n <dnarayan at redhat.com>
---
M client/vdsClientGluster.py
M vdsm.spec.in
M vdsm/gluster/api.py
M vdsm/gluster/apiwrapper.py
M vdsm/gluster/cli.py
M vdsm/gluster/exception.py
M vdsm/rpc/vdsmapi-gluster-schema.json
7 files changed, 161 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/34535/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 421c853..49bac0f 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -430,6 +430,28 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterSnapshotCreate(self, args):
+        params = self._eqSplit(args)
+        volumeName = params.get('volumeName', '')
+        snapName = params.get('snapName', '')
+        description = params.get('description', '')
+        force = (params.get('force', 'no').upper() == 'YES')
+
+        status = self.s.glusterSnapshotCreate(volumeName,
+                                              snapName,
+                                              description,
+                                              force)
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
+    def do_glusterSnapshotDelete(self, args):
+        params = self._eqSplit(args)
+        snapName = params.get('snapName', '')
+
+        status = self.s.glusterSnapshotDelete(snapName)
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -731,4 +753,16 @@
              ('volumeName=<volume name>',
               'Returns total, free and used space(bytes) of gluster volume'
               )),
+         'glusterVolumeSnapshotCreate': (
+             serv.do_glusterSnapshotCreate,
+             ('volumeName=<volume_name> snapName=<snap_name> '
+              '[description=<description>] '
+              '[force={yes|no}]',
+              'create gluster volume snapshot'
+              )),
+         'glusterVolumeSnapshotDelete': (
+             serv.do_glusterSnapshotDelete,
+             ('snapName=<snap_name>',
+              'delete snapshot'
+              )),
          }
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 4b49a8e..00fb56b 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -236,7 +236,7 @@
 
 # GlusterFS client-side RPMs needed for Gluster SD
 %if 0%{?with_gluster}
-Requires: glusterfs >= 3.4.2
+Requires: glusterfs >= 3.6
 Requires: glusterfs-cli
 Requires: glusterfs-api
 Requires: glusterfs-fuse
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index b9a08e5..92bdb74 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -322,6 +322,20 @@
         data = self.svdsmProxy.glusterVolumeStatvfs(volumeName)
         return self._computeVolumeStats(data)
 
+    @exportAsVerb
+    def snapshotCreate(self, volumeName, snapName,
+                       description=None, force=False):
+        return self.svdsmProxy.glusterSnapshotCreate(
+            volumeName,
+            snapName,
+            description,
+            force
+        )
+
+    @exportAsVerb
+    def snapshotDelete(self, snapName):
+        self.svdsmProxy.glusterSnapshotDelete(snapName)
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/apiwrapper.py b/vdsm/gluster/apiwrapper.py
index c45fc57..9639c6c 100644
--- a/vdsm/gluster/apiwrapper.py
+++ b/vdsm/gluster/apiwrapper.py
@@ -178,3 +178,15 @@
 
     def rebalanceStatus(self, volumeName):
         return self._gluster.volumeRebalanceStatus(volumeName)
+
+
+class GlusterSnapshot(GlusterApiBase):
+    def __init__(self):
+        GlusterApiBase.__init__(self)
+
+    def create(self, volumeName, snapName, description=None, force=False):
+        return self._gluster.snapshotCreate(volumeName, snapName,
+                                            description, force)
+
+    def delete(self, snapName):
+        return self._gluster.snapshotDelete(snapName)
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index 2e1c9a9..10c6cb2 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -49,6 +49,10 @@
     return [_glusterCommandPath.cmd, "system::"]
 
 
+def _getGlusterSnapshotCmd():
+    return [_glusterCommandPath.cmd, "--mode=script", "snapshot"]
+
+
 class BrickStatus:
     PAUSED = 'PAUSED'
     COMPLETED = 'COMPLETED'
@@ -1054,3 +1058,32 @@
         return _parseVolumeTasks(xmltree)
     except _etreeExceptions:
         raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+ at makePublic
+def snapshotCreate(volumeName, snapName, description=None, force=False):
+    command = _getGlusterSnapshotCmd() + ["create", snapName, volumeName]
+
+    if description:
+        command += ['description', description]
+    if force:
+        command.append('force')
+
+    try:
+        xmltree = _execGlusterXml(command)
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterSnapshotCreateFailedException(rc=e.rc, err=e.err)
+    try:
+        return {'uuid': xmltree.find('snapCreate/snapshot/uuid').text}
+    except _etreeExceptions:
+        raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+ at makePublic
+def snapshotDelete(snapName):
+    command = _getGlusterSnapshotCmd() + ["delete", snapName]
+    try:
+        _execGlusterXml(command)
+        return True
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterSnapshotDeleteFailedException(rc=e.rc, err=e.err)
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index 0205cb1..e4e6b7d 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -506,3 +506,21 @@
 class GlfsFiniException(GlusterLibgfapiException):
     code = 4573
     message = "glfs fini failed"
+
+
+# Volume Snapshot
+class GlusterSnapshotException(GlusterException):
+    code = 4600
+    message = "Gluster Volume Snapshot Exception"
+
+
+class GlusterSnapshotCreateFailedException(
+        GlusterSnapshotException):
+    code = 4601
+    message = "Snapshot create failed"
+
+
+class GlusterSnapshotDeleteFailedException(
+        GlusterSnapshotException):
+    code = 4602
+    message = "Snapshot delete failed"
diff --git a/vdsm/rpc/vdsmapi-gluster-schema.json b/vdsm/rpc/vdsmapi-gluster-schema.json
index 4ddd182..a3e5ff8 100644
--- a/vdsm/rpc/vdsmapi-gluster-schema.json
+++ b/vdsm/rpc/vdsmapi-gluster-schema.json
@@ -1238,3 +1238,52 @@
 {'command': {'class': 'GlusterVolume', 'name': 'statsInfoGet'},
  'data': {'volumeName': 'str'},
  'returns': 'GlusterVolumeStatsInfo'}
+
+## Category: @GlusterSnapshot ######################################################
+##
+# @GlusterSnapshot:
+#
+# Gluster snapshot object.
+#
+# Since: 4.16
+##
+{'class': 'GlusterSnapshot'}
+
+##
+# @GlusterSnapshot.create:
+#
+# Create a Gluster volume snapshot
+#
+# @volumeName: Gluster volume name
+#
+# @snapName: Snapsot name
+#
+# @description: #optional Description for the snapshot
+#
+# @force: #optional Force create snapshot
+#
+# Returns:
+# uuid of the snapshot
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterSnapshot', 'name': 'create'},
+ 'data': {'volumeName': 'str', 'snapName': 'str',
+          '*description': 'str', '*force': 'bool'},
+ 'returns': 'UUID'}
+
+##
+# @GlusterSnapshot.delete:
+#
+# Delete the volume snapshot
+#
+# @snapName: Gluster volume snapshot name
+#
+# Returns:
+# success/failure
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterSnapshot', 'name': 'delete'},
+ 'data': {'snapName': 'str'},
+ 'returns': 'bool'}


-- 
To view, visit http://gerrit.ovirt.org/34535
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2d1f1b2f2a675c5407222cb267a7560927ae84f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Darshan N <dnarayan at redhat.com>


More information about the vdsm-patches mailing list