[PATCH] bug fix: Only check for ISO images in active pools

From: Aline Manera <alinefm@br.ibm.com> The wrong exception was expected while searching for ISO files in the storage pools. Independent of the exception raised it should not block users to create a template, so use the generic Exception to catch any error. Fix it to avoit the error below. Request Headers: COOKIE: kimchi=a50f5cb488c331754db1a642eaba89f7fe71c0b8; userid=alinefm HOST: localhost:8000 CONNECTION: keep-alive Remote-Addr: 127.0.0.1 ACCEPT: application/json, text/javascript, */*; q=0.01 USER-AGENT: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0 X-REQUESTED-WITH: XMLHttpRequest ACCEPT-LANGUAGE: en-us,en;q=0.7,pt-br;q=0.3 Content-Type: application/json REFERER: http://localhost:8000/ ACCEPT-ENCODING: gzip, deflate [28/Feb/2014:12:27:50] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond response.body = self.handler() File "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in __call__ self.body = self.oldhandler(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 34, in __call__ return self.callable(*self.args, **self.kwargs) File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 274, in index return self.get(filter_params) File "/home/alinefm/kimchi/src/kimchi/control/storagevolumes.py", line 71, in get res_list = get_list(*self.model_args) File "/home/alinefm/kimchi/src/kimchi/model/storagevolumes.py", line 170, in get_list pool.refresh(0) File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py", line 62, in wrapper ret = f(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/libvirt.py", line 2220, in refresh if ret == -1: raise libvirtError ('virStoragePoolRefresh() failed', pool=self) libvirtError: Requested operation is not valid: storage pool is not active Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- src/kimchi/model/storagevolumes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py index 8defdb7..3e21268 100644 --- a/src/kimchi/model/storagevolumes.py +++ b/src/kimchi/model/storagevolumes.py @@ -169,7 +169,7 @@ class IsoVolumesModel(object): pool = StoragePoolModel.get_storagepool(pool_name, self.conn) pool.refresh(0) volumes = pool.listVolumes() - except InvalidOperation: + except Exception: # Skip inactive pools continue -- 1.7.10.4

-- Tested-by: Paulo Vital <pvital@linux.vnet.ibm.com> Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On Fri, 2014-02-28 at 13:03 -0300, Aline Manera wrote:
From: Aline Manera <alinefm@br.ibm.com>
The wrong exception was expected while searching for ISO files in the storage pools. Independent of the exception raised it should not block users to create a template, so use the generic Exception to catch any error.
Fix it to avoit the error below.
Request Headers: COOKIE: kimchi=a50f5cb488c331754db1a642eaba89f7fe71c0b8; userid=alinefm HOST: localhost:8000 CONNECTION: keep-alive Remote-Addr: 127.0.0.1 ACCEPT: application/json, text/javascript, */*; q=0.01 USER-AGENT: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0 X-REQUESTED-WITH: XMLHttpRequest ACCEPT-LANGUAGE: en-us,en;q=0.7,pt-br;q=0.3 Content-Type: application/json REFERER: http://localhost:8000/ ACCEPT-ENCODING: gzip, deflate [28/Feb/2014:12:27:50] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond response.body = self.handler() File "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in __call__ self.body = self.oldhandler(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 34, in __call__ return self.callable(*self.args, **self.kwargs) File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 274, in index return self.get(filter_params) File "/home/alinefm/kimchi/src/kimchi/control/storagevolumes.py", line 71, in get res_list = get_list(*self.model_args) File "/home/alinefm/kimchi/src/kimchi/model/storagevolumes.py", line 170, in get_list pool.refresh(0) File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py", line 62, in wrapper ret = f(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/libvirt.py", line 2220, in refresh if ret == -1: raise libvirtError ('virStoragePoolRefresh() failed', pool=self) libvirtError: Requested operation is not valid: storage pool is not active
Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- src/kimchi/model/storagevolumes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py index 8defdb7..3e21268 100644 --- a/src/kimchi/model/storagevolumes.py +++ b/src/kimchi/model/storagevolumes.py @@ -169,7 +169,7 @@ class IsoVolumesModel(object): pool = StoragePoolModel.get_storagepool(pool_name, self.conn) pool.refresh(0) volumes = pool.listVolumes() - except InvalidOperation: + except Exception: # Skip inactive pools continue

On 02/28/2014 04:06 PM, Crístian Viana wrote:
Am 28-02-2014 13:03, schrieb Aline Manera:
- except InvalidOperation: + except Exception: # Skip inactive pools continue
I'd suggest logging the error message, especially now that we are catching every type error. If something occurs, we will have no clue on what has happened. Done
participants (3)
-
Aline Manera
-
Crístian Viana
-
Paulo Ricardo Paz Vital