<div dir="ltr">Reviewed-by: Crístian Deives <<a href="mailto:cristiandeives@gmail.com">cristiandeives@gmail.com</a>><br></div><br><div class="gmail_quote">On Thu, May 7, 2015 at 12:17 PM Aline Manera <<a href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Instead of predefine a default pools list, build it according to user<br>
input to make it will be always accurated.<br>
Specially in case to import the StoragePoolsModel multiple times.<br>
<br>
Signed-off-by: Aline Manera <<a href="mailto:alinefm@linux.vnet.ibm.com" target="_blank">alinefm@linux.vnet.ibm.com</a>><br>
---<br>
src/kimchi/model/storagepools.py | 19 +++++++++----------<br>
1 file changed, 9 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py<br>
index e82d6ed..f022deb 100644<br>
--- a/src/kimchi/model/storagepools.py<br>
+++ b/src/kimchi/model/storagepools.py<br>
@@ -35,9 +35,6 @@ from kimchi.utils import add_task, kimchi_log, pool_name_from_uri, run_command<br>
from kimchi.xmlutils.utils import xpath_get_text<br>
<br>
<br>
-DEFAULT_POOLS = {'default': {'path': '/var/lib/libvirt/images'},<br>
- 'ISO': {'path': '/var/lib/kimchi/isos'}}<br>
-<br>
ISO_POOL_NAME = u'kimchi_isos'<br>
<br>
POOL_STATE_MAP = {0: 'inactive',<br>
@@ -71,25 +68,27 @@ class StoragePoolsModel(object):<br>
self._check_default_pools()<br>
<br>
def _check_default_pools(self):<br>
+ pools = {}<br>
+<br>
default_pool = tmpl_defaults['storagepool']<br>
default_pool = default_pool.split('/')[2]<br>
<br>
- if default_pool != 'default':<br>
- del DEFAULT_POOLS['default']<br>
- DEFAULT_POOLS[default_pool] = {}<br>
+ pools[default_pool] = {}<br>
+ if default_pool == 'default':<br>
+ pools[default_pool] = {'path': '/var/lib/libvirt/images'}<br>
<br>
- if config.get("server", "create_iso_pool") != "true":<br>
- del DEFAULT_POOLS['ISO']<br>
+ if config.get("server", "create_iso_pool") == "true":<br>
+ pools['ISO'] = {'path': '/var/lib/kimchi/isos'}<br>
<br>
error_msg = ("Please, check the configuration in %s/template.conf to "<br>
"ensure it has a valid storage pool." % paths.conf_dir)<br>
<br>
conn = self.conn.get()<br>
- for pool_name in DEFAULT_POOLS:<br>
+ for pool_name in pools:<br>
try:<br>
pool = conn.storagePoolLookupByName(pool_name)<br>
except libvirt.libvirtError, e:<br>
- pool_path = DEFAULT_POOLS[pool_name].get('path')<br>
+ pool_path = pools[pool_name].get('path')<br>
if pool_path is None:<br>
msg = "Fatal: Unable to find storage pool %s. " + error_msg<br>
kimchi_log.error(msg % pool_name)<br>
--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org" target="_blank">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</blockquote></div>