diff options
-rw-r--r-- | lower-constraints.txt | 39 | ||||
-rw-r--r-- | oslo_utils/fnmatch.py | 9 | ||||
-rw-r--r-- | oslo_utils/imageutils.py | 10 | ||||
-rw-r--r-- | oslo_utils/tests/test_imageutils.py | 30 | ||||
-rw-r--r-- | releasenotes/notes/deprecate-fnmatch-057a092d434a0c53.yaml | 5 | ||||
-rw-r--r-- | releasenotes/notes/drop-imageutils-human-format-support-a89101a36c4dd3cb.yaml | 5 |
6 files changed, 51 insertions, 47 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt deleted file mode 100644 index ced789b..0000000 --- a/lower-constraints.txt +++ /dev/null @@ -1,39 +0,0 @@ -appdirs==1.3.0 -Babel==2.3.4 -bandit==1.4.0 -coverage==4.0 -ddt==1.0.1 -debtcollector==1.2.0 -eventlet==0.18.2 -extras==1.0.0 -fixtures==3.0.0 -funcsigs==1.0.0 -gitdb==0.6.4 -GitPython==1.0.1 -iso8601==0.1.11 -keystoneauth1==3.4.0 -linecache2==1.0.0 -netaddr==0.7.18 -netifaces==0.10.4 -os-client-config==1.28.0 -oslo.config==5.2.0 -oslo.i18n==3.15.3 -oslotest==3.2.0 -packaging==20.4 -pbr==2.0.0 -pyparsing==2.1.0 -python-mimeparse==1.6.0 -python-subunit==1.0.0 -pytz==2013.6 -PyYAML==3.13 -requests==2.14.2 -requestsexceptions==1.2.0 -rfc3986==0.3.1 -smmap==0.9.0 -stestr==2.0.0 -stevedore==1.20.0 -testscenarios==0.4 -testtools==2.2.0 -traceback2==1.4.0 -unittest2==1.1.0 -wrapt==1.7.0 diff --git a/oslo_utils/fnmatch.py b/oslo_utils/fnmatch.py index 71439ab..c52cf05 100644 --- a/oslo_utils/fnmatch.py +++ b/oslo_utils/fnmatch.py @@ -24,6 +24,15 @@ import os import posixpath import re import sys +import warnings + +import debtcollector + +warnings.simplefilter("always") +debtcollector.deprecate( + "Using the oslo.utils's 'fnmatch' module is deprecate, " + "please use the stdlib `fnmatch` module." +) if sys.version_info > (2, 7, 9): diff --git a/oslo_utils/imageutils.py b/oslo_utils/imageutils.py index fc7b494..8a7fe6e 100644 --- a/oslo_utils/imageutils.py +++ b/oslo_utils/imageutils.py @@ -28,6 +28,8 @@ Helper methods to deal with images. import json import re +import debtcollector + from oslo_utils._i18n import _ from oslo_utils import strutils @@ -38,8 +40,11 @@ class QemuImgInfo(object): The instance of :class:`QemuImgInfo` has properties: `image`, `backing_file`, `file_format`, `virtual_size`, `cluster_size`, `disk_size`, `snapshots` and `encrypted`. + The parameter format can be set to 'json' or 'human'. With 'json' format output, qemu image information will be parsed more easily and readable. + However 'human' format support will be dropped in next cycle and only + 'json' format will be supported. Prefer to use 'json' instead of 'human'. """ BACKING_FILE_RE = re.compile((r"^(.*?)\s*\(actual\s+path\s*:" r"\s+(.*?)\)\s*$"), re.I) @@ -61,6 +66,11 @@ class QemuImgInfo(object): self.encrypted = details.get('encrypted') self.format_specific = details.get('format-specific') else: + debtcollector.deprecate( + 'The human format is deprecated and the format parameter ' + 'will be removed. Use explicitly json instead', + version="xena", + category=FutureWarning) details = self._parse(cmd_output or '') self.image = details.get('image') self.backing_file = details.get('backing_file') diff --git a/oslo_utils/tests/test_imageutils.py b/oslo_utils/tests/test_imageutils.py index 6b3a9fa..63e0ee9 100644 --- a/oslo_utils/tests/test_imageutils.py +++ b/oslo_utils/tests/test_imageutils.py @@ -13,15 +13,19 @@ # License for the specific language governing permissions and limitations # under the License. +import warnings + from oslotest import base as test_base import testscenarios from oslo_utils import imageutils +from unittest import mock + load_tests = testscenarios.load_tests_apply_scenarios -class ImageUtilsRawTestCase(test_base.BaseTestCase): +class ImageUtilsHumanRawTestCase(test_base.BaseTestCase): _image_name = [ ('disk_config', dict(image_name='disk.config')), @@ -125,7 +129,8 @@ class ImageUtilsRawTestCase(test_base.BaseTestCase): if self.snapshot_count is not None: self.assertEqual(len(image_info.snapshots), self.snapshot_count) - def test_qemu_img_info(self): + @mock.patch('debtcollector.deprecate') + def test_qemu_img_info_human_format(self, mock_deprecate): img_info = self._initialize_img_info() if self.garbage_before_snapshot is True: img_info = img_info + ('blah BLAH: bb',) @@ -134,14 +139,16 @@ class ImageUtilsRawTestCase(test_base.BaseTestCase): if self.garbage_before_snapshot is False: img_info = img_info + ('junk stuff: bbb',) example_output = '\n'.join(img_info) + warnings.simplefilter("always", FutureWarning) image_info = imageutils.QemuImgInfo(example_output) + mock_deprecate.assert_called() self._base_validation(image_info) -ImageUtilsRawTestCase.generate_scenarios() +ImageUtilsHumanRawTestCase.generate_scenarios() -class ImageUtilsQemuTestCase(ImageUtilsRawTestCase): +class ImageUtilsHumanQemuTestCase(ImageUtilsHumanRawTestCase): _file_format = [ ('qcow2', dict(file_format='qcow2')), @@ -180,7 +187,8 @@ class ImageUtilsQemuTestCase(ImageUtilsRawTestCase): cls._qcow2_encrypted, cls._qcow2_backing_file) - def test_qemu_img_info(self): + @mock.patch("debtcollector.deprecate") + def test_qemu_img_info_human_format(self, mock_deprecate): img_info = self._initialize_img_info() img_info = img_info + ('cluster_size: %s' % self.cluster_size,) if self.backing_file is not None: @@ -195,7 +203,9 @@ class ImageUtilsQemuTestCase(ImageUtilsRawTestCase): if self.garbage_before_snapshot is False: img_info = img_info + ('junk stuff: bbb',) example_output = '\n'.join(img_info) + warnings.simplefilter("always", FutureWarning) image_info = imageutils.QemuImgInfo(example_output) + mock_deprecate.assert_called() self._base_validation(image_info) self.assertEqual(image_info.cluster_size, self.exp_cluster_size) if self.backing_file is not None: @@ -205,7 +215,7 @@ class ImageUtilsQemuTestCase(ImageUtilsRawTestCase): self.assertEqual(image_info.encrypted, self.encrypted) -ImageUtilsQemuTestCase.generate_scenarios() +ImageUtilsHumanQemuTestCase.generate_scenarios() class ImageUtilsBlankTestCase(test_base.BaseTestCase): @@ -220,7 +230,8 @@ class ImageUtilsBlankTestCase(test_base.BaseTestCase): class ImageUtilsJSONTestCase(test_base.BaseTestCase): - def test_qemu_img_info_json_format(self): + @mock.patch("debtcollector.deprecate") + def test_qemu_img_info(self, mock_deprecate): img_output = '''{ "virtual-size": 41126400, "filename": "fake_img", @@ -230,6 +241,7 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase): "format-specific": {"data": {"foo": "bar"}} }''' image_info = imageutils.QemuImgInfo(img_output, format='json') + mock_deprecate.assert_not_called() self.assertEqual(41126400, image_info.virtual_size) self.assertEqual('fake_img', image_info.image) self.assertEqual(65536, image_info.cluster_size) @@ -237,9 +249,11 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase): self.assertEqual(13168640, image_info.disk_size) self.assertEqual("bar", image_info.format_specific["data"]["foo"]) - def test_qemu_img_info_json_format_blank(self): + @mock.patch("debtcollector.deprecate") + def test_qemu_img_info_blank(self, mock_deprecate): img_output = '{}' image_info = imageutils.QemuImgInfo(img_output, format='json') + mock_deprecate.assert_not_called() self.assertIsNone(image_info.virtual_size) self.assertIsNone(image_info.image) self.assertIsNone(image_info.cluster_size) diff --git a/releasenotes/notes/deprecate-fnmatch-057a092d434a0c53.yaml b/releasenotes/notes/deprecate-fnmatch-057a092d434a0c53.yaml new file mode 100644 index 0000000..e187d5f --- /dev/null +++ b/releasenotes/notes/deprecate-fnmatch-057a092d434a0c53.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + Oslo.utils's ``fnmatch`` module is deprecated, please use the stdlib + ``fnmatch`` module which is thread safe for python 3+. diff --git a/releasenotes/notes/drop-imageutils-human-format-support-a89101a36c4dd3cb.yaml b/releasenotes/notes/drop-imageutils-human-format-support-a89101a36c4dd3cb.yaml new file mode 100644 index 0000000..16b56e5 --- /dev/null +++ b/releasenotes/notes/drop-imageutils-human-format-support-a89101a36c4dd3cb.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + Support for parsing the ``human`` format has been deprecated and will + be removed in a future release. |