Change in vdsm[master]: vdsm-gluster: Added gluster volume geo-replication start verb

tjeyasin at redhat.com tjeyasin at redhat.com
Wed Aug 7 11:43:12 UTC 2013


Hello Ayal Baron, Bala.FA, Saggi Mizrahi, Dan Kenigsberg,

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

    http://gerrit.ovirt.org/17766

to review the following change.

Change subject: vdsm-gluster: Added gluster volume geo-replication start verb
......................................................................

vdsm-gluster: Added gluster volume geo-replication start verb

Start the geo-replication session between the hosts.

Start distributed geo-replication on all the nodes that are a part
of the master-volume. Even if any node, that is a part of the
master-volume is down, the command will still be successful.

Change-Id: I3cf03c748cf9fe28efe7d407727cd52da20701c5
Signed-off-by: Timothy Asir <tjeyasin at redhat.com>
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/cli.py
M vdsm/gluster/exception.py
4 files changed, 100 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/17766/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 90af83e..feb6387 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -424,6 +424,34 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterVolumeGeoRepStart(self, args):
+        params = self._eqSplit(args)
+        masterVolName = params.get('masterVolName', '')
+        slaveHost = params.get('slaveHost', '')
+        slaveVolName = params.get('slaveVolName', '')
+        if not(masterVolName and slaveHost and slaveVolName):
+            raise ValueError
+
+        status = self.s.glusterVolumeGeoRepStart(masterVolName,
+                                                 slaveHost,
+                                                 slaveVolName)
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
+    def do_glusterVolumeGeoRepStop(self, args):
+        params = self._eqSplit(args)
+        masterVolName = params.get('masterVolName', '')
+        slaveHost = params.get('slaveHost', '')
+        slaveVolName = params.get('slaveVolName', '')
+        if not(masterVolName and slaveHost and slaveVolName):
+            raise ValueError
+
+        status = self.s.glusterVolumeGeoRepStop(masterVolName,
+                                                slaveHost,
+                                                slaveVolName)
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -705,4 +733,26 @@
               'not set'
               '(swift, glusterd, smb, memcached)'
               )),
+         'glusterVolumeGeoRepStart': (
+             serv.do_glusterVolumeGeoRepStart,
+             ('masterVolName=<master_volume_name> slaveHost=<slave_host> '
+              'slaveVolName=<slave_volume_name>\n\t'
+              '<master_volume_name> is an existing volume name in the '
+              'master node\n\t'
+              '<slave_host> is slave host name\n\t'
+              '<slave_volume_name> is an existing volume name in the '
+              'slave node',
+              'start volume geo-replication'
+              )),
+         'glusterVolumeGeoRepStop': (
+             serv.do_glusterVolumeGeoRepStop,
+             ('masterVolName=<master_volume_name> slaveHost=<slave_host> '
+              'slaveVolName=<slave_volume_name>\n\t'
+              '<master_volume_name> is an existing volume name in the '
+              'master node\n\t'
+              '<slave_host> is slave host name\n\t'
+              '<slave_volume_name> is an existing volume name in the '
+              'slave node',
+              'stop volume geo-replication'
+              )),
          }
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 4bd8308..ed9f5ae 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -287,6 +287,20 @@
         status = self.svdsmProxy.glusterServicesGet(serviceNames)
         return {'services': status}
 
+    @exportAsVerb
+    def volumeGeoRepStart(self, masterVolName, slaveHost, slaveVolName,
+                          options=None):
+        self.svdsmProxy.glusterVolumeGeoRepStart(masterVolName,
+                                                 slaveHost,
+                                                 slaveVolName)
+
+    @exportAsVerb
+    def volumeGeoRepStop(self, masterVolName, slaveHost, slaveVolName,
+                         options=None):
+        self.svdsmProxy.glusterVolumeGeoRepStop(masterVolName,
+                                                slaveHost,
+                                                slaveVolName)
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index bac6d1c..e4d6615 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -897,3 +897,29 @@
         return _parseVolumeProfileInfo(xmltree, nfs)
     except _etreeExceptions:
         raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+ at makePublic
+def volumeGeoRepStart(masterVolName, slaveHost, slaveVolName):
+    command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+                                     "%s::%s" % (slaveHost, slaveVolName),
+                                     "start"]
+    try:
+        _execGlusterXml(command)
+        return True
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterVolumeGeoRepStartFailedException(rc=e.rc,
+                                                         err=e.err)
+
+
+ at makePublic
+def volumeGeoRepStop(masterVolName, slaveHost, slaveVolName):
+    command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+                                     "%s::%s" % (slaveHost, slaveVolName),
+                                     "stop"]
+    try:
+        _execGlusterXml(command)
+        return True
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterVolumeGeoRepStopFailedException(rc=e.rc,
+                                                        err=e.err)
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index c569a9e..259df32 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -484,3 +484,13 @@
         prefix = "%s: " % (action)
         self.message = prefix + "Service action is not supported"
         self.err = [self.message]
+
+
+class GlusterVolumeGeoRepStartFailedException(GlusterVolumeException):
+    code = 4164
+    message = "Volume geo-replication start failed"
+
+
+class GlusterVolumeGeoRepStopFailedException(GlusterVolumeException):
+    code = 4165
+    message = "Volume geo-replication stop failed"


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

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


More information about the vdsm-patches mailing list