list_servers pagination support

If we want to list the servers of a deployment with more servers than
nova.conf max_limit, currently we only return max_limit. This patch
makes it behave as expected, getting you all the servers.

Change-Id: I58844125ba37d81f1611e4e8ec641c1b8573884d
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
This commit is contained in:
Antoni Segura Puimedon 2018-03-23 18:31:29 +01:00
parent 017630e314
commit 6040b34345
No known key found for this signature in database
GPG Key ID: 9B08FFD846853B9D
1 changed files with 13 additions and 1 deletions

View File

@ -2191,8 +2191,20 @@ class OpenStackCloud(
params['all_tenants'] = True
data = self._compute_client.get(
'/servers/detail', params=params, error_message=error_msg)
unprocessed_servers = {'servers': []}
while 'servers_links' in data:
unprocessed_servers['servers'].extend(data['servers'])
parse_result = urllib.parse.urlparse(
data['servers_links'][0]['href'])
pagination_params = dict(
urllib.parse.parse_qsl(parse_result.query))
params.update(pagination_params)
data = self._compute_client.get(
'/servers/detail', params=params, error_message=error_msg)
unprocessed_servers['servers'].extend(data['servers'])
servers = self._normalize_servers(
self._get_and_munchify('servers', data))
self._get_and_munchify('servers', unprocessed_servers))
return [
self._expand_server(server, detailed, bare)
for server in servers