Hello Bala.FA,

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

    http://gerrit.ovirt.org/20648

to review the following change.

Change subject: gluster: performs peer detach using host UUID if provided
......................................................................

gluster: performs peer detach using host UUID if provided

This patch adds an optional argument hostUuid to the verb
glusterHostRemove. If hostUuid is provided then host
corresponding to uuid will be removed.

Signed-off-by: ndarshan <[email protected]>
Change-Id: Idfff258ccc43c276ca7b9c0472dacac2fefce64a
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/vdsmapi-gluster-schema.json
3 files changed, 42 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/20648/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 3c1199c..42bbe06 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -151,8 +151,12 @@
         params = self._eqSplit(args)
         hostName = params.get('hostName', '')
         force = (params.get('force', 'no').upper() == 'YES')
-
-        status = self.s.glusterHostRemove(hostName, force)
+        hostUuid = params.get('hostUuid')
+        if hostUuid is None:
+            status = self.s.glusterHostRemove(hostName, force)
+        else:
+            status = self.s.glusterHostRemove(hostName, force,
+                                              {'hostUuid': hostUuid})
         return status['status']['code'], status['status']['message']
 
     def do_glusterVolumeReplaceBrickStart(self, args):
@@ -532,9 +536,10 @@
               )),
          'glusterHostRemove': (
              serv.do_glusterHostRemove,
-             ('hostName=<host> [force={yes|no}]\n\t'
+             ('hostName=<host> [force={yes|no}] [hostUuid=<uuid>]\n\t'
               '<host> is hostname or ip address of a server in '
-              'gluster cluster',
+              'gluster cluster'
+              'host UUID',
               'remove server from gluster cluster'
               )),
          'glusterVolumeReplaceBrickStart': (
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 284fa97..07cd25d 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -19,9 +19,11 @@
 #
 
 from functools import wraps
+import logging
 
 from vdsm.define import doneCode
 import supervdsm as svdsm
+
 
 _SUCCESS = {'status': doneCode}
 
@@ -210,8 +212,23 @@
         self.svdsmProxy.glusterPeerProbe(hostName)
 
     @exportAsVerb
-    def hostRemove(self, hostName, force=False, options=None):
-        self.svdsmProxy.glusterPeerDetach(hostName, force)
+    def hostRemove(self, hostName, force=False, options={}):
+        host = None
+        hostUuid = options.get('hostUuid')
+
+        # get hostname of given host uuid
+        if hostUuid:
+            for hostInfo in self.svdsmProxy.glusterPeerStatus():
+                if(hostInfo['uuid'] == hostUuid):
+                    host = hostInfo['hostname']
+                    break
+            if not host:
+                logging.debug("Host with UUID:%s not found " % hostUuid)
+                host = hostName
+        else:
+            host = hostName
+
+        self.svdsmProxy.glusterPeerDetach(host, force)
 
     @exportAsVerb
     def hostsList(self, options=None):
diff --git a/vdsm/gluster/vdsmapi-gluster-schema.json 
b/vdsm/gluster/vdsmapi-gluster-schema.json
index f45a438..3fb5be4 100644
--- a/vdsm/gluster/vdsmapi-gluster-schema.json
+++ b/vdsm/gluster/vdsmapi-gluster-schema.json
@@ -920,6 +920,19 @@
  'returns': 'bool'}
 
 ##
+# @HostOptions:
+#
+# List of host options.
+#
+# @hostUuid:  The Uuid of the host
+#
+# Since: 4.10.3
+##
+{'type': 'HostOptions',
+ 'data': {'hostUuid': 'UUID'}}
+
+
+##
 # @GlusterHost.remove:
 #
 # Remove Gluster Host
@@ -930,7 +943,7 @@
 # Since: 4.10.3
 ##
 {'command': {'class': 'GlusterHost', 'name': 'remove'},
- 'data': {'hostName': 'str', 'force': 'bool'},
+ 'data': {'hostName': 'str', 'force': 'bool', 'options': 'HostOptions'}
  'returns': 'bool'}
 
 ##


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfff258ccc43c276ca7b9c0472dacac2fefce64a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Darshan N <[email protected]>
Gerrit-Reviewer: Bala.FA <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to