Hello Nir Soffer, Bala.FA,

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

    https://gerrit.ovirt.org/45370

to review the following change.

Change subject: gluster: Publish gluster get volume info
......................................................................

gluster: Publish gluster get volume info

In 3.6 we use glusterVolumeInfo API to get gluster volume info in order to
mount gluster to backup volume servers.  glusterVolumeInfo API is defined in
vdsm/gluster/cli.py and is imported to supervdsm. In vdsm/gluster/cli.py there
are APIs that are used to manage gluster volumes; however, we don't want to
expose all these APIs in supervdsm unless gluster is used, while we do want to
expose getGlusterVolumeInfo.  To achieve this goal, we expose RHEV_ENABLED
param. With this change, gluster API defined in vdsm/gluster/cli.py exposed on
supervdsm either when building with gluster or when building on RHEV.

Change-Id: Ib9c70e9afa2fd776dfd9c2767c2e83e7f179b5c2
Bug-Url: https://bugzilla.redhat.com/1254499
Signed-off-by: Ala Hino <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/45098
Reviewed-by: Nir Soffer <[email protected]>
Reviewed-by: Bala.FA <[email protected]>
Continuous-Integration: Jenkins CI
---
M lib/vdsm/constants.py.in
M vdsm.spec.in
M vdsm/gluster/Makefile.am
M vdsm/gluster/__init__.py
M vdsm/gluster/cli.py
M vdsm/supervdsmServer
6 files changed, 30 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/45370/1

diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in
index 0c85b9f..541786b 100644
--- a/lib/vdsm/constants.py.in
+++ b/lib/vdsm/constants.py.in
@@ -23,6 +23,8 @@
 from __future__ import absolute_import
 import os
 
+RHEV_ENABLED = False if '@RHEV_TRUE@' else True
+
 # SMBIOS manufacturer
 SMBIOS_MANUFACTURER = '@SMBIOS_MANUFACTURER@'
 SMBIOS_OSNAME = '@SMBIOS_OSNAME@'
diff --git a/vdsm.spec.in b/vdsm.spec.in
index d17338d..798f74e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -983,14 +983,10 @@
 %{_datadir}/%{vdsm_name}/kaxmlrpclib.py*
 %{_datadir}/%{vdsm_name}/momIF.py*
 %{_datadir}/%{vdsm_name}/set-conf-item
-%if 0%{?with_gluster}
 %dir %{_datadir}/%{vdsm_name}/gluster
 %{_datadir}/%{vdsm_name}/gluster/__init__.py*
 %{_datadir}/%{vdsm_name}/gluster/cli.py*
 %{_datadir}/%{vdsm_name}/gluster/exception.py*
-%else
-%exclude %{_datadir}/%{vdsm_name}/gluster/*
-%endif
 %{python_sitelib}/sos/plugins/vdsm.py*
 %{_udevrulesdir}/12-vdsm-lvm.rules
 /etc/security/limits.d/99-vdsm.conf
diff --git a/vdsm/gluster/Makefile.am b/vdsm/gluster/Makefile.am
index 71c22f5..b52f516 100644
--- a/vdsm/gluster/Makefile.am
+++ b/vdsm/gluster/Makefile.am
@@ -22,12 +22,16 @@
 
 vdsmglusterdir = $(vdsmdir)/gluster
 
-dist_vdsmgluster_PYTHON = \
+common = \
        __init__.py \
+       cli.py \
+       exception.py
+       $(NULL)
+
+if !RHEV
+gluster_only = \
        api.py \
        apiwrapper.py \
-       cli.py \
-       exception.py \
        fstab.py \
        gfapi.py \
        hooks.py \
@@ -35,3 +39,6 @@
        storagedev.py \
        tasks.py \
        $(NULL)
+endif
+
+dist_vdsmgluster_PYTHON = $(common) $(gluster_only)
diff --git a/vdsm/gluster/__init__.py b/vdsm/gluster/__init__.py
index dd363d6..fa953a1 100644
--- a/vdsm/gluster/__init__.py
+++ b/vdsm/gluster/__init__.py
@@ -30,14 +30,19 @@
     return func
 
 
-def listPublicFunctions():
+def makePublicRHEV(func):
+    func.superVdsmRHEV = True
+    return func
+
+
+def listPublicFunctions(rhev=False):
     methods = []
     for modName in MODULE_LIST:
         try:
             module = __import__('gluster.' + modName, fromlist=['gluster'])
             for name in dir(module):
                 func = getattr(module, name)
-                if getattr(func, 'superVdsm', False):
+                if _shouldPublish(func, rhev):
                     funcName = 'gluster%s%s' % (name[0].upper(), name[1:])
                     methods.append((funcName, func))
         except ImportError:
@@ -45,6 +50,13 @@
     return methods
 
 
+def _shouldPublish(func, rhev):
+    if rhev:
+        return getattr(func, 'superVdsmRHEV', False)
+    else:
+        return getattr(func, 'superVdsm', False)
+
+
 def safeWrite(fileName, content):
     with tempfile.NamedTemporaryFile(dir=os.path.dirname(fileName),
                                      delete=False) as tmp:
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index b35f09f..8d399f0 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -27,7 +27,7 @@
 from vdsm import utils
 from vdsm import netinfo
 import exception as ge
-from . import makePublic
+from . import makePublic, makePublicRHEV
 
 _glusterCommandPath = utils.CommandPath("gluster",
                                         "/usr/sbin/gluster",
@@ -473,6 +473,7 @@
 
 
 @makePublic
+@makePublicRHEV
 def volumeInfo(volumeName=None, remoteServer=None):
     """
     Returns:
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index 119c2ba..978fc18 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -76,7 +76,7 @@
 from vdsm.constants import METADATA_GROUP, EXT_CHOWN, EXT_UDEVADM, \
     DISKIMAGE_USER, DISKIMAGE_GROUP, \
     P_LIBVIRT_VMCHANNELS, P_OVIRT_VMCONSOLES, \
-    VDSM_USER, QEMU_PROCESS_USER, QEMU_PROCESS_GROUP
+    VDSM_USER, QEMU_PROCESS_USER, QEMU_PROCESS_GROUP, RHEV_ENABLED
 from storage.devicemapper import _removeMapping, _getPathsStatus
 from vdsm.config import config
 import mkimage
@@ -493,7 +493,7 @@
         return wrapper
 
     if _glusterEnabled:
-        for name, func in listPublicFunctions():
+        for name, func in listPublicFunctions(RHEV_ENABLED):
             setattr(_SuperVdsm, name, logDecorator(bind(func)))
 
     try:


-- 
To view, visit https://gerrit.ovirt.org/45370
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9c70e9afa2fd776dfd9c2767c2e83e7f179b5c2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Ala Hino <[email protected]>
Gerrit-Reviewer: Bala.FA <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to