[PATCH 0/2] Filter directory from storage volume list

From: Royce Lv <lvroyce@linux.vnet.ibm.com> Royce Lv (2): Filter directory in storage volume listing fix test case for volume filtering src/kimchi/control/base.py | 2 +- src/kimchi/control/storagevolumes.py | 5 +++++ tests/test_rest.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) -- 1.8.3.2

From: Royce Lv <lvroyce@linux.vnet.ibm.com> When listing storage volumes, directory will be listed Signed-off-by: Royce Lv <lvroyce@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

From: Royce Lv <lvroyce@linux.vnet.ibm.com> Test mock model passed an unsupported type when volume create, fix it. Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- tests/test_rest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_rest.py b/tests/test_rest.py index 4feb298..544f06b 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -982,7 +982,7 @@ class RestTests(unittest.TestCase): req = json.dumps({'name': name, 'capacity': 1024, 'allocation': 512, - 'type': 'disk', + 'type': 'file', 'format': 'raw'}) resp = self.request('/storagepools/pool-1/storagevolumes', req, 'POST') -- 1.8.3.2

Tested-By: Christy Perez <christy@linux.vnet.ibm.com> On 07/30/2014 09:56 AM, lvroyce0210@gmail.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
Royce Lv (2): Filter directory in storage volume listing fix test case for volume filtering
src/kimchi/control/base.py | 2 +- src/kimchi/control/storagevolumes.py | 5 +++++ tests/test_rest.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
participants (3)
-
Aline Manera
-
Christy Perez
-
lvroyce0210@gmail.com