
Signed-off-by: Jose Ricardo Ziviani <joserz@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}) @@ -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] -- 1.9.1