[Kimchi-devel] [PATCH v2 1/3] Fix Key Error when editing CD ROM path

Aline Manera alinefm at linux.vnet.ibm.com
Mon Aug 11 19:38:46 UTC 2014


On 08/08/2014 04:34 PM, Christy Perez wrote:
> lxml only accepts strings as parameters when looking
> up xml elements. The port for remote ISO was being
> passed in as an int, and a KeyError was thrown.
>
> This patch just casts the ints to strings for the
> lookups.
>
> Signed-off-by: Christy Perez <christy at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vmstorages.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index b5311db..25c3aaa 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -67,7 +67,7 @@ def _get_storage_xml(params, ignore_source=False):
>       # Working with url paths
>       if src_type == 'network':
>           output = urlparse.urlparse(params.get('path'))
> -        port = output.port or socket.getservbyname(output.scheme)
> +        port = str(output.port) or str(socket.getservbyname(output.scheme))

The correct would be:

port = str(output.port or socket.getservbyname(output.scheme))

Otherwise, if output.port is None we will convert None to string and use 
it as the port value


>           host = E.host(name=output.hostname, port=port)
>           source = E.source(protocol=output.scheme, name=output.path)
>           source.append(host)




More information about the Kimchi-devel mailing list