Change in vdsm[master]: gluster: volume snapshot config set and get verbs.

dnarayan at redhat.com dnarayan at redhat.com
Mon Nov 3 08:43:12 UTC 2014


Darshan N has uploaded a new change for review.

Change subject: gluster: volume snapshot config set and get verbs.
......................................................................

gluster: volume snapshot config set and get verbs.

This patch adds two new verbs to get and set the
configuration of gluster volume snapshots.

*glusterSnapshotConfigGet: get the snapshot configuration.
Volume name can be provided as an optional argument,
if volume name is given configuration for that volume is
listed along with system snapshot configuration
Returns:
    {'systemConfig':{'hardLimit': 'hardLimit',
                     'softLimit': 'softLimit',
                     'autoDelete': 'enable/disable'},
     'volumeConfig':[{'name': 'volume name',
                      'hardLimit': 'hardLimit',
                      'effectiveHardLimit': 'effectiveHardLimit',
                      'softLimit': 'softLimit'}]
    }

*glusterSnapshotConfigSet: Set snapshot configuration.
The possible configurations that can be set are:
snap-max-hard-limit for gluster volume and
snap-max-hard-limit, snap-max-soft-limit and auto-delete
at system leval.
Returns:
    success/failure

Change-Id: Iee32a95cf028cda33f25776c08820c5ed80f1033
Signed-off-by: Darshan n <dnarayan at redhat.com>
---
M client/vdsClientGluster.py
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
6 files changed, 201 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/34741/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index bdd7a6c..05e0566 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -452,6 +452,30 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterSnapshotConfigGet(self, args):
+        params = self._eqSplit(args)
+        volumeName = params.get('volumeName', '')
+
+        status = self.s.glusterSnapshotConfigGet(volumeName)
+
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
+    def do_glusterSnapshotConfigSet(self, args):
+        params = self._eqSplit(args)
+        volumeName = params.get('volumeName', '')
+        snapMaxHardLimit = params.get('snapMaxHardLimit', '')
+        snapMaxSoftLimit = params.get('snapMaxSoftLimit', '')
+        autoDelete = params.get('autoDelete', '')
+
+        status = self.s.glusterSnapshotConfigSet(volumeName,
+                                                 snapMaxHardLimit,
+                                                 snapMaxSoftLimit,
+                                                 autoDelete)
+
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -765,4 +789,17 @@
              ('snapName=<snap_name>',
               'delete snapshot'
               )),
+         'glusterSnapshotConfigGet': (
+             serv.do_glusterSnapshotConfigGet,
+             ('[volumeName=<volume_name>]',
+              'get gluster volume snapshot configuration'
+              )),
+         'glusterSnapshotConfigSet': (
+             serv.do_glusterSnapshotConfigSet,
+             ('[volumeName=<volume_name>]'
+              '[snapMaxHardLimit=<snapMaxHardLimit>]'
+              '[snapMaxSoftLimit=<snapMaxSoftLimit>]'
+              '[autoDelete=<enable|disable>]',
+              'Set gluster volume snapshot configuration'
+              )),
          }
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 92bdb74..c183883 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -336,6 +336,18 @@
     def snapshotDelete(self, snapName):
         self.svdsmProxy.glusterSnapshotDelete(snapName)
 
+    @exportAsVerb
+    def snapshotConfigGet(self, volumeName=None):
+        return self.svdsmProxy.glusterSnapshotConfigGet(volumeName)
+
+    @exportAsVerb
+    def snapshotConfigSet(self, volumeName=None, snapMaxHardLimit=None,
+                          snapMaxSoftLimit=None, autoDelete="enable"):
+        self.svdsmProxy.glusterSnapshotConfigSet(volumeName,
+                                                 snapMaxHardLimit,
+                                                 snapMaxSoftLimit,
+                                                 autoDelete)
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/apiwrapper.py b/vdsm/gluster/apiwrapper.py
index 9639c6c..6d7c4ef 100644
--- a/vdsm/gluster/apiwrapper.py
+++ b/vdsm/gluster/apiwrapper.py
@@ -190,3 +190,13 @@
 
     def delete(self, snapName):
         return self._gluster.snapshotDelete(snapName)
+
+    def ConfigGet(self, volumeName=None):
+        return self._gluster.snapshotConfigGet(volumeName)
+
+    def ConfigSet(self, volumeName=None, snapConfigHardLimit=None,
+                  snapConfigSoftLimit=None, autoDelete="enable"):
+        return self._gluster.snapshotConfigSet(volumeName,
+                                               snapConfigHardLimit,
+                                               snapConfigSoftLimit,
+                                               autoDelete)
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index 10c6cb2..56d5db6 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -1087,3 +1087,76 @@
         return True
     except ge.GlusterCmdFailedException as e:
         raise ge.GlusterSnapshotDeleteFailedException(rc=e.rc, err=e.err)
