[Kimchi-devel] [PATCH 3/3] Mockmodel and test changes for the new API

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Tue Jul 14 15:00:05 UTC 2015


From: Daniel Henrique Barboza <dhbarboza82 at gmail.com>

API added: getAvailableHostPCIDevices, option _available_only of
host/devices backend.

Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
---
 src/kimchi/mockmodel.py |  3 ++-
 tests/test_host.py      | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index aaf1af2..34bcfc9 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -335,7 +335,8 @@ class MockModel(Model):
         return self._mock_partitions.partitions[name]
 
     def _mock_devices_get_list(self, _cap=None, _passthrough=None,
-                               _passthrough_affected_by=None):
+                               _passthrough_affected_by=None,
+                               _available_only=None):
         if _cap is None:
             return self._mock_devices.devices.keys()
 
diff --git a/tests/test_host.py b/tests/test_host.py
index 1273457..fe6124e 100644
--- a/tests/test_host.py
+++ b/tests/test_host.py
@@ -190,3 +190,14 @@ class HostTests(unittest.TestCase):
                                 dev)
             affected_devs = [dev['name'] for dev in json.loads(resp.read())]
             self.assertTrue(set(affected_devs) <= set(dev_names))
+
+    def test_get_available_passthrough_devices(self):
+        resp = self.request('/host/devices?_passthrough=true')
+        all_devs = [dev['name'] for dev in json.loads(resp.read())]
+
+        resp = self.request(
+            '/host/devices?_passthrough=true&_available_only=true'
+        )
+        available_devs = [dev['name'] for dev in json.loads(resp.read())]
+
+        self.assertLessEqual(len(available_devs), len(all_devs))
-- 
2.4.3




More information about the Kimchi-devel mailing list