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

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

    http://gerrit.ovirt.org/17650

to review the following change.

Change subject: vdsm-gluster: Added gluster volume geo-replication create 
push-pem verb
......................................................................

vdsm-gluster: Added gluster volume geo-replication create push-pem verb

Create the geo-replication session. The push-pem option is needed to
perform the necessary pem-file setup on the slave nodes.

Change-Id: I4f0b7ba685918bf147eb291c2bbe90527b965416
Signed-off-by: Timothy Asir <[email protected]>
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/cli.py
M vdsm/gluster/exception.py
4 files changed, 69 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/17650/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 90af83e..e5f036d 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -424,6 +424,27 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterVolumeGeoRepCreatePushPem(self, args):
+        params = self._eqSplit(args)
+        try:
+            masterVolName = params.get('masterVolName', '')
+            slaveHost = params.get('slaveHost', '')
+            slaveVolName = params.get('slaveVolName', '')
+            force = (params.get('force', 'no').upper() == 'YES')
+
+        except:
+            raise ValueError
+
+        if not (masterVolName and slaveHost and slaveVolName):
+            raise ValueError
+
+        status = self.s.glusterVolumeGeoRepCreatePushPem(masterVolName,
+                                                         slaveHost,
+                                                         slaveVolName,
+                                                         force)
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -705,4 +726,15 @@
               'not set'
               '(swift, glusterd, smb, memcached)'
               )),
+         'glusterVolumeGeoRepCreatePushPem': (
+             serv.do_glusterVolumeGeoRepCreatePushPem,
+             ('masterVolName=<master_volume_name> '
+              'slaveHost=<slave_host_name> '
+              'slaveVolName=<slave_volume_name> '
+              '[force={yes|no}]\n\t'
+              '<master_volume_name> is an existing volume name in the master 
node\n\t'
+              '<slave_host_name> is remote slave host name or ip\n\t'
+              '<slave_volume_name> is an available existing volume name in the 
slave node', 
+              'Create the geo-replication session'
+              )),
          }
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 4bd8308..422ab0f 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -287,6 +287,17 @@
         status = self.svdsmProxy.glusterServicesGet(serviceNames)
         return {'services': status}
 
+    @exportAsVerb
+    def volumeGeoRepCreatePushPem(self, masterVolName, slaveHost,
+                                  slaveVolName, force=True,
+                                  options=None):
+        status = self.svdsmProxy.glusterVolumeGeoRepCreatePushPem(
+            masterVolName,
+            slaveHost,
+            slaveVolName,
+            force=True)
+        return {'geo-rep': status}
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index bac6d1c..33a06ec 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -897,3 +897,18 @@
         return _parseVolumeProfileInfo(xmltree, nfs)
     except _etreeExceptions:
         raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+@makePublic
+def volumeGeoRepCreatePushPem(masterVolName, slaveHost, slaveVolName,
+                                      force=True):
+    command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+                                     "%s::%s" % (slaveHost, slaveVolName),
+                                     "create", "push-pem"]
+    try:
+        if force:
+            xmltree = _execGlusterXml(command + ["force"])
+        else:
+            xmltree = _execGlusterXml(command)
+        return True
+    except ge.GlusterCmdFailedException as e:
+        raise ge.GlusterGeoRepCreatePushPemFailedException(rc=e.rc, err=e.err)
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index c569a9e..bcc0eb5 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -484,3 +484,14 @@
         prefix = "%s: " % (action)
         self.message = prefix + "Service action is not supported"
         self.err = [self.message]
+
+
+#geo-replication
+class GlusterGeoRepException(GlusterException):
+    code = 4560
+    message = "Gluster Geo-Replication Exception"
+
+
+class GlusterGeoRepCreatePushPemFailedException(GlusterGeoRepException):
+    code = 4562
+    message = "Geo Creation of public key file failed"


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f0b7ba685918bf147eb291c2bbe90527b965416
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Timothy Asir <[email protected]>
Gerrit-Reviewer: Ayal Baron <[email protected]>
Gerrit-Reviewer: Bala.FA <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Saggi Mizrahi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to