[Kimchi-devel] [PATCH 1/2] Filter directory in storage volume listing

lvroyce0210 at gmail.com lvroyce0210 at gmail.com
Wed Jul 30 14:56:11 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

When listing storage volumes, directory will be listed

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/control/base.py           | 2 +-
 src/kimchi/control/storagevolumes.py | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index ac24b3f..1854428 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -279,7 +279,7 @@ class Collection(object):
             if not res.is_authorized():
                 continue
 
-            if all(key in res.data and res.data[key] == val
+            if all(key in res.data and (res.data[key] == val or res.data[key] in val)
                    for key, val in fields_filter.iteritems()):
                 data.append(res.data)
         return data
diff --git a/src/kimchi/control/storagevolumes.py b/src/kimchi/control/storagevolumes.py
index c4d6c41..c6f6ce0 100644
--- a/src/kimchi/control/storagevolumes.py
+++ b/src/kimchi/control/storagevolumes.py
@@ -30,6 +30,11 @@ class StorageVolumes(Collection):
         self.resource_args = [self.pool, ]
         self.model_args = [self.pool, ]
 
+    def filter_data(self, resources, fields_filter):
+        # filter directory from storage volumes
+        fields_filter.update({'type': ['file', 'block', 'network']})
+        return super(StorageVolumes, self).filter_data(resources, fields_filter)
+
 
 class StorageVolume(Resource):
     def __init__(self, model, pool, ident):
-- 
1.8.3.2




More information about the Kimchi-devel mailing list