Module: check_mk
Branch: master
Commit: 56e44e554ef50c13cdceb737b9000a3e214c41fd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=56e44e554ef50c…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Apr 5 14:13:09 2018 +0200
Removed global variable g_event_server, part 4.
Change-Id: I90770c347182983c240ec1d6f406008ef94116f3
---
cmk/ec/main.py | 14 +++++++++-----
tests/integration/cmk/ec/test_mkeventd_status.py | 6 +++---
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 55afb06..e0148c5 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -3489,8 +3489,12 @@ class StatusTableStatus(StatusTable):
prefix = "status"
columns = EventServer.status_columns()
+ def __init__(self, event_server):
+ super(StatusTableStatus, self).__init__()
+ self._event_server = event_server
+
def _enumerate(self, query):
- return g_event_server.get_status()
+ return self._event_server.get_status()
#.
@@ -3506,7 +3510,7 @@ class StatusTableStatus(StatusTable):
# '----------------------------------------------------------------------'
class StatusServer(ECServerThread):
- def __init__(self, settings, perfcounters, event_status):
+ def __init__(self, settings, perfcounters, event_status, event_server):
super(StatusServer, self).__init__(name="StatusServer",
settings=settings,
profiling_enabled=settings.options.profile_status,
@@ -3518,7 +3522,7 @@ class StatusServer(ECServerThread):
self.table_events = StatusTableEvents(event_status)
self.table_history = StatusTableHistory(settings, self)
self.table_rules = StatusTableRules(event_status)
- self.table_status = StatusTableStatus()
+ self.table_status = StatusTableStatus(event_server)
self._perfcounters = perfcounters
self._event_status = event_status
@@ -3751,7 +3755,7 @@ class StatusServer(ECServerThread):
log_event_history(self.settings, self, event, "UPDATE", user)
def handle_command_create(self, arguments):
- # Would rather use g_event_server.process_raw_line(), but we are already
+ # Would rather use process_raw_line(), but we are already
# holding lock_eventstatus and it's sub functions are setting
# lock_eventstatus too. The lock can not be allocated twice.
# TODO: Change the lock type in future?
@@ -5051,8 +5055,8 @@ def main():
global g_status_server, g_event_server
perfcounters = Perfcounters()
event_status = EventStatus(settings, perfcounters)
- g_status_server = StatusServer(settings, perfcounters, event_status)
g_event_server = EventServer(settings, perfcounters, event_status)
+ g_status_server = StatusServer(settings, perfcounters, event_status,
event_server)
event_status.load_status(g_event_server)
diff --git a/tests/integration/cmk/ec/test_mkeventd_status.py
b/tests/integration/cmk/ec/test_mkeventd_status.py
index 981e0db..07a06ac 100644
--- a/tests/integration/cmk/ec/test_mkeventd_status.py
+++ b/tests/integration/cmk/ec/test_mkeventd_status.py
@@ -68,8 +68,8 @@ def event_server(settings, config, perfcounters, event_status):
@pytest.fixture(scope="function")
-def status_server(settings, config, perfcounters, event_status):
- cmk.ec.main.g_status_server = cmk.ec.main.StatusServer(settings, perfcounters,
event_status)
+def status_server(settings, config, perfcounters, event_status, event_server):
+ cmk.ec.main.g_status_server = cmk.ec.main.StatusServer(settings, perfcounters,
event_status, event_server)
return cmk.ec.main.g_status_server
@@ -83,7 +83,7 @@ def test_handle_client(event_status, event_server, status_server):
assert "event_id" in response[0]
-def test_mkevent_check_query_perf(config, status_server, event_status, perfcounters):
+def test_mkevent_check_query_perf(config, perfcounters, event_status, status_server):
for num in range(10000):
event_status.new_event(CMKEventConsole.new_event({
"host": "heute-%d" % num,