def from_str(command: str) -> "Command": serial, host_name, mode_name, timeout = command.split(sep=";", maxsplit=3) return Command( config_path=VersionedConfigPath(int(serial)), host_name=HostName(host_name), mode=Mode.CHECKING if mode_name == "checking" else Mode.DISCOVERY, timeout=int(timeout), )
def _create_core_config( core: MonitoringCore, hosts_to_update: HostsToUpdate = None ) -> ConfigurationWarnings: initialize_warnings() _verify_non_duplicate_hosts() _verify_non_deprecated_checkgroups() config_path = next(VersionedConfigPath.current()) config_cache = config.get_config_cache() with config_path.create(is_cmc=config.is_cmc()), _backup_objects_file(core): core.create_config(config_path, config_cache, hosts_to_update=hosts_to_update) cmk.utils.password_store.save_for_helpers(config_path) return get_configuration_warnings()
def test_next(self, config_path): assert config_path == VersionedConfigPath.current( ) == VersionedConfigPath(1) config_path = next(config_path) assert config_path == VersionedConfigPath.current( ) == VersionedConfigPath(2) config_path = next(config_path) assert config_path == VersionedConfigPath.current( ) == VersionedConfigPath(3)
def fixture_config_path() -> VersionedConfigPath: return VersionedConfigPath(42)
def config_path(self): ConfigPath.ROOT.mkdir(parents=True, exist_ok=True) # Call next because this is where `latest` etc. are created and updated. yield next(VersionedConfigPath(0)) # pylint:disable=stop-iteration-return shutil.rmtree(ConfigPath.ROOT)
def test_hash(self, config_path): assert isinstance(hash(config_path), int) assert hash(config_path) == hash(LATEST_CONFIG) assert hash(config_path) != hash(VersionedConfigPath(0))
def test_eq(self, config_path): assert config_path == type(config_path)() assert config_path == Path(config_path) assert config_path != VersionedConfigPath(0)