diff options
| author | Jake Yip <jake.yip@unimelb.edu.au> | 2015-09-08 20:04:11 +1000 |
|---|---|---|
| committer | Jake Yip <jake.yip@unimelb.edu.au> | 2015-09-09 22:44:08 +1000 |
| commit | c8c8964ddd5a49de6eb4794fba68ab4ec0400b08 (patch) | |
| tree | f7cf6b01d4d257962ca5d7a06c88e0a211919100 /glanceclient/v2/shell.py | |
| parent | aa4cd9dc4bba0334a0ee7db6e86ef313721c32f4 (diff) | |
| download | python-glanceclient-c8c8964ddd5a49de6eb4794fba68ab4ec0400b08.tar.gz | |
Updates default --sort behaviour
When querying against a Juno glance-registry, we found that having the
--sort option defaulting to 'name:asc" results in querying the registry
with additional SQL parameters like the following:
WHERE image_properties_2.name = :name_1 AND image_properties_2.value =
:value_1
as a result of handling the newer 'sort' filter. This results in a
blank list being returned as the output of glance image-list.
This patch sets the --sort-key and --sort-dir instead of --sort when
neither --sort-key nor --sort-dir are specified, so as to maintain
backwards compatibility with Juno glance-registry.
Change-Id: I8bd64cca7f1b7abdbabf4c09e3dbbcb4044e51b4
Closes-bug: #1492887
Diffstat (limited to 'glanceclient/v2/shell.py')
| -rw-r--r-- | glanceclient/v2/shell.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 8585d60..3ae5d41 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -142,8 +142,8 @@ def do_image_update(gc, args): help='Sort image list in specified directions.') @utils.arg('--sort', metavar='<key>[:<direction>]', default=None, help=(("Comma-separated list of sort keys and directions in the " - "form of <key>[:<asc|desc>]. Valid keys: %s. OPTIONAL: " - "Default='name:asc'.") % ', '.join(images.SORT_KEY_VALUES))) + "form of <key>[:<asc|desc>]. Valid keys: %s. OPTIONAL." + ) % ', '.join(images.SORT_KEY_VALUES))) def do_image_list(gc, args): """List images you can access.""" filter_keys = ['visibility', 'member_status', 'owner', 'checksum', 'tag'] @@ -169,7 +169,8 @@ def do_image_list(gc, args): if args.sort is not None: kwargs['sort'] = args.sort elif not args.sort_dir and not args.sort_key: - kwargs['sort'] = 'name:asc' + kwargs['sort_key'] = 'name' + kwargs['sort_dir'] = 'asc' columns = ['ID', 'Name'] |
