[Kimchi-devel] [PATCH 4/7] Change VMTemplate._get_iscsi_disks_xml() to use the common get_disk_xml()

Aline Manera alinefm at linux.vnet.ibm.com
Fri Oct 31 17:22:23 UTC 2014


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

diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 04b2cc2..915f826 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -18,7 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
 import os
-import string
 import socket
 import time
 import urlparse
@@ -211,24 +210,17 @@ class VMTemplate(object):
         return ret
 
     def _get_iscsi_disks_xml(self):
-        def build_disk_xml(children=[]):
-            disk = E.disk(type='block', device='disk')
-            disk.extend(children)
-            return etree.tostring(disk)
-
         ret = ""
-        children = []
-        children.append(E.driver(name='qemu', type='raw'))
-        disk_bus = self.info['disk_bus']
-        dev_prefix = self._bus_to_dev[disk_bus]
         pool_name = pool_name_from_uri(self.info['storagepool'])
         for i, d in enumerate(self.info['disks']):
-            source = E.source(dev=self._get_volume_path(pool_name,
-                                                        d.get('volume')))
-            # FIXME if more than 26 disks
-            target = E.target(dev=dev_prefix + string.lowercase[i],
-                              bus=disk_bus)
-            ret += build_disk_xml(children+[source, target])
+            params = {}
+            params['disk'] = 'block'
+            params['type'] = 'disk'
+            params['format'] = 'raw'
+            params['bus'] = self.info['disk_bus']
+            params['index'] = i
+            params['path'] = self._get_volume_path(pool_name, d.get('volume'))
+            ret += get_disk_xml(params)
 
         return ret
 
-- 
1.9.3




More information about the Kimchi-devel mailing list