def save_notification_rules(rules): # type: (List[Dict]) -> None store.mkdir(wato_root_dir()) store.save_to_mk_file(wato_root_dir() + "notifications.mk", "notification_rules", rules, pprint_value=config.wato_pprint_config)
def save_timeperiods(timeperiods): # type: (TimeperiodSpecs) -> None store.mkdir(wato_root_dir()) store.save_to_mk_file(wato_root_dir() + "timeperiods.mk", "timeperiods", _filter_builtin_timeperiods(timeperiods), pprint_value=config.wato_pprint_config)
def save_notification_rules(rules): store.mkdir(wato_root_dir()) store.save_to_mk_file( wato_root_dir() + "notifications.mk", "notification_rules", rules, pprint_value=config.wato_pprint_config)
def save_timeperiods(timeperiods: TimeperiodSpecs) -> None: store.mkdir(wato_root_dir()) store.save_to_mk_file(wato_root_dir() + "timeperiods.mk", "timeperiods", _filter_builtin_timeperiods(timeperiods), pprint_value=config.wato_pprint_config) g.timeperiod_information = timeperiods
def _need_to_create_sample_config(): if os.path.exists(multisite_dir() + "tags.mk") \ or os.path.exists(wato_root_dir() + "rules.mk") \ or os.path.exists(wato_root_dir() + "groups.mk") \ or os.path.exists(wato_root_dir() + "notifications.mk") \ or os.path.exists(wato_root_dir() + "global.mk"): return False return True
def save_notification_rules(rules: list[EventRule]) -> None: store.mkdir(wato_root_dir()) store.save_to_mk_file( wato_root_dir() + "notifications.mk", "notification_rules", rules, pprint_value=active_config.wato_pprint_config, )
def save_timeperiods(timeperiods: TimeperiodSpecs) -> None: store.mkdir(wato_root_dir()) store.save_to_mk_file( wato_root_dir() + "timeperiods.mk", "timeperiods", _filter_builtin_timeperiods(timeperiods), pprint_value=active_config.wato_pprint_config, ) load_timeperiods.cache_clear()
def load_timeperiods() -> TimeperiodSpecs: if "timeperiod_information" in g: return g.timeperiod_information timeperiods = store.load_from_mk_file(wato_root_dir() + "timeperiods.mk", "timeperiods", {}) timeperiods.update(builtin_timeperiods()) g.timeperiod_information = timeperiods return timeperiods
def load_notification_rules(lock=False): filename = wato_root_dir() + "notifications.mk" notification_rules = store.load_from_mk_file(filename, "notification_rules", [], lock=lock) # Convert to new plugin configuration format for rule in notification_rules: if "notify_method" in rule: method = rule["notify_method"] plugin = rule["notify_plugin"] del rule["notify_method"] rule["notify_plugin"] = (plugin, method) return notification_rules
def _load_rulesets_via_redis( self, folder: CREFolder, only_varname: Optional[RulesetName] = None ) -> None: # Search relevant folders with rules.mk files # Note: The sort order of the folders does not matter here # self._load_folder_rulesets ultimately puts each folder into a dict # and groups/sorts them later on with a different mechanism all_folders = get_wato_redis_client().recursive_subfolders_for_path( f"{folder.path()}/".lstrip("/") ) root_dir = wato_root_dir()[:-1] relevant_folders = [] for folder_path in all_folders: if os.path.exists(f"{root_dir}/{folder_path}rules.mk"): relevant_folders.append(folder_path) for folder_path_with_slash in relevant_folders: stripped_folder = folder_path_with_slash.strip("/") self._load_folder_rulesets(Folder.folder(stripped_folder), only_varname)
def __init__(self): super().__init__( config_file_path=Path(wato_root_dir()) / "predefined_conditions.mk", config_variable="predefined_conditions", )
def __init__(self): super().__init__(config_file_path=Path(wato_root_dir()) / "passwords.mk", config_variable="stored_passwords")
def _save_base_config(self, cfg): base_config_file = WatoSimpleConfigFile( config_file_path=Path(wato_root_dir()) / "tags.mk", config_variable="tag_config") base_config_file.save(cfg)
def config_dir(self): return wato_root_dir()
def load_timeperiods() -> TimeperiodSpecs: timeperiods = store.load_from_mk_file(wato_root_dir() + "timeperiods.mk", "timeperiods", {}) timeperiods.update(builtin_timeperiods()) return timeperiods
def _save_base_config(self, cfg: TagConfigSpec) -> None: self._config_file_path.parent.mkdir(mode=0o770, exist_ok=True, parents=True) store.save_to_mk_file( Path(wato_root_dir()) / "tags.mk", "tag_config", cfg)