[PATCH] [Kimchi] Fix template creation from image file

- When using an existing image as base for creating templates we cannot rely on its pool because it's undefined. This commit sets the default pool for this case. Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- vmtemplate.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vmtemplate.py b/vmtemplate.py index 653ad02..b71cf23 100644 --- a/vmtemplate.py +++ b/vmtemplate.py @@ -96,7 +96,12 @@ class VMTemplate(object): for index, disk in enumerate(disks): disk_info = dict(default_disk) - pool_type = self._get_storage_type(disk['pool']['name']) + if 'pool' in disk and 'name' in disk['pool']: + pool_type = self._get_storage_type(disk['pool']['name']) + else: + pool_type = self._get_storage_type( + default_disk['pool']['name']) + if pool_type in ['iscsi', 'scsi']: disk_info = {'index': 0, 'format': 'raw', 'volume': None} -- 1.9.1

Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On Apr 06 04:06PM, Jose Ricardo Ziviani wrote:
- When using an existing image as base for creating templates we cannot rely on its pool because it's undefined. This commit sets the default pool for this case.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- vmtemplate.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py index 653ad02..b71cf23 100644 --- a/vmtemplate.py +++ b/vmtemplate.py @@ -96,7 +96,12 @@ class VMTemplate(object): for index, disk in enumerate(disks): disk_info = dict(default_disk)
- pool_type = self._get_storage_type(disk['pool']['name']) + if 'pool' in disk and 'name' in disk['pool']: + pool_type = self._get_storage_type(disk['pool']['name']) + else: + pool_type = self._get_storage_type( + default_disk['pool']['name']) + if pool_type in ['iscsi', 'scsi']: disk_info = {'index': 0, 'format': 'raw', 'volume': None}
-- 1.9.1
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Paulo Ricardo Paz Vital Linux Technology Center, IBM Systems http://www.ibm.com/linux/ltc/

On 04/06/2016 04:06 PM, Jose Ricardo Ziviani wrote:
- When using an existing image as base for creating templates we cannot rely on its pool because it's undefined. This commit sets the default pool for this case.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- vmtemplate.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py index 653ad02..b71cf23 100644 --- a/vmtemplate.py +++ b/vmtemplate.py @@ -96,7 +96,12 @@ class VMTemplate(object): for index, disk in enumerate(disks): disk_info = dict(default_disk)
- pool_type = self._get_storage_type(disk['pool']['name']) + if 'pool' in disk and 'name' in disk['pool']: + pool_type = self._get_storage_type(disk['pool']['name']) + else: + pool_type = self._get_storage_type( + default_disk['pool']['name']) +
Maybe it is simpler to do: pool = disk.get('pool', disk_info['pool'] pool_type = self._get_storage_type(pool['name'])
if pool_type in ['iscsi', 'scsi']: disk_info = {'index': 0, 'format': 'raw', 'volume': None}
participants (3)
-
Aline Manera
-
Jose Ricardo Ziviani
-
Paulo Ricardo Paz Vital