Cinder Pagination
Contents
Overview
Pagination allows for retrieving a limited number of results instead of the entire data set. The cinder /volumes and /volumes/detail APIs support pagination and support a single sort key and sort direction.
Proposal
Multiple sort keys and directions
The /servers and /servers/detail APIs will support the following parameters being repeated on the request:
Parameter | Description |
---|---|
sort_key | Key used to determine sort order |
sort_dir | Direction for with the associated sort key (asc or desc) |
The caller can specify these parameters multiple times in order to generate a list of sort keys and sort directions. The first key listed is the primary key, the next key is the secondary key, etc.
Note: The created_at and id sort keys are always appended at the end of the key list (descending sort order) if they are not already specified on the request.
Implementation Details
Multiple sort keys and directions
The database layer already supports multiple sort keys and sort directions (see paginate_query function in sqlalchemyutils.py). The layers above this need to be modified to accept a list of sort keys and sort direction. Also, a function needs to be added to create the list of sort keys and directions from the request parameters.
Retailed Blueprints
Nova
The same enhancements are being proposed in nova: Nova Pagination