Adam Litke has uploaded a new change for review.

Change subject: qemuimg: Introduce compat_is_supported helper
......................................................................

qemuimg: Introduce compat_is_supported helper

To enable checking if a qcow2 image has a supported compatibility level,
add a simple utility function to qemuimg.

Change-Id: I341b4559d5d10709fa93b722572cf7f0a8f953ff
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1344289
Signed-off-by: Adam Litke <ali...@redhat.com>
---
M lib/vdsm/qemuimg.py
M tests/qemuimgTests.py
2 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/10/59410/1

diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py
index 608b14a..303d8f2 100644
--- a/lib/vdsm/qemuimg.py
+++ b/lib/vdsm/qemuimg.py
@@ -46,6 +46,11 @@
 
 _QCOW2_COMPAT_SUPPORTED = ["0.10", "1.1"]
 
+
+def compat_is_supported(compat):
+    return compat in _QCOW2_COMPAT_SUPPORTED
+
+
 __iregex = {
     'format': re.compile("^file format: (?P<value>\w+)$"),
     'virtualsize': re.compile("^virtual size: "
diff --git a/tests/qemuimgTests.py b/tests/qemuimgTests.py
index bb36272..3918e41 100644
--- a/tests/qemuimgTests.py
+++ b/tests/qemuimgTests.py
@@ -29,6 +29,14 @@
 QEMU_IMG = qemuimg._qemuimg.cmd
 
 
+@expandPermutations
+class GeneralTests(TestCaseBase):
+
+    @permutations((("0.10", True), ("1.1", True), ("10.1", False)))
+    def test_compat_is_supported(self, compat, result):
+        self.assertEqual(result, qemuimg.compat_is_supported(compat))
+
+
 class CommandTests(TestCaseBase):
 
     def supported(self, command, result):


-- 
To view, visit https://gerrit.ovirt.org/59410
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I341b4559d5d10709fa93b722572cf7f0a8f953ff
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <ali...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org

Reply via email to