def _get_criticality_choices(self): """Returns the current configuration of the tag_group criticality""" tags = cmk.gui.tags.TagConfig() tags.parse_config(watolib.TagConfigFile().load_for_reading()) criticality_group = tags.get_tag_group("criticality") if not criticality_group: return [] return criticality_group.get_tag_choices()
def _get_criticality_choices(self): """Returns the current configuration of the tag_group criticality""" cache_id = "criticality_choices" if cache_id in current_app.g: return current_app.g[cache_id] tags = cmk.utils.tags.TagConfig() tags.parse_config(watolib.TagConfigFile().load_for_reading()) criticality_group = tags.get_tag_group("criticality") if not criticality_group: current_app.g[cache_id] = [] return [] current_app.g[cache_id] = criticality_group.get_tag_choices() return current_app.g[cache_id]
def _optional_tag_criticality_element(self): """This element is optional. The user may have deleted the tag group criticality""" tags = cmk.gui.tags.TagConfig() tags.parse_config(watolib.TagConfigFile().load_for_reading()) criticality_group = tags.get_tag_group("criticality") if not criticality_group: return [] return [( "tag_criticality", DropdownChoice( title=_("Set criticality host tag"), help= _("Added hosts will be created as \"offline\" host by default. You " "can change this option to activate monitoring of new hosts after " "next activation of the configuration after the scan."), choices=self._get_criticality_choices, default_value="offline", ))]