示例#1
0
    def _make_callback_url(self, alert_id, domain_id, access_key):
        def _rollback(alert_id, access_key):
            _LOGGER.info(f'[_make_callback_url._rollback] '
                         f'Delete cache : {alert_id} '
                         f'({access_key})')
            cache.delete(f'alert-notification-callback:{alert_id}:{access_key}')

        cache.set(f'alert-notification-callback:{alert_id}:{access_key}', domain_id, expire=600)
        self.transaction.add_rollback(_rollback, alert_id, access_key)

        webhook_domain = config.get_global('WEBHOOK_DOMAIN')
        return f'{webhook_domain}/monitoring/v1/alert/{alert_id}/{access_key}/ACKNOWLEDGED'
示例#2
0
    def cache_filter(self, collector_id, secret_id, data):
        """
        FilerManager can save cache of filter for collect plugin
        Save the region_name cache
        Args:
            data (dict): {
                'region_name': list of region name,
                'cloud_service': list of cloud service (for cloud service plugin)
                }

        Key: collector-filter:<collector_id>:<secret_id>
        Value: region_name: [list of regions]
        """
        key = f'collector-filter:{collector_id}:{secret_id}'
        _LOGGER.debug(f'[cache_filter] {key} : {data}')
        cache.set(key, data, expire=self.CONSTANT_FILTER_CACHE_TIMEOUT)
示例#3
0
 def _set_lock(self, domain_id, name):
     try:
         key = f"supervisor:{domain_id}:{name}"
         return cache.set(key, 1, expire=SUPERVISOR_SYNC_EXPIRE_TIME)
     except Exception as e:
         _LOGGER.debug(f'[_set_lock] {key}, {e}')
         return False
示例#4
0
 def _create_job_task_stat_cache(self, job_id, job_task_id, domain_id):
     """ Update to cache
     Args:
         - kind: CREATED | UPDATED | ERROR
     cache key
         - job_task_stat:<job_id>:<job_task_id>:created = N
         - job_task_stat:<job_id>:<job_task_id>:updated = M
         - job_task_stat:<job_id>:<job_task_id<:failure = X
     """
     try:
         key = f'job_task_stat:{domain_id}:{job_id}:{job_task_id}:CREATED'
         cache.set(key, 0, expire=JOB_TASK_STAT_EXPIRE_TIME)
         key = f'job_task_stat:{domain_id}:{job_id}:{job_task_id}:UPDATED'
         cache.set(key, 0, expire=JOB_TASK_STAT_EXPIRE_TIME)
         key = f'job_task_stat:{domain_id}:{job_id}:{job_task_id}:FAILURE'
         cache.set(key, 0, expire=JOB_TASK_STAT_EXPIRE_TIME)
     except Exception as e:
         _LOGGER.error(f'[_create_job_task_stat_cache] {e}')
示例#5
0
    def _set_refresh_token_cache(self, new_refresh_key):
        if cache.is_set():
            if self.old_refresh_key:
                cache.delete(f'refresh-token:{self.old_refresh_key}')

            cache.set(f'refresh-token:{new_refresh_key}', '', expire=self.CONST_REFRESH_TIMEOUT)