Openstack image list should sort on name

Bug #1639231 reported by Vijendra Soni
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Undecided
Vijendra Soni

Bug Description

Currently openstack image list display output sorted on the sort_key as 'created_at" argument(taken by default) and sort_dir as desc. For example:
openstack image list
+--------------------------------------+---------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------------------+--------+
| 44a15e58-b9b4-4e94-8b19-33837b0f1657 | cirros-0.3.4-x86_64-uec | active |
| 2c74ff4c-7baa-42f9-afe0-6b620bf79a90 | cirros-0.3.4-x86_64-uec-ramdisk | active |
| 7850eb88-ec7e-40f4-b72d-0a812e2960b1 | cirros-0.3.4-x86_64-uec-kernel | active |
+--------------------------------------+---------------------------------+--------+

However glance image-list do it differently. sort_key as 'name' and sort_dir as 'asc'. For example:

glance image-list
+--------------------------------------+---------------------------------+
| ID | Name |
+--------------------------------------+---------------------------------+
| 44a15e58-b9b4-4e94-8b19-33837b0f1657 | cirros-0.3.4-x86_64-uec |
| 7850eb88-ec7e-40f4-b72d-0a812e2960b1 | cirros-0.3.4-x86_64-uec-kernel |
| 2c74ff4c-7baa-42f9-afe0-6b620bf79a90 | cirros-0.3.4-x86_64-uec-ramdisk |
+--------------------------------------+---------------------------------+

It make more sense to sort the output based on 'name' as it is more human friendly output. So need to change the default sort_key to 'name' and sort_dir to 'asc'

Changed in python-openstackclient:
assignee: nobody → Vijendra Soni (vijendra-soni)
Changed in python-openstackclient:
status: New → Confirmed
Revision history for this message
Vijendra Soni (vijendra-soni) wrote :

Dear Reviewers,

I would like to share earlier bug filed in the glance to address the similar issue, this time I am trying to fix the same for openstack client.

URL : https://bugs.launchpad.net/python-glanceclient/+bug/1081542.

Thanks
Vijendra Soni

Revision history for this message
Brian Rosmaita (brian-rosmaita) wrote :

We cannot change the default sort values or direction.

There are filtering options available for the image-list call that can be used to customize the output; those should be used instead.

Changed in python-openstackclient:
status: Confirmed → Invalid
Revision history for this message
Brian Rosmaita (brian-rosmaita) wrote :

I just realized this is an OSC bug, not a Glance bug. The OSC people may have a different opinion on what they want to do about this. But the above is my two cents.

Revision history for this message
Steve Martinelli (stevemar) wrote :

We can sort this on the client side, anything we should know about when it comes to sorting massive lists? does glance use markers and such?

Changed in python-openstackclient:
status: Invalid → New
assignee: Vijendra Soni (vijendra-soni) → nobody
Revision history for this message
Vijendra Soni (vijendra-soni) wrote :

yes glance use marker along with limit,sort_key,sort_dir and filters.

however marker set to none for openstack image list without any further command argument and sort_key set to 'created_at' and sort_dir' set to 'desc'.

When issuing openstackstack image list --sort 'name:asc' , marker set to none, sort_key as 'name' and sort_dir as 'asc'.

please suggest how to go for default sort by name in asc order fix.

Thanks,
Vijendra Soni

Changed in python-openstackclient:
assignee: nobody → Vijendra Soni (vijendra-soni)
Revision history for this message
Vijendra Soni (vijendra-soni) wrote :

Steve, one simple approach it to set the default for sort parameter if it is none(no command line argument passed). I replicated it in my local and giving as expected results.

openstack image list
+--------------------------------------+---------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------------------+--------+
| 62a526cb-7fd1-405e-908a-d2422a4cd085 | None | active |
| 44a15e58-b9b4-4e94-8b19-33837b0f1657 | cirros-0.3.4-x86_64-uec | active |
| 7850eb88-ec7e-40f4-b72d-0a812e2960b1 | cirros-0.3.4-x86_64-uec-kernel | active |
| 2c74ff4c-7baa-42f9-afe0-6b620bf79a90 | cirros-0.3.4-x86_64-uec-ramdisk | active |
+--------------------------------------+---------------------------------+--------+

openstack image list --sort 'created_at:desc'
+--------------------------------------+---------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------------------+--------+
| 62a526cb-7fd1-405e-908a-d2422a4cd085 | None | active |
| 44a15e58-b9b4-4e94-8b19-33837b0f1657 | cirros-0.3.4-x86_64-uec | active |
| 2c74ff4c-7baa-42f9-afe0-6b620bf79a90 | cirros-0.3.4-x86_64-uec-ramdisk | active |
| 7850eb88-ec7e-40f4-b72d-0a812e2960b1 | cirros-0.3.4-x86_64-uec-kernel | active |
+--------------------------------------+---------------------------------+--------+

Changed in python-openstackclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstackclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/396732

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/396732
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=a7a0d0c61a6a88e044b781bbc4903cdcfc919e55
Submitter: Jenkins
Branch: master

commit a7a0d0c61a6a88e044b781bbc4903cdcfc919e55
Author: Vijendra Soni <email address hidden>
Date: Fri Nov 11 20:01:05 2016 +0530

    Sort list images by name by default

    Set the default key and dir for openstack image list,
    if no command line argument passed
    Changing sort_key to name(old value: created_at)

    Change-Id: I6c61f6e5a04824d655ccf43477afcec9652101df
    Closes-Bug: #1639231

Changed in python-openstackclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient 3.5.0

This issue was fixed in the openstack/python-openstackclient 3.5.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.