Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: add Gluster Support
......................................................................

packaging: setup: add Gluster Support

Add Gluster Support to Hosted Engine.
See feature page:
http://www.ovirt.org/Features/Self_Hosted_Engine_Gluster_Support
for documentation.

Requires: http://gerrit.ovirt.org/36783
Change-Id: I87f37cda3c9f957b548f7634ba143cf3f8a59ebe
Bug-Url: https://bugzilla.redhat.com/1173669
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M ovirt-hosted-engine-setup.spec.in
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
4 files changed, 93 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/62/37662/1

diff --git a/ovirt-hosted-engine-setup.spec.in 
b/ovirt-hosted-engine-setup.spec.in
index a820238..b29fb0c 100644
--- a/ovirt-hosted-engine-setup.spec.in
+++ b/ovirt-hosted-engine-setup.spec.in
@@ -41,6 +41,7 @@
 Requires:       otopi >= 1.3.1
 Requires:       vdsm >= 4.16.10
 Requires:       vdsm-cli >= 4.16.10
+Requires:       vdsm-gluster >= 4.16.10
 Requires:       vdsm-python >= 4.16.10
 Requires:       ovirt-host-deploy >= 1.3.1
 Requires:       openssh-server
diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 1af24b6..d443821 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -65,6 +65,7 @@
 @util.codegen
 class FileSystemTypes(object):
     NFS = 'nfs'
+    GLUSTERFS = 'glusterfs'
 
 
 @util.export
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
index 3e03b05..01b1d3f 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
@@ -1,6 +1,6 @@
 #
 # ovirt-hosted-engine-setup -- ovirt hosted engine setup
-# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014-2015 Red Hat, Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -19,7 +19,7 @@
 
 
 """
-Local storage domain plugin.
+NFS / GlusterFS storage plugin.
 """
 
 import os
@@ -30,6 +30,7 @@
 
 from otopi import util
 from otopi import plugin
+from vdsm import vdscli
 
 
 from ovirt_hosted_engine_setup import constants as ohostedcons
@@ -61,6 +62,8 @@
         elif domain_type == ohostedcons.DomainTypes.NFS4:
             fstype = ohostedcons.FileSystemTypes.NFS
             opts.append('vers=4')
+        elif domain_type == ohostedcons.DomainTypes.GLUSTERFS:
+            fstype = ohostedcons.FileSystemTypes.GLUSTERFS
 
         if fstype == ohostedcons.FileSystemTypes.NFS:
             opts.append('retry=1')
@@ -82,7 +85,11 @@
 
         rc, _stdout, stderr = self.execute(
             mount_cmd,
-            raiseOnError=False
+            raiseOnError=False,
+            env={
+                'LC_ALL': 'C',
+            },
+
         )
         error = '\n'.join(stderr)
         if rc != 0:
@@ -104,7 +111,10 @@
                     self.command.get('umount'),
                     path
                 ),
-                raiseOnError=False
+                raiseOnError=False,
+                env={
+                    'LC_ALL': 'C',
+                },
             )
             if rc == 0:
                 tries = -1
@@ -118,7 +128,10 @@
                         '+D%s' % path,
                         '-xfl'
                     ),
-                    raiseOnError=False
+                    raiseOnError=False,
+                    env={
+                        'LC_ALL': 'C',
+                    },
                 )
         return rc
 
@@ -147,7 +160,44 @@
                 )
             )
 
+    def _check_replica_level(self, connection):
+        cli = vdscli.connect()
+        server, volume = connection.split(':')
+        if volume[0] == '/':
+            volume = volume[1:]
+        self.logger.debug('glusterVolumesList')
+        response = cli.glusterVolumesList(volume, server)
+        self.logger.debug(response)
+        if response['status']['code'] != 0:
+            # TODO: check if a more informative message can be given
+            raise RuntimeError(response['status']['message'])
+        volumes = response['volumes']
+        if volume not in volumes:
+            raise RuntimeError(_('GlusterFS Volume does not exist!'))
+        if str(volumes[volume]['replicaCount']) != '3':
+            raise RuntimeError(
+                _(
+                    'GlusterFS Volume is not using replica 3'
+                )
+            )
+        self.logger.info(_('GlusterFS replica 3 Volume detected'))
+
     def _validateDomain(self, connection, domain_type, check_space):
