Change in vdsm[master]: virt: utils: add is_kvm helper

fromani at redhat.com fromani at redhat.com
Mon Apr 4 11:26:41 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: virt: utils: add is_kvm helper
......................................................................

virt: utils: add is_kvm helper

Add silly helper to be used in the upcoming patches
to reduce the code duplication.

Change-Id: I3f9e1b8f9326e565ee7324d0b328100ca86c6967
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M lib/vdsm/virt/utils.py
M tests/vmUtilsTests.py
2 files changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/55647/1

diff --git a/lib/vdsm/virt/utils.py b/lib/vdsm/virt/utils.py
index 286dc18..bc6248c 100644
--- a/lib/vdsm/virt/utils.py
+++ b/lib/vdsm/virt/utils.py
@@ -118,3 +118,7 @@
     if os.path.islink(sock):
         rmFile(os.path.realpath(sock))
     rmFile(sock)
+
+
+def is_kvm(conf):
+    return conf.get('vmType') == 'kvm'
diff --git a/tests/vmUtilsTests.py b/tests/vmUtilsTests.py
index 3d54efb..d103fb7 100644
--- a/tests/vmUtilsTests.py
+++ b/tests/vmUtilsTests.py
@@ -155,3 +155,17 @@
     @permutations([[-1], [1023]])
     def test_eventToString_unknown_event(self, code):
         self.assertTrue(vm.eventToString(code))
+
+
+class TestIsKvm(TestCaseBase):
+
+    def test_empty(self):
+        self.assertFalse(utils.is_kvm({}))
+
+    def test_succeed(self):
+        conf = {'vmType': 'kvm'}
+        self.assertTrue(utils.is_kvm(conf))
+
+    def test_fails(self):
+        conf = {'vmType': 'xen'}
+        self.assertFalse(utils.is_kvm(conf))


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f9e1b8f9326e565ee7324d0b328100ca86c6967
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list