Skip to content

Commit

Permalink
Fix camel case: Taggroup -> TagGroup
Browse files Browse the repository at this point in the history
Change-Id: I3e9708361d07865e1a402ff9f84dcec9ebe98fad
  • Loading branch information
Synss committed Apr 11, 2023
1 parent a025068 commit eeaeea8
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 83 deletions.
18 changes: 9 additions & 9 deletions cmk/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from cmk.utils.site import omd_site
from cmk.utils.store.host_storage import apply_hosts_file_to_object, get_host_storage_loaders
from cmk.utils.structured_data import RawIntervalsFromConfig
from cmk.utils.tags import ComputedDataSources, TaggroupID, TagID
from cmk.utils.tags import ComputedDataSources, TagGroupID, TagID
from cmk.utils.type_defs import (
ActiveCheckPluginName,
AgentTargetVersion,
Expand Down Expand Up @@ -2170,7 +2170,7 @@ def _discovered_labels_of_service(
}

@staticmethod
def get_tag_to_group_map() -> Mapping[TagID, TaggroupID]:
def get_tag_to_group_map() -> Mapping[TagID, TagGroupID]:
tags = cmk.utils.tags.get_effective_tag_config(tag_config)
return ruleset_matcher.get_tag_to_group_map(tags)

Expand Down Expand Up @@ -2853,7 +2853,7 @@ def _make_snmp_sections(
for name in (checking_sections | disabled_sections)
}

def _collect_hosttags(self, tag_to_group_map: Mapping[TagID, TaggroupID]) -> None:
def _collect_hosttags(self, tag_to_group_map: Mapping[TagID, TagGroupID]) -> None:
"""Calculate the effective tags for all configured hosts
WATO ensures that all hosts configured with WATO have host_tags set, but there may also be hosts defined
Expand Down Expand Up @@ -2888,7 +2888,7 @@ def _collect_hosttags(self, tag_to_group_map: Mapping[TagID, TaggroupID]) -> Non

@staticmethod
def _tag_groups_to_tag_list(
host_path: str, tag_groups: Mapping[TaggroupID, TagID]
host_path: str, tag_groups: Mapping[TagGroupID, TagID]
) -> set[TagID]:
# The pre 1.6 tags contained only the tag group values (-> chosen tag id),
# but there was a single tag group added with it's leading tag group id. This
Expand All @@ -2900,8 +2900,8 @@ def _tag_groups_to_tag_list(

@staticmethod
def _tag_list_to_tag_groups(
tag_to_group_map: Mapping[TagID, TaggroupID], tag_list: Iterable[TagID]
) -> Mapping[TaggroupID, TagID]:
tag_to_group_map: Mapping[TagID, TagGroupID], tag_list: Iterable[TagID]
) -> Mapping[TagGroupID, TagID]:
# This assumes all needed aux tags of grouped are already in the tag_list

# Ensure the internal mandatory tag groups are set for all hosts
Expand Down Expand Up @@ -2932,7 +2932,7 @@ def tag_list(self, hostname: HostName) -> set[TagID]:

# TODO: check all call sites and remove this or make it private?
@staticmethod
def tags(hostname: HostName) -> Mapping[TaggroupID, TagID]:
def tags(hostname: HostName) -> Mapping[TagGroupID, TagID]:
"""Returns the dict of all configured tag groups and values of a host."""
if hostname in host_tags:
return host_tags[hostname]
Expand Down Expand Up @@ -3294,7 +3294,7 @@ def _flatten_piggybacked_host_files_rule(

def tags_of_service(
self, hostname: HostName, svc_desc: ServiceName
) -> Mapping[TaggroupID, TagID]:
) -> Mapping[TagGroupID, TagID]:
"""Returns the dict of all configured tags of a service
It takes all explicitly configured tag groups into account.
"""
Expand Down Expand Up @@ -3516,7 +3516,7 @@ def section_name_of(self, section: CheckPluginNameStr) -> str:

@staticmethod
def _get_tag_attributes(
collection: Mapping[TaggroupID, TagID] | Labels | LabelSources,
collection: Mapping[TagGroupID, TagID] | Labels | LabelSources,
prefix: str,
) -> ObjectAttributes:
return {f"__{prefix}_{k}": str(v) for k, v in collection.items()}
Expand Down
2 changes: 1 addition & 1 deletion cmk/bi/data_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _site_data_filename(self, site_id: str, timestamp: int) -> str:
def add_site_data(self, site_id: SiteId, hosts: Mapping[HostName, tuple]) -> None:
# BIHostData
# ("site_id", str),
# ("tags", set[tuple[TaggroupID, TagID]]),
# ("tags", set[tuple[TagGroupID, TagID]]),
# ("labels", set),
# ("folder", str),
# ("services", dict[str, BIServiceData]),
Expand Down
6 changes: 3 additions & 3 deletions cmk/bi/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from cmk.utils import plugin_registry
from cmk.utils.macros import MacroMapping, replace_macros_in_str
from cmk.utils.rulesets.ruleset_matcher import TagCondition
from cmk.utils.tags import TaggroupID, TagID
from cmk.utils.tags import TagGroupID, TagID
from cmk.utils.type_defs import HostName, HostState, ServiceDetails, ServiceName, ServiceState

from cmk.bi.type_defs import ActionConfig, ComputationConfigDict, GroupConfigDict, SearchConfig
Expand Down Expand Up @@ -95,7 +95,7 @@ class BIServiceData(NamedTuple):

class BIHostData(NamedTuple):
site_id: str
tags: set[tuple[TaggroupID, TagID]]
tags: set[tuple[TagGroupID, TagID]]
labels: MapGroup2Value
folder: str
services: dict[str, BIServiceData]
Expand Down Expand Up @@ -404,7 +404,7 @@ def filter_host_choice(
def filter_host_tags(
self,
hosts: Iterable[BIHostData],
tag_conditions: Mapping[TaggroupID, TagCondition],
tag_conditions: Mapping[TagGroupID, TagCondition],
) -> Iterable[BIHostData]:
...

Expand Down
4 changes: 2 additions & 2 deletions cmk/bi/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from cmk.utils.regex import regex
from cmk.utils.rulesets.ruleset_matcher import matches_labels, matches_tag_condition, TagCondition
from cmk.utils.tags import TaggroupID
from cmk.utils.tags import TagGroupID
from cmk.utils.type_defs import HostName

from cmk.bi.lib import ABCBISearcher, BIHostData, BIHostSearchMatch, BIServiceSearchMatch
Expand Down Expand Up @@ -177,7 +177,7 @@ def filter_host_folder(
def filter_host_tags(
self,
hosts: Iterable[BIHostData],
tag_conditions: Mapping[TaggroupID, TagCondition],
tag_conditions: Mapping[TagGroupID, TagCondition],
) -> Iterable[BIHostData]:
return (
host
Expand Down
8 changes: 4 additions & 4 deletions cmk/gui/plugins/openapi/endpoints/host_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Any

from cmk.utils.regex import REGEX_ID
from cmk.utils.tags import BuiltinTagConfig, TagGroup, TaggroupSpec
from cmk.utils.tags import BuiltinTagConfig, TagGroup, TagGroupSpec

from cmk.gui.http import Response
from cmk.gui.logged_in import user
Expand Down Expand Up @@ -172,7 +172,7 @@ def update_host_tag_group(params: Mapping[str, Any]) -> Response:
updated_details = {x: body[x] for x in body if x != "repair"}
tag_group = _retrieve_group(ident)
group_details = tag_group.get_dict_format()
# This is an incremental update of the TaggroupSpec
# This is an incremental update of the TagGroupSpec
group_details.update(updated_details) # type: ignore[typeddict-item]
try:
edit_tag_group(ident, TagGroup.from_config(group_details), allow_repair=body["repair"])
Expand Down Expand Up @@ -256,13 +256,13 @@ def _retrieve_group(ident: str) -> TagGroup:
return tag_group


def _serve_host_tag_group(tag_details: TaggroupSpec) -> Response:
def _serve_host_tag_group(tag_details: TagGroupSpec) -> Response:
response = serve_json(serialize_host_tag_group(tag_details))
response.headers.add("ETag", constructors.etag_of_dict(dict(tag_details)).to_header())
return response


def serialize_host_tag_group(details: TaggroupSpec) -> dict[str, Any]:
def serialize_host_tag_group(details: TagGroupSpec) -> dict[str, Any]:
return constructors.domain_object(
domain_type="host_tag_group",
identifier=details["id"],
Expand Down
8 changes: 4 additions & 4 deletions cmk/gui/view_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from cmk.utils.html import replace_state_markers
from cmk.utils.labels import Labels
from cmk.utils.rulesets.ruleset_matcher import LabelSources
from cmk.utils.tags import TaggroupID, TagID
from cmk.utils.tags import TagGroupID, TagID

import cmk.gui.utils.escaping as escaping
from cmk.gui.htmllib.generator import HTMLWriter
Expand Down Expand Up @@ -195,15 +195,15 @@ def render_labels(


def render_tag_groups(
tag_groups: Mapping[TaggroupID, TagID], object_type: str, with_links: bool
tag_groups: Mapping[TagGroupID, TagID], object_type: str, with_links: bool
) -> HTML:
return _render_tag_groups_or_labels(
tag_groups, object_type, with_links, label_type="tag_group", label_sources={}
)


def _render_tag_groups_or_labels(
entries: Mapping[TaggroupID, TagID] | Labels,
entries: Mapping[TagGroupID, TagID] | Labels,
object_type: str,
with_links: bool,
label_type: str,
Expand All @@ -226,7 +226,7 @@ def _render_tag_groups_or_labels(


def _render_tag_group(
tag_group_id_or_label_key: TaggroupID | str,
tag_group_id_or_label_key: TagGroupID | str,
tag_id_or_label_value: TagID | str,
object_type: str,
with_link: bool,
Expand Down
4 changes: 2 additions & 2 deletions cmk/gui/views/painter/v0/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import cmk.utils.render
from cmk.utils.macros import replace_macros_in_str
from cmk.utils.rulesets.ruleset_matcher import LabelSources
from cmk.utils.tags import TaggroupID, TagID
from cmk.utils.tags import TagGroupID, TagID
from cmk.utils.type_defs import HostName

from cmk.gui.config import active_config
Expand Down Expand Up @@ -89,7 +89,7 @@ def format_plugin_output(output: str, row: Row) -> HTML:
)


def get_tag_groups(row: Row, what: str) -> Mapping[TaggroupID, TagID]:
def get_tag_groups(row: Row, what: str) -> Mapping[TagGroupID, TagID]:
# Sites with old versions that don't have the tag groups column return
# None for this field. Convert this to the default value
groups = row.get("%s_tags" % what, {}) or {}
Expand Down
6 changes: 3 additions & 3 deletions cmk/gui/wato/pages/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
TagConditionNOR,
TagConditionOR,
)
from cmk.utils.tags import GroupedTag, TaggroupID, TagID
from cmk.utils.tags import GroupedTag, TagGroupID, TagID
from cmk.utils.type_defs import (
HostName,
HostOrServiceConditions,
Expand Down Expand Up @@ -2439,7 +2439,7 @@ def render(
yield from self._service_label_conditions(conditions)

def _tag_conditions(
self, host_tag_conditions: Mapping[TaggroupID, TagCondition]
self, host_tag_conditions: Mapping[TagGroupID, TagCondition]
) -> Iterable[HTML]:
for taggroup_id, tag_spec in host_tag_conditions.items():
if isinstance(tag_spec, dict) and "$or" in tag_spec:
Expand Down Expand Up @@ -2479,7 +2479,7 @@ def _tag_conditions(

def _single_tag_condition(
self,
taggroup_id: TaggroupID,
taggroup_id: TagGroupID,
tag_spec: TagID | None | TagConditionNE,
) -> HTML:
negate = False
Expand Down
8 changes: 4 additions & 4 deletions cmk/gui/watolib/host_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import cmk.utils.plugin_registry
from cmk.utils.exceptions import MKGeneralException
from cmk.utils.tags import TagGroup, TaggroupID, TagID
from cmk.utils.tags import TagGroup, TagGroupID, TagID
from cmk.utils.type_defs import HostName

from cmk.gui.config import active_config
Expand Down Expand Up @@ -372,7 +372,7 @@ def filter_matches(self, crit: Any, value: Any, hostname: HostName) -> bool:
that are represented by the current HTML variables."""
return crit == value

def get_tag_groups(self, value: Any) -> Mapping[TaggroupID, TagID]:
def get_tag_groups(self, value: Any) -> Mapping[TagGroupID, TagID]:
"""Each attribute may set multiple tag groups for a host
This is used for calculating the effective host tags when writing the hosts{.mk|.cfg}"""
return {}
Expand Down Expand Up @@ -909,7 +909,7 @@ def name(self) -> str:
def is_tag_attribute(self) -> bool:
return True

def get_tag_groups(self, value: TagID | None) -> Mapping[TaggroupID, TagID]:
def get_tag_groups(self, value: TagID | None) -> Mapping[TagGroupID, TagID]:
"""Return set of tag groups to set (handles secondary tags)"""
return self._tag_group.get_tag_group_config(value)

Expand Down Expand Up @@ -976,7 +976,7 @@ def render_input(self, varprefix: str, value: TagID | None) -> None:
def _tag_value(self) -> TagID | None:
return self._tag_group.get_tag_choices()[0][0]

def get_tag_groups(self, value: TagID | None) -> Mapping[TaggroupID, TagID]:
def get_tag_groups(self, value: TagID | None) -> Mapping[TagGroupID, TagID]:
if not value:
return {}
return super().get_tag_groups(self._tag_value())
Expand Down
6 changes: 3 additions & 3 deletions cmk/gui/watolib/hosts_and_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
StandardHostsStorage,
StorageFormat,
)
from cmk.utils.tags import TaggroupID, TagID
from cmk.utils.tags import TagGroupID, TagID
from cmk.utils.type_defs import ContactgroupName, HostName

