[Kimchi-devel] [PATCH 5/8] Remove ignore_src parameter from get_disk_xml()

Aline Manera alinefm at linux.vnet.ibm.com
Tue Oct 28 12:42:58 UTC 2014


The ignore_src parameter can be automatically identified by the disk path
value, ie, when it is an empty string the source can be ignored.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/kimchi/model/vmstorages.py | 7 +++----
 src/kimchi/xmlutils/disk.py    | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index b3b1514..4c4682c 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -190,13 +190,12 @@ class VMStorageModel(object):
             raise OperationFailed("KCHVMSTOR0010E", {'error': e.message})
 
     def update(self, vm_name, dev_name, params):
-        path = params.get('path')
-        if path and len(path) != 0:
+        path = params.get('path', '')
+        params['path'] = path
+        if len(path) != 0:
             src_type = _check_path(path)
-            ignore_source = False
         else:
             src_type = 'file'
-            ignore_source = True
         dom = VMModel.get_vm(vm_name, self.conn)
 
         dev_info = self.lookup(vm_name, dev_name)
diff --git a/src/kimchi/xmlutils/disk.py b/src/kimchi/xmlutils/disk.py
index aadbfb8..f40f34f 100644
--- a/src/kimchi/xmlutils/disk.py
+++ b/src/kimchi/xmlutils/disk.py
@@ -31,7 +31,7 @@ BUS_TO_DEV_MAP = {'ide': 'hd', 'virtio': 'vd', 'scsi': 'sd'}
 DEV_TYPE_SRC_ATTR_MAP = {'file': 'file', 'block': 'dev'}
 
 
-def get_disk_xml(src_type, params, ignore_src=False):
+def get_disk_xml(src_type, params):
     """
     <disk type='file' device='cdrom'>
       <driver name='qemu' type='raw'/>
@@ -57,7 +57,7 @@ def get_disk_xml(src_type, params, ignore_src=False):
             bus=params['address']['bus'], target='0',
             unit=params['address']['unit']))
 
-    if ignore_src:
+    if len(params['path']) == 0:
         return (dev, ET.tostring(disk, encoding='utf-8', pretty_print=True))
 
     if src_type == 'network':
-- 
1.9.3




More information about the Kimchi-devel mailing list