[Kimchi-devel] [PATCH] [Kimchi 3/3] Issue #920: Template is removed if an ISO doesn't exist anymore

Aline Manera alinefm at linux.vnet.ibm.com
Tue Apr 5 12:44:58 UTC 2016


I am not sure if I understood the idea of this patch.

 From the bug description, I saw a problem when editing a Template 
instead when creating a new one. But per this patch, you modified the 
Template creation process.

In the update process, we just need to validate the data and raise an 
error if any exists and do not delete anything.

So when removing an ISO from system and try to use this same path in an 
update process, the error should be raised to inform user about the 
invalid input and it is all. When canceling the operation, no request 
should be sent to server.

Did I misunderstand the problem or could you explain better what do you 
have in mind to solve the bug?

On 04/04/2016 10:02 PM, Jose Ricardo Ziviani wrote:
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
>   model/templates.py | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/model/templates.py b/model/templates.py
> index 2a722b9..1b2be0e 100644
> --- a/model/templates.py
> +++ b/model/templates.py
> @@ -51,7 +51,11 @@ class TemplatesModel(object):
>
>       def create(self, params):
>           name = params.get('name', '').strip()
> -        iso = params.get('cdrom')
> +        if params.get('force_no_cdrom', None) is None:
> +            iso = None
> +        else:
> +            iso = params.get('cdrom')
> +
>           # check search permission
>           if iso and iso.startswith('/') and os.path.exists(iso):
>               st_mode = os.stat(iso).st_mode
> @@ -74,7 +78,10 @@ class TemplatesModel(object):
>           # Creates the template class with necessary information
>           # Checkings will be done while creating this class, so any exception
>           # will be raised here
> -        t = LibvirtVMTemplate(params, scan=True, conn=self.conn)
> +        scan = False
> +        if params.get('force_no_cdrom', None) is None:
> +            scan = True
> +        t = LibvirtVMTemplate(params, scan=scan, conn=self.conn)
>
>           # Validate cpu info
>           t.cpuinfo_validate()
> @@ -206,6 +213,13 @@ class TemplateModel(object):
>                                                           'template': name})
>
>           self.delete(name)
> +
> +        # if the cdrom is invalid (if it was removed) the template will be
> +        # deleted but never replaced back, users won't understand why because
> +        # it's not clear. In this sceario, since a are replacing an existing
> +        # temaplte, let's create it anyway and gives the user a chance to
> +        # fix the cdrom name.
> +        new_t['force_no_cdrom'] = True
>           try:
>               ident = self.templates.create(new_t)
>           except:




More information about the Kimchi-devel mailing list