diff options
author | Zuul <zuul@review.opendev.org> | 2021-05-04 19:11:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-05-04 19:11:39 +0000 |
commit | 4ac3d795199c0e654249030838dc5ab764a75745 (patch) | |
tree | 95e0c43e6c10dd76ee424ab1f285df1046c65a8a | |
parent | c09dd5ce0bec7f4c969838dda535494b2465b456 (diff) | |
parent | 3251d7b6417ff67c7f0d1e51bb9b3bea078de967 (diff) | |
download | ironic-python-agent-4ac3d795199c0e654249030838dc5ab764a75745.tar.gz |
Merge "Remove runtime dependency on pbr"
-rw-r--r-- | ironic_python_agent/ironic_api_client.py | 2 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/test_ironic_api_client.py | 8 | ||||
-rw-r--r-- | ironic_python_agent/version.py | 9 | ||||
-rw-r--r-- | requirements.txt | 1 |
4 files changed, 13 insertions, 7 deletions
diff --git a/ironic_python_agent/ironic_api_client.py b/ironic_python_agent/ironic_api_client.py index 81573324..dc6f0cf7 100644 --- a/ironic_python_agent/ironic_api_client.py +++ b/ironic_python_agent/ironic_api_client.py @@ -150,7 +150,7 @@ class APIClient(object): data['agent_token'] = self.agent_token if api_ver >= AGENT_VERSION_IRONIC_VERSION: - data['agent_version'] = version.version_info.release_string() + data['agent_version'] = version.__version__ if api_ver >= AGENT_VERIFY_CA_IRONIC_VERSION and generated_cert: data['agent_verify_ca'] = generated_cert diff --git a/ironic_python_agent/tests/unit/test_ironic_api_client.py b/ironic_python_agent/tests/unit/test_ironic_api_client.py index 5de49f4e..ba603651 100644 --- a/ironic_python_agent/tests/unit/test_ironic_api_client.py +++ b/ironic_python_agent/tests/unit/test_ironic_api_client.py @@ -148,7 +148,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): self.assertEqual(API_URL + heartbeat_path, request_args[1]) expected_data = { 'callback_url': 'http://192.0.2.1:9999', - 'agent_version': version.version_info.release_string()} + 'agent_version': version.__version__} self.assertEqual(jsonutils.dumps(expected_data), data) def test_successful_heartbeat_ip6(self): @@ -171,7 +171,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): self.assertEqual(API_URL + heartbeat_path, request_args[1]) expected_data = { 'callback_url': 'http://[fc00:1111::4]:9999', - 'agent_version': version.version_info.release_string()} + 'agent_version': version.__version__} self.assertEqual(jsonutils.dumps(expected_data), data) def test_successful_heartbeat_with_token(self): @@ -196,7 +196,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): expected_data = { 'callback_url': 'http://192.0.2.1:9999', 'agent_token': 'magical', - 'agent_version': version.version_info.release_string()} + 'agent_version': version.__version__} self.assertEqual(jsonutils.dumps(expected_data), data) def test_heartbeat_agent_version_unsupported(self): @@ -244,7 +244,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): expected_data = { 'callback_url': 'https://192.0.2.1:9999', 'agent_token': 'magical', - 'agent_version': version.version_info.release_string(), + 'agent_version': version.__version__, 'agent_verify_ca': 'I am a cert'} self.assertEqual(jsonutils.dumps(expected_data), data) headers = self.api_client.session.request.call_args[1]['headers'] diff --git a/ironic_python_agent/version.py b/ironic_python_agent/version.py index 9082d81e..3c0bdb35 100644 --- a/ironic_python_agent/version.py +++ b/ironic_python_agent/version.py @@ -13,6 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -import pbr.version +try: + # For Python 3.8 and later + import importlib.metadata as importlib_metadata +except ImportError: + # For everyone else + import importlib_metadata -version_info = pbr.version.VersionInfo('ironic_python_agent') +__version__ = importlib_metadata.version("ironic_python_agent") diff --git a/requirements.txt b/requirements.txt index 9fefc997..eacef315 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 +importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0 eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT netifaces>=0.10.4 # MIT oslo.config>=5.2.0 # Apache-2.0 |