Merge "Get rid of pkg_resources"

This commit is contained in:
Zuul 2024-10-08 13:52:59 +00:00 committed by Gerrit Code Review
commit a30fea57d7
2 changed files with 5 additions and 6 deletions

View File

@ -13,6 +13,7 @@
# limitations under the License.
import collections
import importlib.metadata
import ipaddress
import random
import socket
@ -26,7 +27,6 @@ from ironic_lib import mdns
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
import pkg_resources
from ironic_python_agent.api import app
from ironic_python_agent import config
@ -233,8 +233,7 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
self.listen_address = listen_address
self.advertise_address = advertise_address
self.advertise_protocol = advertise_protocol
self.version = pkg_resources.get_distribution('ironic-python-agent')\
.version
self.version = importlib.metadata.version('ironic-python-agent')
self.api = app.Application(self, cfg.CONF)
self.heartbeat_timeout = None
self.started_at = None

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import importlib.metadata
import json
import socket
import time
@ -21,7 +22,6 @@ from unittest.mock import sentinel
from ironic_lib import exception as lib_exc
from oslo_concurrency import processutils
from oslo_config import cfg
import pkg_resources
from stevedore import extension
from ironic_python_agent import agent
@ -231,8 +231,8 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest):
status = self.agent.get_status()
self.assertIsInstance(status, agent.IronicPythonAgentStatus)
self.assertEqual(started_at, status.started_at)
self.assertEqual(pkg_resources.get_distribution('ironic-python-agent')
.version, status.version)
self.assertEqual(importlib.metadata.version('ironic-python-agent'),
status.version)
@mock.patch(
'ironic_python_agent.hardware_managers.cna._detect_cna_card',