Darshan N has uploaded a new change for review.

Change subject: gluster: Added a plugin under gluster for nrpe configuration.
......................................................................

gluster: Added a plugin under gluster for nrpe configuration.

Added a plugin called nrpe under gluster which is used
for configuring nrpe(a agent used by nagios for monitoring
remote host). This plugin adds the ip address of the server
to list of allowed machines in nrpe config file.

Change-Id: I4faa40e2bf382187907db944f7485c1630fcc0ae
Signed-off-by: ndarshan <dnara...@redhat.com>
---
M src/plugins/ovirt-host-deploy/gluster/Makefile.am
M src/plugins/ovirt-host-deploy/gluster/__init__.py
A src/plugins/ovirt-host-deploy/gluster/nrpe.py
3 files changed, 81 insertions(+), 0 deletions(-)


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

diff --git a/src/plugins/ovirt-host-deploy/gluster/Makefile.am 
b/src/plugins/ovirt-host-deploy/gluster/Makefile.am
index 14afc89..d84e4c3 100644
--- a/src/plugins/ovirt-host-deploy/gluster/Makefile.am
+++ b/src/plugins/ovirt-host-deploy/gluster/Makefile.am
@@ -26,6 +26,7 @@
 mydir=$(ovirthostdeployplugindir)/ovirt-host-deploy/gluster
 dist_my_PYTHON = \
        __init__.py \
+        nrpe.py \
        packages.py \
        $(NULL)
 
diff --git a/src/plugins/ovirt-host-deploy/gluster/__init__.py 
b/src/plugins/ovirt-host-deploy/gluster/__init__.py
index 1977182..c3ebf24 100644
--- a/src/plugins/ovirt-host-deploy/gluster/__init__.py
+++ b/src/plugins/ovirt-host-deploy/gluster/__init__.py
@@ -25,11 +25,13 @@
 
 
 from . import packages
+from . import nrpe
 
 
 @util.export
 def createPlugins(context):
     packages.Plugin(context=context)
+    nrpe.Plugin(context=context)
 
 
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-host-deploy/gluster/nrpe.py 
b/src/plugins/ovirt-host-deploy/gluster/nrpe.py
new file mode 100644
index 0000000..bf38cde
--- /dev/null
+++ b/src/plugins/ovirt-host-deploy/gluster/nrpe.py
@@ -0,0 +1,78 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2013 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
+#
+
+
+"""gluster psackages plugin."""
+
+
+import gettext
+_ = lambda m: gettext.dgettext(message=m, domain='ovirt-host-deploy')
+
+
+from otopi import util
+from otopi import plugin
+import os.path
+from ovirt_host_deploy import constants as odeploycons
+import socket
+import fileinput
+import sys
+
+NRPE_CONFIG_FILE = "/etc/nagios/nrpe.cfg"
+
+
+@util.export
+class Plugin(plugin.PluginBase):
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+        self._enabled = False
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_INIT,
+    )
+    def _setup(self):
+        self.environment[odeploycons.GlusterEnv.ENABLE] = False
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_VALIDATION,
+        condition=lambda self: (
+            not self.environment[
+                odeploycons.VdsmEnv.OVIRT_NODE
+            ] and
+            self.environment[odeploycons.GlusterEnv.ENABLE]
+        ),
+    )
+    def _validation(self):
+        self._enabled = True
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_MISC,
+        condition=lambda self: (
+            os.path.isfile(NRPE_CONFIG_FILE)
+        ),
+    )
+    def _misc(self):
+        host = self.environment[odeploycons.VdsmEnv.ENGINE_HOST]
+        addr = socket.gethostbyname(host)
+        for line in fileinput.input(NRPE_CONFIG_FILE, inplace=True):
+            if line.startswith("allowed_hosts"):
+                if line.find(str(addr)) == -1:
+                    line = line[:-1] + "," + str(addr)
+            sys.stdout.write(line)
+
+# vim: expandtab tabstop=4 shiftwidth=4


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

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

Reply via email to