Ask Your Question

Example of sorting flavors in Horizon?

asked 2014-02-13 20:24:51 -0500

jproulx gravatar image

I can see Horizon now has configurable sorting via CREATE_INSTANCE_FLAVOR_SORT can anyone give me an exaple, just a simple sort by name perhaps?

The link to isn't really sufficient for me.

#     'key': my_awesome_callback_method,
#     'reverse': False,
# }

Is 'key' literal or is it meant to be replaced by the key we're sorting on? Does my_awsome_callback_method get that key as in put or some data structure of instance_types? If the latter what is that structure?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-02-14 12:36:29 -0500

jproulx gravatar image

updated 2014-02-15 16:46:35 -0500

To sort by name:

     'key': lambda flavor: getattr(flavor,'name'),
     'reverse': False,

my_awsome_callback_method gets a flavor object partially described here there's potentially more fields returned depending on your installation. By using nova --debug flavor-show I was able to see the raw API response and a full listing of available attrs to get for my flavor types.

This example will order primarily by ram/cpu and secondarily by number of vcpus:

     'key': lambda flavor: getattr(flavor,'ram')/getattr(flavor,'vcpus')+getattr(flavor,'vcpus'),
     'reverse': False,
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2014-02-13 20:24:51 -0500

Seen: 476 times

Last updated: Feb 15 '14