diff --git a/glance/async_/flows/location_import.py b/glance/async_/flows/location_import.py index 9936727bac..b9faf45b0f 100644 --- a/glance/async_/flows/location_import.py +++ b/glance/async_/flows/location_import.py @@ -18,7 +18,6 @@ import glance_store as store from oslo_config import cfg from oslo_log import log as logging from oslo_utils import encodeutils -from oslo_utils import secretutils from taskflow.patterns import linear_flow as lf from taskflow import retry from taskflow import task @@ -60,7 +59,7 @@ class _CalculateHash(task.Task): def _calculate_hash(self, image): current_os_hash_value = hashlib.new(self.hashing_algo) - current_checksum = secretutils.md5(usedforsecurity=False) + current_checksum = hashlib.md5(usedforsecurity=False) for chunk in image.get_data(): if chunk is None: break diff --git a/glance/image_cache/__init__.py b/glance/image_cache/__init__.py index 454cf7585b..e181ec257f 100644 --- a/glance/image_cache/__init__.py +++ b/glance/image_cache/__init__.py @@ -16,13 +16,13 @@ """ LRU Cache for Image Data """ +import hashlib from oslo_config import cfg from oslo_log import log as logging 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 units from glance.common import exception @@ -354,7 +354,7 @@ class ImageCache(object): def cache_tee_iter(self, image_id, image_iter, image_checksum): try: - current_checksum = md5(usedforsecurity=False) + current_checksum = hashlib.md5(usedforsecurity=False) with self.driver.open_for_write(image_id) as cache_file: for chunk in image_iter: diff --git a/glance/tests/functional/v2/test_images.py b/glance/tests/functional/v2/test_images.py index 59e990f68b..a305892fea 100644 --- a/glance/tests/functional/v2/test_images.py +++ b/glance/tests/functional/v2/test_images.py @@ -29,7 +29,6 @@ from oslo_config import cfg from oslo_limit import exception as ol_exc from oslo_limit import limit from oslo_serialization import jsonutils -from oslo_utils.secretutils import md5 from oslo_utils import units import requests @@ -212,7 +211,8 @@ class TestImages(functional.FunctionalTest): status='active', max_sec=10, delay_sec=0.2) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -355,7 +355,8 @@ class TestImages(functional.FunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -733,7 +734,8 @@ class TestImages(functional.FunctionalTest): response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, expect_c, expect_h, 'active', @@ -1176,7 +1178,8 @@ class TestImages(functional.FunctionalTest): image_data = b'ZZZZZ' response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -1190,7 +1193,8 @@ class TestImages(functional.FunctionalTest): image_data = b'WWWWW' response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image2_id, @@ -3793,7 +3797,8 @@ class TestImages(functional.FunctionalTest): headers = self._headers({'X-Tenant-Id': TENANT1}) url = 'http://127.0.0.1:%s/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha256(r.content).hexdigest()) validation_data = { 'os_hash_algo': 'sha256', @@ -3835,7 +3840,8 @@ class TestImages(functional.FunctionalTest): url = 'http://127.0.0.1:%s/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) validation_data = { 'os_hash_algo': 'sha512', @@ -3882,7 +3888,8 @@ class TestImages(functional.FunctionalTest): headers = self._headers({'X-Tenant-Id': TENANT1}) url = 'http://127.0.0.1:%s/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) data = jsonutils.dumps({'url': url}) response = requests.post(path, headers=headers, data=data) @@ -4056,7 +4063,8 @@ class TestImages(functional.FunctionalTest): response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, expect_c, expect_h, 'active', @@ -5029,7 +5037,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): status='active', max_sec=15, delay_sec=0.2) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -5194,7 +5203,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): status='active', max_sec=15, delay_sec=0.2) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -5358,7 +5368,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -5521,7 +5532,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -5683,7 +5695,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -5847,7 +5860,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -6071,7 +6085,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -6329,7 +6344,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -6471,7 +6487,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -6645,7 +6662,8 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest): response = requests.put(path, headers=headers, data=image_data) self.assertEqual(http.NO_CONTENT, response.status_code) - expect_c = str(md5(image_data, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(image_data, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(image_data).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -7181,7 +7199,8 @@ class TestCopyImagePermissions(functional.MultipleBackendFunctionalTest): delay_sec=0.2, start_delay_sec=1) with requests.get(image_data_uri) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) func_utils.verify_image_hashes_and_status(self, image_id, @@ -7942,7 +7961,8 @@ class TestMultipleBackendsLocationApi(functional.SynchronousAPIBase): headers = self._headers({'X-Tenant-Id': TENANT1}) url = 'http://127.0.0.1:%s/store1/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha256(r.content).hexdigest()) validation_data = { 'os_hash_algo': 'sha256', @@ -7984,7 +8004,8 @@ class TestMultipleBackendsLocationApi(functional.SynchronousAPIBase): url = 'http://127.0.0.1:%s/store2/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) validation_data = { 'os_hash_algo': 'sha512', @@ -8032,7 +8053,8 @@ class TestMultipleBackendsLocationApi(functional.SynchronousAPIBase): headers = self._headers({'X-Tenant-Id': TENANT1}) url = 'http://127.0.0.1:%s/store2/foo_image' % self.http_port0 with requests.get(url) as r: - expect_c = str(md5(r.content, usedforsecurity=False).hexdigest()) + expect_c = str( + hashlib.md5(r.content, usedforsecurity=False).hexdigest()) expect_h = str(hashlib.sha512(r.content).hexdigest()) data = {'url': url} response = self.api_post(path, headers=headers, json=data) diff --git a/glance/tests/unit/test_image_cache.py b/glance/tests/unit/test_image_cache.py index 750760bead..e63e6d946e 100644 --- a/glance/tests/unit/test_image_cache.py +++ b/glance/tests/unit/test_image_cache.py @@ -16,6 +16,7 @@ from contextlib import contextmanager import datetime import errno +import hashlib import io import os import tempfile @@ -26,7 +27,6 @@ import fixtures import glance_store as store from oslo_config import cfg from oslo_utils import fileutils -from oslo_utils import secretutils from oslo_utils import units from glance import async_ @@ -474,7 +474,7 @@ class ImageCacheTestCase(object): image = b"12345678990abcdefghijklmnop" image_id = 123 - md5 = secretutils.md5(usedforsecurity=False) + md5 = hashlib.md5(usedforsecurity=False) md5.update(image) checksum = md5.hexdigest() diff --git a/releasenotes/notes/remove-py38-0d208cda61f2e0a7.yaml b/releasenotes/notes/remove-py38-0d208cda61f2e0a7.yaml new file mode 100644 index 0000000000..0403163605 --- /dev/null +++ b/releasenotes/notes/remove-py38-0d208cda61f2e0a7.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 7b070f20d2..51eee52f19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ description_file = author = OpenStack author_email = openstack-discuss@lists.openstack.org home_page = https://docs.openstack.org/glance/latest/ -python_requires = >=3.8 +python_requires = >=3.9 classifier = Environment :: OpenStack Intended Audience :: Information Technology @@ -16,7 +16,6 @@ classifier = Programming Language :: Python Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11