[Kimchi-devel] [PATCH 5/8] MockModel: Add mock code to list partitions to /host/partitions API

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jan 22 13:32:55 UTC 2015


To create a logical pool we need to make sure at least one partition
exists. So add fake partitions to MockModel to allow create and extend
a logical pool.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/kimchi/mockmodel.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 14891ee..affbf42 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -66,6 +66,7 @@ class MockModel(Model):
         osinfo.defaults = dict(defaults)
 
         self._mock_devices = MockDevices()
+        self._mock_partitions = MockPartitions()
         self._mock_storagevolumes = MockStorageVolumes()
         self._mock_swupdate = MockSoftwareUpdate()
         self._mock_repositories = MockRepositories()
@@ -288,6 +289,12 @@ class MockModel(Model):
 
         return self._model_storagevolume_lookup(pool, vol)
 
+    def _mock_partitions_get_list(self):
+        return self._mock_partitions.partitions.keys()
+
+    def _mock_partition_lookup(self, name):
+        return self._mock_partitions.partitions[name]
+
     def _mock_devices_get_list(self, _cap=None, _passthrough=None,
                                _passthrough_affected_by=None):
         if _cap is None:
@@ -427,6 +434,18 @@ class MockStorageVolumes(object):
                                             'ref_cnt': 0}}
 
 
+class MockPartitions(object):
+    def __init__(self):
+        self.partitions = {"vdx": {"available": True, "name": "vdx",
+                                   "fstype": "", "path": "/dev/vdx",
+                                   "mountpoint": "", "type": "disk",
+                                   "size": "2147483648"},
+                           "vdz": {"available": True, "name": "vdz",
+                                   "fstype": "", "path": "/dev/vdz",
+                                   "mountpoint": "", "type": "disk",
+                                   "size": "2147483648"}}
+
+
 class MockDevices(object):
     def __init__(self):
         self.devices = {
-- 
2.1.0




More information about the Kimchi-devel mailing list