diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-11-30 21:22:23 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-11-30 21:22:23 +0000 |
commit | b66e6faac0cb47333fd9ec2687458aaa3c0e154d (patch) | |
tree | aa7ac1e5c660e45cd15ff798c0a5ebc3b024cee0 /glanceclient/v1/images.py | |
parent | 09c821617770a792b92859acb6f0076bf80307e5 (diff) | |
parent | 4da8b287b40cf0f0de0fd77998e3e66d8bac7999 (diff) | |
download | python-glanceclient-b66e6faac0cb47333fd9ec2687458aaa3c0e154d.tar.gz |
Merge "Add --sort-key and --sort-dir to image-list"
Diffstat (limited to 'glanceclient/v1/images.py')
-rw-r--r-- | glanceclient/v1/images.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index 3ddfbca..16ee5f0 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -34,6 +34,10 @@ CREATE_PARAMS = UPDATE_PARAMS + ('id', 'store') DEFAULT_PAGE_SIZE = 20 +SORT_DIR_VALUES = ('asc', 'desc') +SORT_KEY_VALUES = ('name', 'status', 'container_format', 'disk_format', + 'size', 'id', 'created_at', 'updated_at') + class Image(base.Resource): def __repr__(self): @@ -146,6 +150,22 @@ class ImageManager(base.Manager): if 'marker' in kwargs: params['marker'] = kwargs['marker'] + sort_key = kwargs.get('sort_key') + if sort_key is not None: + if sort_key in SORT_KEY_VALUES: + params['sort_key'] = sort_key + else: + raise ValueError('sort_key must be one of the following: %s.' + % ', '.join(SORT_KEY_VALUES)) + + sort_dir = kwargs.get('sort_dir') + if sort_dir is not None: + if sort_dir in SORT_DIR_VALUES: + params['sort_dir'] = sort_dir + else: + raise ValueError('sort_dir must be one of the following: %s.' + % ', '.join(SORT_DIR_VALUES)) + filters = kwargs.get('filters', {}) properties = filters.pop('properties', {}) for key, value in properties.items(): |