3604df
From d798790c3a21611ec7ead55a7820b98019b2d0c7 Mon Sep 17 00:00:00 2001
3604df
From: Aravinda VK <avishwan@redhat.com>
3604df
Date: Wed, 21 Sep 2016 17:43:00 +0530
3604df
Subject: [PATCH 94/94] eventsapi/geo-rep: Geo-rep will not work without eventsapi rpms
3604df
3604df
If glusterfs-events rpm is not installed, Geo-replication will
3604df
fail since it imports eventtypes.
3604df
3604df
Any call to gsyncd will fail with Import error. Glusterd start
3604df
fails since it runs `gsyncd.py --version`
3604df
3604df
Traceback (most recent call last):
3604df
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncd.py",
3604df
    line 29, in <module>
3604df
      from syncdutils import FreeObject, norm, grabpidfile, finalize
3604df
  File "/usr/libexec/glusterfs/python/syncdaemon/syncdutils.py",
3604df
    line 28, in <module>
3604df
      from events import eventtypes
3604df
ImportError: No module named events
3604df
3604df
> Reviewed-on: http://review.gluster.org/15539
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com>
3604df
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
3604df
3604df
BUG: 1378030
3604df
Change-Id: I1a9bc086c3d52449ec7296cb2f9ceb16cd41a8a4
3604df
Signed-off-by: Aravinda VK <avishwan@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/85934
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 geo-replication/syncdaemon/monitor.py    |    4 ++--
3604df
 geo-replication/syncdaemon/syncdutils.py |   13 ++++++++++---
3604df
 2 files changed, 12 insertions(+), 5 deletions(-)
3604df
3604df
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
3604df
index a624fe4..22cd1cc 100644
3604df
--- a/geo-replication/syncdaemon/monitor.py
3604df
+++ b/geo-replication/syncdaemon/monitor.py
3604df
@@ -25,7 +25,7 @@ from gconf import gconf
3604df
 from syncdutils import select, waitpid, errno_wrap
3604df
 from syncdutils import set_term_handler, is_host_local, GsyncdError
3604df
 from syncdutils import escape, Thread, finalize, memoize
3604df
-from syncdutils import gf_event, eventtypes
3604df
+from syncdutils import gf_event, EVENT_GEOREP_FAULTY
3604df
 
3604df
 from gsyncdstatus import GeorepStatus, set_monitor_status
3604df
 
3604df
@@ -375,7 +375,7 @@ class Monitor(object):
3604df
                 ret = exit_status(ret)
3604df
                 if ret in (0, 1):
3604df
                     self.status[w[0]['dir']].set_worker_status(self.ST_FAULTY)
3604df
-                    gf_event(eventtypes.GEOREP_FAULTY,
3604df
+                    gf_event(EVENT_GEOREP_FAULTY,
3604df
                              master_volume=master.volume,
3604df
                              master_node=w[0]['host'],
3604df
                              slave_host=slave_host,
3604df
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
3604df
index f5d3c51..0bcf5ec 100644
3604df
--- a/geo-replication/syncdaemon/syncdutils.py
3604df
+++ b/geo-replication/syncdaemon/syncdutils.py
3604df
@@ -25,7 +25,13 @@ from os import waitpid as owaitpid
3604df
 
3604df
 from conf import GLUSTERFS_LIBEXECDIR
3604df
 sys.path.insert(1, GLUSTERFS_LIBEXECDIR)
3604df
-from events import eventtypes
3604df
+EVENTS_ENABLED = True
3604df
+try:
3604df
+    from events.eventtypes import GEOREP_FAULTY as EVENT_GEOREP_FAULTY
3604df
+except ImportError:
3604df
+    # Events APIs not installed, dummy eventtypes with None
3604df
+    EVENTS_ENABLED = False
3604df
+    EVENT_GEOREP_FAULTY = None
3604df
 
3604df
 try:
3604df
     from cPickle import PickleError
3604df
@@ -530,5 +536,6 @@ def get_changelog_log_level(lvl):
3604df
 
3604df
 
3604df
 def gf_event(event_type, **kwargs):
3604df
-    from events.gf_event import gf_event as gfevent
3604df
-    gfevent(event_type, **kwargs)
3604df
+    if EVENTS_ENABLED:
3604df
+        from events.gf_event import gf_event as gfevent
3604df
+        gfevent(event_type, **kwargs)
3604df
-- 
3604df
1.7.1
3604df