[Kimchi-devel] [PATCH] [Kimchi 2/3] Issue #919: Deactivate a storagepool makes the list of templates blank
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Apr 5 12:37:15 UTC 2016
On 04/04/2016 10:02 PM, Jose Ricardo Ziviani wrote:
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
> model/templates.py | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/model/templates.py b/model/templates.py
> index 92705b6..2a722b9 100644
> --- a/model/templates.py
> +++ b/model/templates.py
> @@ -271,7 +271,7 @@ class LibvirtVMTemplate(VMTemplate):
> # validate CPU info values - will raise appropriate exceptions
> cpu_model.check_cpu_info(self.info['cpu_info'])
>
> - def _storage_validate(self, pool_uri):
> + def _storage_validate(self, pool_uri, throw_if_not_active=True):
> pool_name = pool_name_from_uri(pool_uri)
> try:
> conn = self.conn.get()
> @@ -280,7 +280,11 @@ class LibvirtVMTemplate(VMTemplate):
> raise InvalidParameter("KCHTMPL0004E", {'pool': pool_uri,
> 'template': self.name})
>
> - if not pool.isActive():
> + # TODO: refactor this code because an inactive pool is not an
> + # exception, it is a valid and expect flow. It should be the
> + # called responsibility to decide what to do when the pool
> + # is not active.
> + if not pool.isActive() and throw_if_not_active:
> raise InvalidParameter("KCHTMPL0005E", {'pool': pool_name,
> 'template': self.name})
In this case, the pool should be add to the 'invalid' parameter to let
user knows the Template is invalid.
We have time to do it for 2.2, so I'd appreciate if you could do the
right solution now =)
> @@ -315,7 +319,7 @@ class LibvirtVMTemplate(VMTemplate):
> return xpath_get_text(xml, "/pool/target/path")[0]
>
> def _get_storage_type(self, pool_uri=None):
> - pool = self._storage_validate(pool_uri)
> + pool = self._storage_validate(pool_uri, False)
> xml = pool.XMLDesc(0)
> return xpath_get_text(xml, "/pool/@type")[0]
>
More information about the Kimchi-devel
mailing list