Change in vdsm[master]: gluster: use rebalance cli xml output

barumuga at redhat.com barumuga at redhat.com
Wed Mar 13 12:15:50 UTC 2013


Hello Timothy Asir, Saggi Mizrahi, Aravinda VK, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/13003

to review the following change.

Change subject: gluster: use rebalance cli xml output
......................................................................

gluster: use rebalance cli xml output

glusterVolumeRebalanceStart and glusterVolumeRebalanceStop use gluster
cli xml output than stdout parsing.

glusterVolumeRebalanceStart is not consumed by engine/RHS-C yet, its
OK to differ in compatibility issue now.

Change-Id: I4c3f1328245fd8fb2338d03cec477ea059f3b389
Signed-off-by: Bala.FA <barumuga at redhat.com>
---
M vdsm/gluster/api.py
M vdsm/gluster/cli.py
M vdsm_cli/vdsClientGluster.py
3 files changed, 35 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/13003/1

diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 5f0b0ed..cc58c3f 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -95,9 +95,9 @@
     @exportAsVerb
     def volumeRebalanceStart(self, volumeName, rebalanceType="",
                              force=False, options=None):
-        self.svdsmProxy.glusterVolumeRebalanceStart(volumeName,
-                                                    rebalanceType,
-                                                    force)
+        return self.svdsmProxy.glusterVolumeRebalanceStart(volumeName,
+                                                           rebalanceType,
+                                                           force)
 
     @exportAsVerb
     def volumeRebalanceStop(self, volumeName, force=False, options=None):
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index 13a5694..9123b6b 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -560,11 +560,15 @@
     command.append("start")
     if force:
         command.append("force")
-    rc, out, err = _execGluster(command)
-    if rc:
-        raise ge.GlusterVolumeRebalanceStartFailedException(rc, out, err)
-    else:
-        return True
+    try:
+        xmltree = _execGlusterXml(command)
+    except ge.GlusterCmdFailedException, e:
+        raise ge.GlusterVolumeRebalanceStartFailedException(rc=e.rc,
+                                                            err=e.err)
+    try:
+        return {'taskId': xmltree.find('volRebalance/task-id').text}
+    except _etreeExceptions:
+        raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
 
 
 @exportToSuperVdsm
@@ -572,11 +576,12 @@
     command = _getGlusterVolCmd() + ["rebalance", volumeName, "stop"]
     if force:
         command.append('force')
-    rc, out, err = _execGluster(command)
-    if rc:
-        raise ge.GlusterVolumeRebalanceStopFailedException(rc, out, err)
-    else:
+    try:
+        _execGlusterXml(command)
         return True
+    except ge.GlusterCmdFailedException, e:
+        raise ge.GlusterVolumeRebalanceStopFailedException(rc=e.rc,
+                                                           err=e.err)
 
 
 @exportToSuperVdsm
diff --git a/vdsm_cli/vdsClientGluster.py b/vdsm_cli/vdsClientGluster.py
index be47696..b746188 100644
--- a/vdsm_cli/vdsClientGluster.py
+++ b/vdsm_cli/vdsClientGluster.py
@@ -112,19 +112,23 @@
         return status['status']['code'], status['status']['message']
 
     def do_glusterVolumeRebalanceStart(self, args):
-        params = self._eqSplit(args[1:])
-        rebalanceType = params.get('type', 'fix-layout')
-        force = params.get('force', False)
-        status = self.s.glusterVolumeRebalanceStart(args[0],
-                                                    rebalanceType, force)
+        params = self._eqSplit(args)
+        volumeName = params.get('volumeName', '')
+        rebalanceType = params.get('rebalanceType', '')
+        force = (params.get('force', 'no').upper() == 'YES')
+
+        status = self.s.glusterVolumeRebalanceStart(volumeName,
+                                                    rebalanceType,
+                                                    force)
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
     def do_glusterVolumeRebalanceStop(self, args):
-        params = self._eqSplit(args[1:])
-        force = params.get('force', False)
-        status = self.s.glusterVolumeRebalanceStop(args[0], force)
-        pp.pprint(status)
+        params = self._eqSplit(args)
+        volumeName = params.get('volumeName', '')
+        force = (params.get('force', 'no').upper() == 'YES')
+
+        status = self.s.glusterVolumeRebalanceStop(volumeName, force)
         return status['status']['code'], status['status']['message']
 
     def do_glusterVolumeRebalanceStatus(self, args):
@@ -338,12 +342,15 @@
               )),
          'glusterVolumeRebalanceStart': (
              serv.do_glusterVolumeRebalanceStart,
-             ('<volume_name>\n\t<volume_name> is existing volume name',
+             ('volumeName=<volume_name> [rebalanceType=fix-layout] '
+              '[force={yes|no}]\n\t'
+              '<volume_name> is existing volume name',
               'start volume rebalance'
               )),
          'glusterVolumeRebalanceStop': (
              serv.do_glusterVolumeRebalanceStop,
-             ('<volume_name>\n\t<volume_name> is existing volume name',
+             ('volumeName=<volume_name> [force={yes|no}]\n\t'
+              '<volume_name> is existing volume name',
               'stop volume rebalance'
               )),
          'glusterVolumeRebalanceStatus': (


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c3f1328245fd8fb2338d03cec477ea059f3b389
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Bala.FA <barumuga at redhat.com>
Gerrit-Reviewer: Aravinda VK <avishwan at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Timothy Asir <tjeyasin at redhat.com>


More information about the vdsm-patches mailing list