[Kimchi-devel] [PATCH] [Kimchi] Handle URLError exception when creating Template.

Ramon Medeiros ramonn at linux.vnet.ibm.com
Wed Jun 15 02:20:23 UTC 2016


Reviewed-By: Ramon Medeiros <ramonn at br.ibm.com>

On 06/14/2016 07:26 PM, pvital at linux.vnet.ibm.com wrote:
> From: Paulo Vital <pvital at linux.vnet.ibm.com>
>
> urllib2 raised URLError when could not access a remote file due to unauthorized
> access, for example. This patch gives to VMTemplate the ability of handle this
> exception and raises a relevant error message to user.
>
> This patch fixes Issue #959
>
> Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
> ---
>   i18n.py       | 1 +
>   vmtemplate.py | 3 +++
>   2 files changed, 4 insertions(+)
>
> diff --git a/i18n.py b/i18n.py
> index 2d8390f..b33c6ec 100644
> --- a/i18n.py
> +++ b/i18n.py
> @@ -52,6 +52,7 @@ messages = {
>                        "to file access control lists for '%(user)s' user if possible, or add the "
>                        "'%(user)s' to the ISO path group, or (not recommended) 'chmod -R o+x 'path_to_iso'."
>                        "Details: %(err)s" ),
> +    "KCHISO0009E": _("Unable to access remote ISO. Details: %(err)s"),
>
>       "KCHIMG0001E": _("An error occurred when probing image OS information."),
>       "KCHIMG0003E": _("Unable to read image file %(filename)s"),
> diff --git a/vmtemplate.py b/vmtemplate.py
> index ef92914..6faf4c5 100644
> --- a/vmtemplate.py
> +++ b/vmtemplate.py
> @@ -24,6 +24,7 @@ import urlparse
>   import uuid
>   from lxml import etree
>   from lxml.builder import E
> +from urllib2 import URLError
>
>   from wok.exception import InvalidParameter, ImageFormatError, IsoFormatError
>   from wok.exception import MissingParameter, OperationFailed
> @@ -172,6 +173,8 @@ class VMTemplate(object):
>               return iso_img.probe()
>           except IsoFormatError:
>               raise InvalidParameter("KCHISO0001E", {'filename': iso})
> +        except URLError as e:
> +            raise OperationFailed("KCHISO0009E", {'err': e})
>
>       def _get_cdrom_xml(self, libvirt_stream_protocols):
>           if 'cdrom' not in self.info:
> --
> 2.5.5
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>

-- 

Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn at br.ibm.com




More information about the Kimchi-devel mailing list