Skip to content

Commit

Permalink
Pass summary_config callback to checker
Browse files Browse the repository at this point in the history
CMK-16672

Change-Id: Id9f3415ca4b9da33188016b0e595a64cce6734eb
  • Loading branch information
Synss committed May 10, 2024
1 parent f8294f5 commit 9777120
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions cmk/base/automations/check_mk.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ def section_error_handling(
parser=parser,
fetcher=fetcher,
summarizer=CMKSummarizer(
config_cache,
hostname,
config_cache.summary_config,
override_non_ok_state=None,
),
section_plugins=SectionPluginMapper(),
Expand Down Expand Up @@ -592,8 +592,8 @@ def _execute_discovery(
parser=parser,
fetcher=fetcher,
summarizer=CMKSummarizer(
config_cache,
host_name,
config_cache.summary_config,
override_non_ok_state=None,
),
section_plugins=SectionPluginMapper(),
Expand Down Expand Up @@ -767,7 +767,9 @@ def section_error_handling(
parser=parser,
fetcher=fetcher,
summarizer=CMKSummarizer(
config_cache, host_name, override_non_ok_state=None
host_name,
config_cache.summary_config,
override_non_ok_state=None,
),
section_plugins=section_plugins,
section_error_handling=section_error_handling,
Expand Down
6 changes: 3 additions & 3 deletions cmk/base/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ def __call__(
class CMKSummarizer:
def __init__(
self,
config_cache: ConfigCache,
host_name: HostName,
summary_config: Callable[[HostName, str], SummaryConfig],
*,
override_non_ok_state: ServiceState | None = None,
) -> None:
self.config_cache: Final = config_cache
self.host_name: Final = host_name
self.summary_config: Final = summary_config
self.override_non_ok_state: Final = override_non_ok_state

def __call__(
Expand All @@ -230,7 +230,7 @@ def __call__(
_summarize_host_sections(
host_sections,
source,
self.config_cache.summary_config(source.hostname, source.ident),
self.summary_config(source.hostname, source.ident),
override_non_ok_state=self.override_non_ok_state,
)
for source, host_sections in host_sections
Expand Down
10 changes: 5 additions & 5 deletions cmk/base/modes/check_mk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,8 +1823,8 @@ def mode_check_discovery(
logger=logging.getLogger("cmk.base.discovery"),
)
summarizer = CMKSummarizer(
config_cache,
hostname,
config_cache.summary_config,
override_non_ok_state=None,
)
error_handler = CheckResultErrorHandler(
Expand Down Expand Up @@ -2321,8 +2321,8 @@ def mode_check(
logger=logging.getLogger("cmk.base.checking"),
)
summarizer = CMKSummarizer(
config_cache,
hostname,
config_cache.summary_config,
override_non_ok_state=None,
)
dry_run = options.get("no-submit", False)
Expand Down Expand Up @@ -2572,8 +2572,8 @@ def section_error_handling(
parameters = config_cache.hwsw_inventory_parameters(hostname)
raw_intervals_from_config = config_cache.inv_retention_intervals(hostname)
summarizer = CMKSummarizer(
config_cache,
hostname,
config_cache.summary_config,
override_non_ok_state=parameters.fail_status,
)

Expand Down Expand Up @@ -2797,8 +2797,8 @@ def mode_inventory_as_check(
logger=logging.getLogger("cmk.base.inventory"),
)
summarizer = CMKSummarizer(
config_cache,
hostname,
config_cache.summary_config,
override_non_ok_state=parameters.fail_status,
)
error_handler = CheckResultErrorHandler(
Expand Down Expand Up @@ -2951,8 +2951,8 @@ def mode_inventorize_marked_hosts(options: Mapping[str, object]) -> None:

def summarizer(host_name: HostName) -> CMKSummarizer:
return CMKSummarizer(
config_cache,
host_name,
config_cache.summary_config,
override_non_ok_state=config_cache.hwsw_inventory_parameters(host_name).fail_status,
)

Expand Down

0 comments on commit 9777120

Please sign in to comment.