[Kimchi-devel] [PATCHv2 4/5] Integrate image os probe in vm template create

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jul 17 00:19:40 UTC 2014


On 07/15/2014 06:11 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> When we supply base image, we need to probe its os to choose
> a proper system configuration for it.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/vmtemplate.py | 15 ++++++++++-----
>   1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 91617d9..d531406 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -24,7 +24,8 @@ import urlparse
>
>
>   from kimchi import osinfo
> -from kimchi.exception import InvalidParameter, IsoFormatError
> +from kimchi.exception import InvalidParameter, IsoFormatError, ImageFormatError
> +from kimchi.imageinfo import probe_image
>   from kimchi.isoinfo import IsoImage
>   from kimchi.utils import check_url_path, pool_name_from_uri
>   from lxml import etree
> @@ -51,7 +52,7 @@ class VMTemplate(object):
>           self.fc_host_support = args.get('fc_host_support')
>
>           # Identify the cdrom if present
> -        iso_distro = iso_version = 'unknown'
> +        distro = version = 'unknown'
>           iso = args.get('cdrom', '')
>
>           # if ISO not specified and base disk image specified,
> @@ -59,17 +60,21 @@ class VMTemplate(object):
>           if len(iso) == 0 and 'disks' in args:
>               for d in args['disks']:
>                   if 'base' in d:
> +                    try:
> +                        distro, version = probe_image(d['base'])
> +                    except ImageFormatError:
> +                        pass

>                       args['cdrom'] = ''

Same I commented in previous patch about setting the cdrom value

>                       break
>
>           if scan and len(iso) > 0:
> -            iso_distro, iso_version = self.get_iso_info(iso)
> +            distro, version = self.get_iso_info(iso)
>               if not iso.startswith('/'):
>                   self.info.update({'iso_stream': True})
>
>           # 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)
> +        os_distro = args.get('os_distro', distro)
> +        os_version = args.get('os_version', version)
>           entry = osinfo.lookup(os_distro, os_version)
>           self.info.update(entry)
>




More information about the Kimchi-devel mailing list