+
+
+def _parseSnapshotConfigGet(tree):
+    """
+    returns {'systemConfig':{'hardLimit': 'hardlimit',
+                             'softLimit': 'softLimit',
+                             'autodelete': 'enable/disable'},
+              volumeConfig':[{'name': 'volume name',
+                              'hardLimit: 'hardlimit',
+                              'effectiveHardLimit: 'effectiveHardlimit',
+                              'softLimit': 'softLimit'}]
+            }
+    """
+
+    systemConfig = {}
+    systemConfig['hardLimit'] = tree.find(
+        'snapConfig/systemConfig/hardLimit').text
+    systemConfig['SoftLimit'] = tree.find(
+        'snapConfig/systemConfig/softLimit').text
+    systemConfig['autoDelete'] = tree.find(
+        'snapConfig/systemConfig/autoDelete').text
+
+    volumeConfig = []
+    for el in tree.findall('snapConfig/volumeConfig/volume'):
+        volume = {}
+        volume['name'] = el.find('name').text
+        volume['hardLimit'] = el.find('hardLimit').text
+        volume['effectiveHardLimit'] = el.find('effectiveHardLimit').text
+        volume['softLimit'] = el.find('softLimit').text
+        volumeConfig.append(volume)
+
+    return {'systemConfig': systemConfig, 'volumeConfig': volumeConfig}
+
+
+ at makePublic
+def snapshotConfigGet(volumeName=None):
+    command = _getGlusterSnapshotCmd() + ["config"]
+
+    if volumeName:
+        command.append(volumeName)
+
+    try:
+        xmltree = _execGlusterXml(command)
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterSnapshotConfigGetFailedException(rc=e.rc, err=e.err)
+    try:
+        return _parseSnapshotConfigGet(xmltree)
+    except _etreeExceptions:
+        raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+ at makePublic
+def snapshotConfigSet(volumeName=None, snapMaxHardLimit=None,
+                      snapMaxSoftLimit=None, autoDelete="enable"):
+    command = _getGlusterSnapshotCmd() + ["config"]
+
+    if volumeName:
+        if snapMaxHardLimit:
+            command += [volumeName, "snap-max-hard-limit", snapMaxHardLimit]
+    else:
+        if snapMaxHardLimit or snapMaxSoftLimit:
+            if snapMaxHardLimit:
+                command += ["snap-max-hard-limit", snapMaxHardLimit]
+            if snapMaxSoftLimit:
+                command += ["snap-max-soft-limit", snapMaxSoftLimit]
+        else:
+                command += ["auto-delete", autoDelete]
+
+    try:
+        _execGlusterXml(command)
+        return True
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterSnapshotConfigSetFailedException(rc=e.rc, err=e.err)
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index e4e6b7d..23cef31 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -524,3 +524,15 @@
         GlusterSnapshotException):
     code = 4602
     message = "Snapshot delete failed"
+
+
+class GlusterSnapshotConfigGetFailedException(
+        GlusterSnapshotException):
+    code = 4608
+    message = "Snapshot config get failed"
+
+
+class GlusterSnapshotConfigSetFailedException(
+        GlusterSnapshotException):
+    code = 4609
+    message = "Snapshot config set failed"
diff --git a/vdsm/rpc/vdsmapi-gluster-schema.json b/vdsm/rpc/vdsmapi-gluster-schema.json
index a3e5ff8..c04287f 100644
--- a/vdsm/rpc/vdsmapi-gluster-schema.json
+++ b/vdsm/rpc/vdsmapi-gluster-schema.json
@@ -1287,3 +1287,60 @@
 {'command': {'class': 'GlusterSnapshot', 'name': 'delete'},
  'data': {'snapName': 'str'},
  'returns': 'bool'}
+
+##
+# @AutoDeleteOption:
+#
+# Possible value of autoDelete
+#
+# @enabled: autodelete option is enabled
+#
+# @disabled: autodelete option is disabled
+#
+# Since: 4.10.3
+##
+{'enum': 'AutoDeleteOption',
+ 'data': ['enabled', 'disabled']}
+
+##
+# @GlusterSnapshot.configGet:
+#
+# get the  config values of snapshot
+#
+# @volumeName:#optional Gluster volume name
+#
+# @systemConfig: configuration related to system
+#
+# @volumeConfig: configuration related to config
+#
+# Returns:
+# configuration related to system and volume
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterSnapshot', 'name': 'configGet'},
+ 'data': {'*volumeName': 'str'},
+ 'returns': {'systemConfig': {'hardLimit': 'int', 'softLimit': 'int', 'autoDelete': 'AutoDeleteOption'}, 'volumeConfig': [{'name': 'str', 'hardLimit': 'int', 'softLimit': 'int', 'effectiveHardLimit': 'int'}]}}
+
+##
+# @GlusterSnapshot.configSet:
+#
+# set gluster volume snapshot config
+#
+# @volumeName: #optional Gluster volume name
+#
+# @snapMaxHardLimit: hard limit for number of snapshot
+#
+# @snapMaxSoftLimit: soft limit for number of snapshot
+#
+# @autoDelete: autodelete option
+#
+# Returns:
+# success/failure
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterSnapshot', 'name': 'configSet'},
+ 'data': {'*volumeName': 'str', '*snapMaxHardLimit': 'int',
+          '*snapMaxSoftLimit': 'int', 'autoDelete': 'AutoDeleteOption'},
+ 'returns': 'bool'}


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee32a95cf028cda33f25776c08820c5ed80f1033
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