[Kimchi-devel] [project-kimchi][PATCHv4 5/5] storage server: Update model and mockmodel

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Mon Dec 30 02:17:30 UTC 2013


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

Query all storage pool to retrieve storage server we used.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/mockmodel.py | 13 +++++++++++++
 src/kimchi/model.py     | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 348127a..f53e799 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -405,6 +405,19 @@ class MockModel(object):
                     iso_volumes.append(res)
         return iso_volumes
 
+    def storageservers_get_list(self, target_type):
+        pools = self.storagepools_get_list()
+        server_list = []
+        for pool in pools:
+            try:
+                pool_info = self.storagepool_lookup(pool)
+                if pool_info['type'] == target_type:
+                    server_list.append(pool_info['source']['addr'])
+            except NotFoundError:
+                pass
+
+        return server_list
+
     def dummy_interfaces(self):
         interfaces = {}
         ifaces = {"eth1": "nic", "bond0": "bonding",
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index 3bc5d6d..20f68f6 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -1220,6 +1220,19 @@ class Model(object):
             else:
                 raise
 
+    def storageservers_get_list(self, target_type):
+        pools = self.storagepools_get_list()
+        server_list = []
+        for pool in pools:
+            try:
+                pool_info = self.storagepool_lookup(pool)
+                if pool_info['type'] == target_type:
+                    server_list.append(pool_info['source']['addr'])
+            except NotFoundError:
+                pass
+
+        return server_list
+
     def _get_screenshot(self, vm_uuid):
         with self.objstore as session:
             try:
@@ -1400,7 +1413,6 @@ class LibvirtVMTemplate(VMTemplate):
             pool.createXML(v['xml'].encode('utf-8'), 0)
         return vol_list
 
-
 class LibvirtVMScreenshot(VMScreenshot):
     def __init__(self, vm_uuid, conn):
         VMScreenshot.__init__(self, vm_uuid)
-- 
1.8.1.2




More information about the Kimchi-devel mailing list