Module: check_mk
Branch: master
Commit: 87098017332c1b857e3541248592c1cb6b06e05f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=87098017332c1b…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jun 7 09:51:12 2018 +0200
Fix dependencies of core-related modules, part 2.
Add a parameterless hook for config generation to core_nagios and use it.
Change-Id: I623a1fc835fb48bf0d397be71e7145ace7bbac16
---
cmk_base/core_config.py | 5 ++---
cmk_base/core_nagios.py | 10 ++++------
cmk_base/modes/check_mk.py | 4 ++--
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/cmk_base/core_config.py b/cmk_base/core_config.py
index 087a35a..65b8432 100644
--- a/cmk_base/core_config.py
+++ b/cmk_base/core_config.py
@@ -254,9 +254,8 @@ def _create_config():
import cmk_base.cee.core_cmc as core_cmc
core_cmc.create_config(_cmc_relfilename)
else:
- import cmk_base.core_nagios as core_nagios
- with file(cmk.paths.nagios_objects_file, "w") as out:
- core_nagios.create_config(out)
+ from cmk_base.core_nagios import create_config_hook
+ create_config_hook()
# Verify that the user has no deprecated check groups configured.
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index 74f1321..8f58446 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -57,14 +57,12 @@ import cmk_base.check_utils
# | Create a configuration file for Nagios core with hosts + services |
# '----------------------------------------------------------------------'
-# TODO: Move to modes?
-def do_output_nagios_conf(args):
- if len(args) == 0:
- args = None
- create_config(sys.stdout, args)
+def create_config_hook():
+ with file(cmk.paths.nagios_objects_file, "w") as out:
+ create_config(out, None)
-def create_config(outfile = sys.stdout, hostnames = None):
+def create_config(outfile, hostnames):
global hostgroups_to_define
hostgroups_to_define = set([])
global servicegroups_to_define
diff --git a/cmk_base/modes/check_mk.py b/cmk_base/modes/check_mk.py
index 98503de..455a70b 100644
--- a/cmk_base/modes/check_mk.py
+++ b/cmk_base/modes/check_mk.py
@@ -989,8 +989,8 @@ modes.register(Mode(
# '----------------------------------------------------------------------'
def mode_dump_nagios_config(args):
- import cmk_base.core_nagios as core_nagios
- core_nagios.do_output_nagios_conf(args)
+ fromt cmk_base.core_nagios import create_config
+ core_nagios.create_config(sys.stdout, args if len(args) else None)
modes.register(Mode(
long_option="nagios-config",