def _load_ucr(self): # type: () -> None """Load Univention Config Registry information.""" self.ucr = ConfigRegistry() self.ucr.load() self.role = self.ucr.get('server/role', '') TestEnvironment.logger.debug('Role=%r' % self.role) version = self.ucr.get('version/version', '0.0').split('.', 1) major, minor = int(version[0]), int(version[1]) patchlevel = int(self.ucr.get('version/patchlevel', 0)) if (major, minor) < (3, 0): securitylevel = int(self.ucr.get('version/security-patchlevel', 0)) self.ucs_version = UCSVersion((major, minor, patchlevel, securitylevel)) else: erratalevel = int(self.ucr.get('version/erratalevel', 0)) self.ucs_version = UCSVersion((major, minor, patchlevel, erratalevel)) TestEnvironment.logger.debug('Version=%r' % self.ucs_version)
def check(self, environment): # type: (TestEnvironment) -> Iterator[Verdict] """Check environment for expected version.""" versions = [] for version, state in self.versions.items(): ucs_version = UCSVersion(version) if state not in CheckVersion.STATES: yield Verdict(Verdict.WARNING, 'Unknown state "%s" for version "%s"' % (state, version)) continue versions.append((ucs_version, state)) versions.sort() for (ucs_version, state) in versions: if ucs_version <= environment.ucs_version: self.state = state if self.state == 'skip': yield Verdict(Verdict.ERROR, 'Skipped for version %s' % (environment.ucs_version,), TestCodes.REASON_VERSION_MISMATCH)