From 91596bef6bee9ab451918b5a868ff2a74194d3de Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 2 Oct 2024 02:25:49 +0900 Subject: [PATCH] Remove Python 3.8 support Python 3.8 is no longer part of tested runtimes since 2024.2 . Removing support for Python 3.8 allows us to replace deprecated md5 wrapper from oslo.utils [1] by direct call of hashlib.md5. [1] https://review.opendev.org/c/openstack/oslo.utils/+/930879 Also add python 3.12 to classifiers because now py312 unit test job is voting. Change-Id: I53da305538e27f2ff20a1ecb25960ebb03388011 --- nova/crypto.py | 4 ++-- nova/privsep/fs.py | 5 +++-- nova/tests/unit/test_utils.py | 4 ++-- nova/utils.py | 3 +-- releasenotes/notes/remove-py38-5c619aee267bc1f3.yaml | 5 +++++ setup.cfg | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/remove-py38-5c619aee267bc1f3.yaml diff --git a/nova/crypto.py b/nova/crypto.py index 3b358a3e16..44aeef2fa9 100644 --- a/nova/crypto.py +++ b/nova/crypto.py @@ -21,6 +21,7 @@ Includes root and intermediate CAs, SSH key_pairs and x509 certificates. import base64 import binascii +import hashlib import io import os import typing as ty @@ -36,7 +37,6 @@ from cryptography import x509 from oslo_concurrency import processutils from oslo_log import log as logging from oslo_serialization import base64 as oslo_base64 -from oslo_utils.secretutils import md5 import paramiko import nova.conf @@ -75,7 +75,7 @@ def generate_fingerprint(public_key: str) -> str: serialization.load_ssh_public_key( pub_bytes, backends.default_backend()) pub_data = base64.b64decode(public_key.split(' ')[1]) - raw_fp = md5(pub_data, usedforsecurity=False).hexdigest() + raw_fp = hashlib.md5(pub_data, usedforsecurity=False).hexdigest() return ':'.join(a + b for a, b in zip(raw_fp[::2], raw_fp[1::2])) except Exception: raise exception.InvalidKeypair( diff --git a/nova/privsep/fs.py b/nova/privsep/fs.py index 11249322a4..0ba25ca852 100644 --- a/nova/privsep/fs.py +++ b/nova/privsep/fs.py @@ -17,9 +17,10 @@ Helpers for filesystem related routines. """ +import hashlib + from oslo_concurrency import processutils from oslo_log import log as logging -from oslo_utils.secretutils import md5 import nova.privsep @@ -283,7 +284,7 @@ def _get_hash_str(base_str): """ if isinstance(base_str, str): base_str = base_str.encode('utf-8') - return md5(base_str, usedforsecurity=False).hexdigest() + return hashlib.md5(base_str, usedforsecurity=False).hexdigest() def get_file_extension_for_os_type(os_type, default_ephemeral_format, diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index f3ddd9d52b..f6372ce450 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -13,6 +13,7 @@ # under the License. import datetime +import hashlib import os import os.path import tempfile @@ -29,7 +30,6 @@ from oslo_context import context as common_context from oslo_context import fixture as context_fixture from oslo_utils import encodeutils from oslo_utils import fixture as utils_fixture -from oslo_utils.secretutils import md5 from nova import context from nova import exception @@ -203,7 +203,7 @@ class GenericUtilsTestCase(test.NoDBTestCase): def test_get_hash_str(self): base_str = b"foo" base_unicode = u"foo" - value = md5(base_str, usedforsecurity=False).hexdigest() + value = hashlib.md5(base_str, usedforsecurity=False).hexdigest() self.assertEqual( value, utils.get_hash_str(base_str)) self.assertEqual( diff --git a/nova/utils.py b/nova/utils.py index 777a188637..52ee35c2d6 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -44,7 +44,6 @@ import oslo_messaging as messaging from oslo_utils import encodeutils from oslo_utils import excutils from oslo_utils import importutils -from oslo_utils.secretutils import md5 from oslo_utils import strutils from oslo_utils import timeutils @@ -791,7 +790,7 @@ def get_hash_str(base_str): """ if isinstance(base_str, str): base_str = base_str.encode('utf-8') - return md5(base_str, usedforsecurity=False).hexdigest() + return hashlib.md5(base_str, usedforsecurity=False).hexdigest() def get_sha256_str(base_str): diff --git a/releasenotes/notes/remove-py38-5c619aee267bc1f3.yaml b/releasenotes/notes/remove-py38-5c619aee267bc1f3.yaml new file mode 100644 index 0000000000..0403163605 --- /dev/null +++ b/releasenotes/notes/remove-py38-5c619aee267bc1f3.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Support for Python 3.8 has been removed. Now the minimum python version + supported is 3.9 . diff --git a/setup.cfg b/setup.cfg index 8d323280fa..1b878af091 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ project_urls = Bug Tracker = https://bugs.launchpad.net/nova/ Documentation = https://docs.openstack.org/nova/ Source Code = https://opendev.org/openstack/nova -python_requires = >=3.8 +python_requires = >=3.9 classifiers = Development Status :: 5 - Production/Stable Environment :: OpenStack @@ -20,10 +20,10 @@ classifiers = Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: Implementation :: CPython