diff options
-rw-r--r-- | oslo_utils/imageutils.py | 4 | ||||
-rw-r--r-- | oslo_utils/tests/test_imageutils.py | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/oslo_utils/imageutils.py b/oslo_utils/imageutils.py index 14d7b5c..1194df3 100644 --- a/oslo_utils/imageutils.py +++ b/oslo_utils/imageutils.py @@ -58,6 +58,7 @@ class QemuImgInfo(object): self.disk_size = details.get('actual-size') self.snapshots = details.get('snapshots', []) self.encrypted = details.get('encrypted') + self.format_specific = details.get('format-specific') else: details = self._parse(cmd_output or '') self.image = details.get('image') @@ -68,6 +69,7 @@ class QemuImgInfo(object): self.disk_size = details.get('disk_size') self.snapshots = details.get('snapshot_list', []) self.encrypted = details.get('encrypted') + self.format_specific = None def __str__(self): lines = [ @@ -82,6 +84,8 @@ class QemuImgInfo(object): lines.append("snapshots: %s" % self.snapshots) if self.encrypted: lines.append("encrypted: %s" % self.encrypted) + if self.format_specific: + lines.appened("format_specific: %s" % self.format_specific) return "\n".join(lines) def _canonicalize(self, field): diff --git a/oslo_utils/tests/test_imageutils.py b/oslo_utils/tests/test_imageutils.py index de262e0..bb6340c 100644 --- a/oslo_utils/tests/test_imageutils.py +++ b/oslo_utils/tests/test_imageutils.py @@ -220,7 +220,8 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase): "filename": "fake_img", "cluster-size": 65536, "format": "qcow2", - "actual-size": 13168640 + "actual-size": 13168640, + "format-specific": {"data": {"foo": "bar"}} }''' image_info = imageutils.QemuImgInfo(img_output, format='json') self.assertEqual(41126400, image_info.virtual_size) @@ -228,6 +229,7 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase): self.assertEqual(65536, image_info.cluster_size) self.assertEqual('qcow2', image_info.file_format) 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): img_output = '{}' @@ -237,3 +239,4 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase): self.assertIsNone(image_info.cluster_size) self.assertIsNone(image_info.file_format) self.assertIsNone(image_info.disk_size) + self.assertIsNone(image_info.format_specific) |