servers list API support specify multi-status
Currently the service list API allows the user to specify an optional status
value to use as a filter - for example to limit the list to only servers with
a status of Active.
However often the user wants to filter the list by a set of status values,
for example list servers with a status of Active or Error,
which requires two separate API calls.
Allowing the API to accept a list of status values would reduce this to a
single API call.
Allow to specify status value for many times in a request.
For example::
GET /v2/{tenant_id}/servers?status=ACTIVE&status=ERROR
GET /v3/servers?status=ACTIVE&status=ERROR
V2 API extension::
{
"alias": "os-server-list-multi-status",
"description": "Allow to filter the
servers by a set of status values.",
"links": [],
"name": "ServerListMultiStatus",
"namespace": "http://docs.openstack.org/compute/ext/
os-server-list-multi-status/api/v2",
"updated": "2014-05-11T00:00:00Z"
}
DocImpact: Adds os-server-list-multi-status extension.
blueprint servers-list-support-multi-status
Change-Id: Id0109c56070e2f920be0f95738749aa969258bc1
This commit is contained in:
@@ -534,9 +534,11 @@ class Controller(wsgi.Controller):
|
||||
|
||||
# Verify search by 'status' contains a valid status.
|
||||
# Convert it to filter by vm_state or task_state for compute_api.
|
||||
status = search_opts.pop('status', None)
|
||||
if status is not None:
|
||||
vm_state, task_state = common.task_and_vm_state_from_status(status)
|
||||
search_opts.pop('status', None)
|
||||
if 'status' in req.GET.keys():
|
||||
statuses = req.GET.getall('status')
|
||||
states = common.task_and_vm_state_from_status(statuses)
|
||||
vm_state, task_state = states
|
||||
if not vm_state and not task_state:
|
||||
return {'servers': []}
|
||||
search_opts['vm_state'] = vm_state
|
||||
|
||||
Reference in New Issue
Block a user