Sandro Bonazzola has uploaded a new change for review.

Change subject: hosted-engine: configure gluster for HC
......................................................................

hosted-engine: configure gluster for HC

When both Hosted Engine and Gluster are enabled
glusterd must be configured for supporting
Hyper Converged setup.

Change-Id: I2bded0891309a2d38daef76bac93c7c7a4b0602a
Bug-Url: https://bugzilla.redhat.com/1182786
Bug-Url: https://bugzilla.redhat.com/1181466
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/ovirt_host_deploy/constants.py
M src/plugins/ovirt-host-deploy/hosted-engine/Makefile.am
M src/plugins/ovirt-host-deploy/hosted-engine/__init__.py
A src/plugins/ovirt-host-deploy/hosted-engine/glusterd.py
4 files changed, 86 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy 
refs/changes/78/39678/1

diff --git a/src/ovirt_host_deploy/constants.py 
b/src/ovirt_host_deploy/constants.py
index 470977e..a0af6f8 100644
--- a/src/ovirt_host_deploy/constants.py
+++ b/src/ovirt_host_deploy/constants.py
@@ -64,6 +64,7 @@
     KDUMP_CONFIG_FILE = '/etc/kdump.conf'
 
     HOSTED_ENGINE_CONF = '/etc/ovirt-hosted-engine/hosted-engine.conf'
+    GLUSTERD_VOL = '/etc/glusterfs/glusterd.vol'
 
 
 @util.export
diff --git a/src/plugins/ovirt-host-deploy/hosted-engine/Makefile.am 
b/src/plugins/ovirt-host-deploy/hosted-engine/Makefile.am
index 3a137a0..e840346 100644
--- a/src/plugins/ovirt-host-deploy/hosted-engine/Makefile.am
+++ b/src/plugins/ovirt-host-deploy/hosted-engine/Makefile.am
@@ -27,6 +27,7 @@
 dist_my_PYTHON = \
        __init__.py \
        configureha.py \
+       glusterd.py \
        packages.py \
        $(NULL)
 
diff --git a/src/plugins/ovirt-host-deploy/hosted-engine/__init__.py 
b/src/plugins/ovirt-host-deploy/hosted-engine/__init__.py
index 8818d62..d2685ef 100644
--- a/src/plugins/ovirt-host-deploy/hosted-engine/__init__.py
+++ b/src/plugins/ovirt-host-deploy/hosted-engine/__init__.py
@@ -25,12 +25,14 @@
 
 
 from . import configureha
+from . import glusterd
 from . import packages
 
 
 @util.export
 def createPlugins(context):
     configureha.Plugin(context=context)
+    glusterd.Plugin(context=context)
     packages.Plugin(context=context)
 
 
diff --git a/src/plugins/ovirt-host-deploy/hosted-engine/glusterd.py 
b/src/plugins/ovirt-host-deploy/hosted-engine/glusterd.py
new file mode 100644
index 0000000..4e3132a
--- /dev/null
+++ b/src/plugins/ovirt-host-deploy/hosted-engine/glusterd.py
@@ -0,0 +1,82 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""oVirt Hosted Engine HC gluster configuration plugin."""
+
+
+import gettext
+
+
+from otopi import constants as otopicons
+from otopi import filetransaction
+from otopi import plugin
+from otopi import util
+
+
+from ovirt_host_deploy import constants as odeploycons
+
+
+def _(m):
+    return gettext.dgettext(message=m, domain='ovirt-host-deploy')
+
+
+@util.export
+class Plugin(plugin.PluginBase):
+    """oVirt Hosted Engine HC gluster configuration plugin."""
+
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_MISC,
+        condition=lambda self: self.environment[
+            odeploycons.HostedEngineEnv.ENABLE
+        ],
+    )
+    def _misc(self):
+        if (
+            self.environment[odeploycons.GlusterEnv.ENABLE] and
+            not self.environment[odeploycons.VdsmEnv.OVIRT_NODE]
+        ):
+            self.logger.info(_('Configuring Gluster for HC support'))
+            content = []
+            with open(odeploycons.FileLocations.GLUSTERD_VOL, 'r') as f:
+                for line in f.read().splitlines():
+                    if line.find('rpc-auth-allow-insecure') != -1:
+                        continue
+                    elif line.find('base-port') != -1:
+                        continue
+                    elif line.find('end-volume') == 0:
+                        content.append('    option rpc-auth-allow-insecure on')
+                        content.append('    option base-port 49217')
+                    content.append(line)
+
+            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
+                filetransaction.FileTransaction(
+                    name=odeploycons.FileLocations.GLUSTERD_VOL,
+                    content=content,
+                    modifiedList=self.environment[
+                        otopicons.CoreEnv.MODIFIED_FILES
+                    ],
+                ),
+            )
+
+
+# vim: expandtab tabstop=4 shiftwidth=4


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2bded0891309a2d38daef76bac93c7c7a4b0602a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to