summaryrefslogtreecommitdiff
path: root/ceilometer/publisher
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-12-21 07:39:12 +0000
committerGerrit Code Review <review@openstack.org>2022-12-21 07:39:12 +0000
commit2686aeb695f5a7f08e58095079ac99ff745451a8 (patch)
tree80e48cd0db61d7789c73a735178c51b930a4e6c3 /ceilometer/publisher
parent23299e55d6800d65926611792ff0069bab67448b (diff)
parentb4a2801ec6a99df400d353d27a11de9be879c2a3 (diff)
downloadceilometer-2686aeb695f5a7f08e58095079ac99ff745451a8.tar.gz
Merge "Change oslo_cache implementation"
Diffstat (limited to 'ceilometer/publisher')
-rw-r--r--ceilometer/publisher/gnocchi.py31
1 files changed, 6 insertions, 25 deletions
diff --git a/ceilometer/publisher/gnocchi.py b/ceilometer/publisher/gnocchi.py
index 19f186c7..90e4a207 100644
--- a/ceilometer/publisher/gnocchi.py
+++ b/ceilometer/publisher/gnocchi.py
@@ -14,39 +14,29 @@
# under the License.
from collections import defaultdict
import fnmatch
-import hashlib
import itertools
import json
import operator
import pkg_resources
import threading
-import uuid
from gnocchiclient import exceptions as gnocchi_exc
from keystoneauth1 import exceptions as ka_exceptions
-import oslo_cache
from oslo_log import log
from oslo_utils import timeutils
from stevedore import extension
from urllib import parse as urlparse
+from ceilometer import cache_utils
from ceilometer import declarative
from ceilometer import gnocchi_client
from ceilometer.i18n import _
from ceilometer import keystone_client
from ceilometer import publisher
-NAME_ENCODED = __name__.encode('utf-8')
-CACHE_NAMESPACE = uuid.UUID(bytes=hashlib.md5(NAME_ENCODED).digest())
LOG = log.getLogger(__name__)
-def cache_key_mangler(key):
- """Construct an opaque cache key."""
-
- return uuid.uuid5(CACHE_NAMESPACE, key).hex
-
-
EVENT_CREATE, EVENT_UPDATE, EVENT_DELETE = ("create", "update", "delete")
@@ -213,20 +203,11 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
timeout = options.get('timeout', [6.05])[-1]
self._ks_client = keystone_client.get_client(conf)
- self.cache = None
- try:
- oslo_cache.configure(conf)
- # NOTE(cdent): The default cache backend is a real but
- # noop backend. We don't want to use that here because
- # we want to avoid the cache pathways entirely if the
- # cache has not been configured explicitly.
- if conf.cache.enabled:
- cache_region = oslo_cache.create_region()
- self.cache = oslo_cache.configure_cache_region(
- conf, cache_region)
- self.cache.key_mangler = cache_key_mangler
- except oslo_cache.exception.ConfigurationError as exc:
- LOG.warning('unable to configure oslo_cache: %s', exc)
+ # NOTE(cdent): The default cache backend is a real but
+ # noop backend. We don't want to use that here because
+ # we want to avoid the cache pathways entirely if the
+ # cache has not been configured explicitly.
+ self.cache = cache_utils.get_client(conf)
self._gnocchi_project_id = None
self._gnocchi_project_id_lock = threading.Lock()