Template was not checking if image-based templates are still valid. Now,
if image is missing, an warning will be displayed at UI
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
vmtemplate.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py
index 79730cf..7ac0541 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -492,13 +492,19 @@ class VMTemplate(object):
if invalid_networks:
invalid['networks'] = invalid_networks
- # validate storagepools integrity
+ # validate storagepools and image-based templates integrity
for disk in self.info['disks']:
pool_uri = disk['pool']['name']
pool_name = pool_name_from_uri(pool_uri)
if pool_name not in self._get_active_storagepools_name():
invalid['storagepools'] = [pool_name]
+ if disk.get("base") is None:
+ continue
+
+ if os.path.exists(disk.get("base")) is False:
+ invalid['vm-image'] = disk["base"]
+
# validate iso integrity
# FIXME when we support multiples cdrom devices
iso = self.info.get('cdrom')
--
2.5.5