[Kimchi-devel] [PATCH] [Kimchi 3/3] Issue #920: Template is removed if an ISO doesn't exist anymore
Jose Ricardo Ziviani
joserz at linux.vnet.ibm.com
Tue Apr 5 01:02:01 UTC 2016
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:
--
1.9.1
More information about the Kimchi-devel
mailing list