Пример #1
0
    def _resolve_labels(self, container):
        # Resolve database type
        if self.type == "auto":
            image_regex = re.compile("^(.+?)(?::.+)?$")
            for tag in container.image.tags:
                matches = image_regex.match(tag)
                matched_type = KNOWN_IMAGES.get(matches.group(1), None)
                if matched_type is not None:
                    self.type = matched_type
                    break
            if self.type == "auto":
                self.type = "unknown"

        # Resolve default values based on other attributes
        self._load_labels(TYPE_DEFAULTS.get(self.type, {}), True)
        self._load_labels(RETENTION_DEFAULTS.get(self.retention_policy, {}),
                          True)

        # Other type conversions/calculations
        self.type = DatabaseType[self.type]
        self.port = int(self.port)
        self.compress = distutils.util.strtobool(self.compress)
        self.compression_level = int(self.compression_level)
        self.encrypt = distutils.util.strtobool(self.encrypt)
        self.dump_timestamp = distutils.util.strtobool(self.dump_timestamp)
        self.retention_min_count = max(int(self.retention_min_count), 1)
        self.retention_min_age = tempora.parse_timedelta(
            self.retention_min_age)
        self.retention_max_count = max(int(self.retention_max_count), 0)
        self.retention_max_age = tempora.parse_timedelta(
            self.retention_max_age)
        self.grace_time = tempora.parse_timedelta(self.grace_time)
Пример #2
0
 def _set_keepalive(self, connection):
     if 'TCP keepalive' not in pmxbot.config:
         return
     period = pmxbot.config['TCP keepalive']
     if isinstance(period, numbers.Number):
         period = datetime.timedelta(seconds=period)
     if isinstance(period, str):
         period = tempora.parse_timedelta(period)
     log.info("Setting keepalive for %s", period)
     connection.set_keepalive(period)
Пример #3
0
	def _set_keepalive(self, connection):
		if 'TCP keepalive' not in pmxbot.config:
			return
		period = pmxbot.config['TCP keepalive']
		if isinstance(period, numbers.Number):
			period = datetime.timedelta(seconds=period)
		if isinstance(period, str):
			period = tempora.parse_timedelta(period)
		log.info("Setting keepalive for %s", period)
		connection.set_keepalive(period)