Ignore the exception on GET for Stop (deactivate) of
transient Storage Pools.
---
src/kimchi/control/storagepools.py | 11 +++++++++--
src/kimchi/model/storagepools.py | 8 ++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
index 872ad04..e55a85f 100644
--- a/src/kimchi/control/storagepools.py
+++ b/src/kimchi/control/storagepools.py
@@ -19,7 +19,6 @@
import cherrypy
-
from kimchi.control.base import Collection, Resource
from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes
from kimchi.control.utils import get_class_name, model_fn
@@ -75,11 +74,19 @@ def _get_resources(self, filter_params):
class StoragePool(Resource):
def __init__(self, model, ident):
super(StoragePool, self).__init__(model, ident)
+ _ignore_not_found = False
+ try:
+ # the test driver causes an exception in is_persistent()
+ _ignore_not_found = \
+ not model.storagepool_is_persistent(self.ident.decode('utf-8'))
+ except Exception:
+ pass
self.role_key = 'storage'
self.admin_methods = ['PUT', 'POST', 'DELETE']
self.uri_fmt = "/storagepools/%s"
self.activate = self.generate_action_handler('activate')
- self.deactivate = self.generate_action_handler('deactivate')
+ self.deactivate = self.generate_action_handler('deactivate', \
+ ignore_not_found = _ignore_not_found)
self.storagevolumes = StorageVolumes(self.model, ident)
@property
diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py
index e03c6bb..f7448d1 100644
--- a/src/kimchi/model/storagepools.py
+++ b/src/kimchi/model/storagepools.py
@@ -252,7 +252,7 @@ def lookup(self, name):
pool = self.get_storagepool(name, self.conn)
info = pool.info()
autostart = True if pool.autostart() else False
- persistent = True if pool.isPersistent() else False
+ persistent = self.is_persistent(name)
xml = pool.XMLDesc(0)
path = xpath_get_text(xml, "/pool/target/path")[0]
pool_type = xpath_get_text(xml, "/pool/@type")[0]
@@ -281,7 +281,7 @@ def lookup(self, name):
'nr_volumes': nr_volumes,
'persistent': persistent}
- if not pool.isPersistent():
+ if not persistent:
# Deal with deep scan generated pool
try:
with self.objstore as session:
@@ -293,6 +293,10 @@ def lookup(self, name):
pass
return res
+ def is_persistent(self, name):
+ pool = self.get_storagepool(name, self.conn)
+ return True if pool.isPersistent() else False
+
def _update_lvm_disks(self, pool_name, disks):
# check if all the disks/partitions exists in the host
for disk in disks:
--
1.9.3