From c8c8964ddd5a49de6eb4794fba68ab4ec0400b08 Mon Sep 17 00:00:00 2001 From: Jake Yip Date: Tue, 8 Sep 2015 20:04:11 +1000 Subject: [PATCH] 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 --- glanceclient/v2/shell.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 8585d60e..3ae5d41e 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='[:]', default=None, help=(("Comma-separated list of sort keys and directions in the " - "form of [:]. Valid keys: %s. OPTIONAL: " - "Default='name:asc'.") % ', '.join(images.SORT_KEY_VALUES))) + "form of [:]. 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']