Get rid of pkg_resources

... because pkg_resources was removed in Python 3.12 .

Change-Id: Ib0de144da9d1933ea63aea585df4832c69d7c2fb
This commit is contained in:
Takashi Kajinami 2024-10-02 23:55:39 +09:00
parent b9c987ee75
commit 6f8924a57c
3 changed files with 12 additions and 10 deletions

View File

@ -15,7 +15,6 @@
# under the License.
import fnmatch
import os
import pkg_resources
from oslo_log import log
import yaml
@ -57,8 +56,9 @@ class ConfigManagerBase(object):
if not cfg_loc:
LOG.debug("No pipeline definitions configuration file found! "
"Using default config.")
cfg_loc = pkg_resources.resource_filename(
__name__, 'pipeline/data/' + cfg_file)
cfg_loc = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'pipeline', 'data', cfg_file)
with open(cfg_loc) as fap:
conf = yaml.safe_load(fap)
LOG.debug("Config file: %s", conf)

View File

@ -14,11 +14,11 @@
# under the License.
import fnmatch
import os
from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
import pkg_resources
from ceilometer import declarative
from ceilometer.event import models
@ -278,10 +278,12 @@ class NotificationEventsConverter(object):
def setup_events(conf, trait_plugin_mgr):
"""Setup the event definitions from yaml config file."""
return NotificationEventsConverter(
conf,
declarative.load_definitions(
conf, [], conf.event.definitions_cfg_file,
pkg_resources.resource_filename(
'ceilometer', "pipeline/data/event_definitions.yaml")),
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'..', 'pipeline', 'data', 'event_definitions.yaml')),
trait_plugin_mgr)

View File

@ -17,8 +17,7 @@ import fnmatch
import itertools
import json
import operator
import pkg_resources
import tenacity
import os
import threading
from gnocchiclient import exceptions as gnocchi_exc
@ -26,6 +25,7 @@ from keystoneauth1 import exceptions as ka_exceptions
from oslo_log import log
from oslo_utils import timeutils
from stevedore import extension
import tenacity
from urllib import parse as urlparse
from ceilometer import cache_utils
@ -243,8 +243,8 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
namespace='ceilometer.event.trait_plugin')
data = declarative.load_definitions(
conf, {}, resources_definition_file,
pkg_resources.resource_filename(__name__,
"data/gnocchi_resources.yaml"))
os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data', 'gnocchi_resources.yaml'))
archive_policy_default = data.get("archive_policy_default",
"ceilometer-low")