Merge "QemuImgInfo: Fix inconsistent value format of encrypted"

This commit is contained in:
Zuul 2021-10-13 14:25:59 +00:00 committed by Gerrit Code Review
commit d8b3e046ce
3 changed files with 11 additions and 2 deletions

View File

@ -63,7 +63,7 @@ class QemuImgInfo(object):
self.cluster_size = details.get('cluster-size')
self.disk_size = details.get('actual-size')
self.snapshots = details.get('snapshots', [])
self.encrypted = details.get('encrypted')
self.encrypted = 'yes' if details.get('encrypted') else None
self.format_specific = details.get('format-specific')
else:
if cmd_output is not None:

View File

@ -238,7 +238,8 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
"cluster-size": 65536,
"format": "qcow2",
"actual-size": 13168640,
"format-specific": {"data": {"foo": "bar"}}
"format-specific": {"data": {"foo": "bar"}},
"encrypted": true
}'''
image_info = imageutils.QemuImgInfo(img_output, format='json')
mock_deprecate.assert_not_called()
@ -248,6 +249,7 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
self.assertEqual('qcow2', image_info.file_format)
self.assertEqual(13168640, image_info.disk_size)
self.assertEqual("bar", image_info.format_specific["data"]["foo"])
self.assertEqual('yes', image_info.encrypted)
@mock.patch("debtcollector.deprecate")
def test_qemu_img_info_blank(self, mock_deprecate):
@ -260,3 +262,4 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
self.assertIsNone(image_info.file_format)
self.assertIsNone(image_info.disk_size)
self.assertIsNone(image_info.format_specific)
self.assertIsNone(image_info.encrypted)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
`bug #1942682 <https://bugs.launchpad.net/oslo.utils/+bug/1942682>`_:
Fix inconsistent value of `QemuImgInfo.encrypted`. Now the attribute is
always `'yes'` or `None` regardless of the format(`human` or `json`) used.