[Kimchi-devel] [PATCH] Bug fix: Build default pools list according to user input
Crístian Viana
cristiandeives at gmail.com
Thu May 7 16:40:32 UTC 2015
Reviewed-by: Crístian Deives <cristiandeives at gmail.com>
On Thu, May 7, 2015 at 12:17 PM Aline Manera <alinefm at linux.vnet.ibm.com>
wrote:
> Instead of predefine a default pools list, build it according to user
> input to make it will be always accurated.
> Specially in case to import the StoragePoolsModel multiple times.
>
> Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
> ---
> src/kimchi/model/storagepools.py | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/src/kimchi/model/storagepools.py
> b/src/kimchi/model/storagepools.py
> index e82d6ed..f022deb 100644
> --- a/src/kimchi/model/storagepools.py
> +++ b/src/kimchi/model/storagepools.py
> @@ -35,9 +35,6 @@ from kimchi.utils import add_task, kimchi_log,
> pool_name_from_uri, run_command
> from kimchi.xmlutils.utils import xpath_get_text
>
>
> -DEFAULT_POOLS = {'default': {'path': '/var/lib/libvirt/images'},
> - 'ISO': {'path': '/var/lib/kimchi/isos'}}
> -
> ISO_POOL_NAME = u'kimchi_isos'
>
> POOL_STATE_MAP = {0: 'inactive',
> @@ -71,25 +68,27 @@ class StoragePoolsModel(object):
> self._check_default_pools()
>
> def _check_default_pools(self):
> + pools = {}
> +
> default_pool = tmpl_defaults['storagepool']
> default_pool = default_pool.split('/')[2]
>
> - if default_pool != 'default':
> - del DEFAULT_POOLS['default']
> - DEFAULT_POOLS[default_pool] = {}
> + pools[default_pool] = {}
> + if default_pool == 'default':
> + pools[default_pool] = {'path': '/var/lib/libvirt/images'}
>
> - if config.get("server", "create_iso_pool") != "true":
> - del DEFAULT_POOLS['ISO']
> + if config.get("server", "create_iso_pool") == "true":
> + pools['ISO'] = {'path': '/var/lib/kimchi/isos'}
>
> error_msg = ("Please, check the configuration in %s/template.conf
> to "
> "ensure it has a valid storage pool." %
> paths.conf_dir)
>
> conn = self.conn.get()
> - for pool_name in DEFAULT_POOLS:
> + for pool_name in pools:
> try:
> pool = conn.storagePoolLookupByName(pool_name)
> except libvirt.libvirtError, e:
> - pool_path = DEFAULT_POOLS[pool_name].get('path')
> + pool_path = pools[pool_name].get('path')
> if pool_path is None:
> msg = "Fatal: Unable to find storage pool %s. " +
> error_msg
> kimchi_log.error(msg % pool_name)
> --
> 2.1.0
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20150507/1c3f1308/attachment.html>
More information about the Kimchi-devel
mailing list