[Kimchi-devel] [PATCH V3 2/4] add a new method to get iso info for VMTemplate class

Shu Ming shuming at linux.vnet.ibm.com
Fri Feb 21 09:32:23 UTC 2014


Reviewed-by: Shu Ming <shuming at linux.vnet.ibm.com>
2014/2/21 14:59, shaohef at linux.vnet.ibm.com:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> move the related code about get iso info to a new function.
> Then template integrity can make use of it.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
>   src/kimchi/vmtemplate.py | 22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 5767a13..a11ddd0 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -56,20 +56,10 @@ class VMTemplate(object):
>           iso = args.get('cdrom', '')
>
>           if scan and len(iso) > 0:
> -
> -            iso_prefixes = ['/', 'http', 'https', 'ftp', 'ftps', 'tftp']
> -            if len(filter(iso.startswith, iso_prefixes)) == 0:
> -                raise InvalidParameter("KCHTMPL0006E", {'param': iso})
> -
> +            iso_distro, iso_version = self.get_iso_info(iso)
>               if not iso.startswith('/'):
>                   self.info.update({'iso_stream': True})
>
> -            try:
> -                iso_img = IsoImage(iso)
> -                iso_distro, iso_version = iso_img.probe()
> -            except IsoFormatError:
> -                raise InvalidParameter("KCHISO0001E", {'filename': iso})
> -
>           # Fetch defaults based on the os distro and version
>           os_distro = args.get('os_distro', iso_distro)
>           os_version = args.get('os_version', iso_version)
> @@ -84,6 +74,16 @@ class VMTemplate(object):
>               args['graphics'] = graphics
>           self.info.update(args)
>
> +    def get_iso_info(self, iso):
> +        iso_prefixes = ['/', 'http', 'https', 'ftp', 'ftps', 'tftp']
> +        if len(filter(iso.startswith, iso_prefixes)) == 0:
> +            raise InvalidParameter("KCHTMPL0006E", {'param': iso})
> +        try:
> +            iso_img = IsoImage(iso)
> +            return iso_img.probe()
> +        except IsoFormatError:
> +            raise InvalidParameter("KCHISO0001E", {'filename': iso})
> +
>       def _get_cdrom_xml(self, libvirt_stream, qemu_stream_dns):
>           bus = self.info['cdrom_bus']
>           dev = "%s%s" % (self._bus_to_dev[bus],




More information about the Kimchi-devel mailing list