+        if self.environment[
+            ohostedcons.StorageEnv.DOMAIN_TYPE
+        ] == ohostedcons.DomainTypes.GLUSTERFS:
+            # FIXME: mount.glusterfs exit with code 0 also on failure
+            # without any stderr content.
+            # https://bugzilla.redhat.com/show_bug.cgi?id=1128165
+            # https://bugzilla.redhat.com/show_bug.cgi?id=1173513
+            # https://bugzilla.redhat.com/show_bug.cgi?id=1173515
+            self.logger.warning(
+                _(
+                    'Due to several bugs in mount.glusterfs the validation '
+                    'of GlusterFS share cannot be reliable.'
+                )
+            )
+            self._check_replica_level(connection)
         path = tempfile.mkdtemp()
         try:
             self._mount(path, connection, domain_type)
@@ -187,17 +237,24 @@
         before=(
             ohostedcons.Stages.CONFIG_STORAGE_LATE,
         ),
-        condition=(
-            lambda self: self.environment[
-                ohostedcons.StorageEnv.DOMAIN_TYPE
-            ] in (
-                # ohostedcons.DomainTypes.GLUSTERFS,
+        condition=lambda self: (
+            self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
+                ohostedcons.DomainTypes.GLUSTERFS,
                 ohostedcons.DomainTypes.NFS3,
                 ohostedcons.DomainTypes.NFS4,
             )
         ),
     )
     def _customization(self):
+        if self.environment[
+            ohostedcons.StorageEnv.DOMAIN_TYPE
+        ] == ohostedcons.DomainTypes.GLUSTERFS:
+            self.logger.warning(
+                _(
+                    'Please note that Replica 3 support is required for '
+                    'the shared storage.'
+                )
+            )
         interactive = self.environment[
             ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
         ] is None
@@ -278,16 +335,14 @@
         before=(
             ohostedcons.Stages.DIALOG_TITLES_E_STORAGE,
         ),
-        condition=(
-            lambda self: (
-                not self.environment[
-                    ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
-                ] and
-                self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
-                    # ohostedcons.DomainTypes.GLUSTERFS,
-                    ohostedcons.DomainTypes.NFS3,
-                    ohostedcons.DomainTypes.NFS4,
-                )
+        condition=lambda self: (
+            not self.environment[
+                ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+            ] and
+            self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
+                ohostedcons.DomainTypes.GLUSTERFS,
+                ohostedcons.DomainTypes.NFS3,
+                ohostedcons.DomainTypes.NFS4,
             )
         ),
     )
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index df6bb8e..d27ab8a 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -421,18 +421,21 @@
             ohostedcons.VDSMConstants.NFS_DOMAIN,
             ohostedcons.VDSMConstants.GLUSTERFS_DOMAIN,
         ):
-            conList = [
-                {
-                    'connection': self.environment[
-                        ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
-                    ],
-                    'user': 'kvm',
-                    'id': self.environment[
-                        ohostedcons.StorageEnv.CONNECTION_UUID
-                    ],
-                    'protocol_version': self.protocol_version,
-                }
-            ]
+            conDict = {
+                'connection': self.environment[
+                    ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
+                ],
+                'user': 'kvm',
+                'id': self.environment[
+                    ohostedcons.StorageEnv.CONNECTION_UUID
+                ],
+            }
+            if self.storageType == ohostedcons.VDSMConstants.NFS_DOMAIN:
+                conDict['protocol_version'] = self.protocol_version
+            if self.storageType == ohostedcons.VDSMConstants.GLUSTERFS_DOMAIN:
+                conDict['tpgt'] = '1'
+                conDict['vfs_type'] = 'glusterfs'
+            conList = [conDict]
         elif self.storageType in (
             ohostedcons.VDSMConstants.ISCSI_DOMAIN,
         ):
@@ -856,8 +859,7 @@
                 prompt=True,
                 caseSensitive=True,
                 validValues=(
-                    # Enable when glusterfs issues are solved:
-                    # ohostedcons.DomainTypes.GLUSTERFS,
+                    ohostedcons.DomainTypes.GLUSTERFS,
                     ohostedcons.DomainTypes.ISCSI,
                     ohostedcons.DomainTypes.NFS3,
                     ohostedcons.DomainTypes.NFS4,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87f37cda3c9f957b548f7634ba143cf3f8a59ebe
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.2
Gerrit-Owner: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to