During ISO search (Template creation window), kimchi search volumes in
storagepools and it encodes every file name found. If some file has
unsupported characters, an error is raised and none ISO is presented to
user.
This patch fixes this error.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/kimchi/model/storagevolumes.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py
index d58fd0b..ab8e2fa 100644
--- a/src/kimchi/model/storagevolumes.py
+++ b/src/kimchi/model/storagevolumes.py
@@ -114,6 +114,10 @@ class StorageVolumeModel(object):
raise InvalidOperation("KCHVOL0006E", {'name': pool})
try:
return pool.storageVolLookupByName(name.encode("utf-8"))
+ except UnicodeDecodeError as e:
+ msg = 'Unable to encode file name "%s" from pool
"%s":\n %s'
+ kimchi_log.warn(msg %(name, poolname, str(e)))
+ return None
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_STORAGE_VOL:
raise NotFoundError("KCHVOL0002E", {'name': name,
@@ -151,6 +155,8 @@ class StorageVolumeModel(object):
def lookup(self, pool, name):
vol = self._get_storagevolume(pool, name)
+ if not vol:
+ return None
path = vol.path()
info = vol.info()
xml = vol.XMLDesc(0)
@@ -240,6 +246,8 @@ class IsoVolumesModel(object):
for volume in volumes:
res = self.storagevolume.lookup(pool_name, volume)
+ if res is None:
+ continue
if res['format'] == 'iso':
res['name'] = '%s' % volume
iso_volumes.append(res)
--
1.9.0