[Kimchi-devel] [PATCHv7 2/7] Fix vm disk path when it does not have source element
Sheldon
shaohef at linux.vnet.ibm.com
Mon Mar 10 09:42:57 UTC 2014
Reviewed-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
a log info is better?
On 03/10/2014 05:05 PM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> When vm disk does not have source element,
> objectify library will error with 'no such element: source'
> Trap this exception.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
> src/kimchi/model/vmstorages.py | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index 6298a81..c1c90ce 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -163,17 +163,20 @@ class VMStorageModel(object):
> if disk is None:
> raise NotFoundError("KCHCDROM0007E", {'dev_name': dev_name,
> 'vm_name': vm_name})
> - source = disk.source
> path = ""
> - if source is not None:
> - src_type = disk.attrib['type']
> - if src_type == 'network':
> - host = source.host
> - path = (source.attrib['protocol'] + '://' +
> - host.attrib['name'] + ':' +
> - host.attrib['port'] + source.attrib['name'])
> - else:
> - path = source.attrib[DEV_TYPE_SRC_ATTR_MAP[src_type]]
> + try:
> + source = disk.source
> + if source is not None:
> + src_type = disk.attrib['type']
> + if src_type == 'network':
> + host = source.host
> + path = (source.attrib['protocol'] + '://' +
> + host.attrib['name'] + ':' +
> + host.attrib['port'] + source.attrib['name'])
> + else:
> + path = source.attrib[DEV_TYPE_SRC_ATTR_MAP[src_type]]
> + except:
> + pass
> dev_type = disk.attrib['device']
> return {'dev': dev_name,
> 'type': dev_type,
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center
More information about the Kimchi-devel
mailing list