from cmk.automations.results import ABCAutomationResult
Expand Down Expand Up @@ -3109,14 +3109,14 @@ def site_id(self):
def parents(self):
return self.effective_attribute("parents", [])

def tag_groups(self) -> Mapping[TaggroupID, TagID]:
def tag_groups(self) -> Mapping[TagGroupID, TagID]:
"""Compute tags from host attributes
Each tag attribute may set multiple tags. can set tags (e.g. the SiteAttribute)"""

if self._cached_host_tags is not None:
return self._cached_host_tags # Cached :-)

tag_groups: dict[TaggroupID, TagID] = {}
tag_groups: dict[TagGroupID, TagID] = {}
effective = self.effective_attributes()
for attr in host_attribute_registry.attributes():
value = effective.get(attr.name())
Expand Down
8 changes: 4 additions & 4 deletions cmk/gui/watolib/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
TagCondition,
TagConditionNE,
)
from cmk.utils.tags import TaggroupID, TagID
from cmk.utils.tags import TagGroupID, TagID
from cmk.utils.type_defs import HostOrServiceConditionRegex, HostOrServiceConditions

# Tolerate this for 1.6. Should be cleaned up in future versions,
Expand Down Expand Up @@ -114,14 +114,14 @@ class RuleConditions:
def __init__(
self,
host_folder: str,
host_tags: Mapping[TaggroupID, TagCondition] | None = None,
host_tags: Mapping[TagGroupID, TagCondition] | None = None,
host_labels: Labels | None = None,
host_name: HostOrServiceConditions | None = None,
service_description: HostOrServiceConditions | None = None,
service_labels: Labels | None = None,
) -> None:
self.host_folder: Final = host_folder
self.host_tags: Final[Mapping[TaggroupID, TagCondition]] = host_tags or {}
self.host_tags: Final[Mapping[TagGroupID, TagCondition]] = host_tags or {}
self.host_labels: Final = host_labels or {}
self.host_name: Final = host_name
self.service_description: Final = service_description
Expand Down Expand Up @@ -549,7 +549,7 @@ class Ruleset:
def __init__(
self,
name: RulesetName,
tag_to_group_map: Mapping[TagID, TaggroupID],
tag_to_group_map: Mapping[TagID, TagGroupID],
rulespec: Rulespec | None = None,
) -> None:
super().__init__()
Expand Down
Loading

0 comments on commit eeaeea8

Please sign in to comment.