Suport instance list pagination in novaclient, Part I
Bug 1209242 nova-api has supported pagination for long. A marker and limit option could be passed to nova-api to get a slice of instances. It makes sense to enable this feature in novaclient, so that horizon could use it for pagination supporting. Modification to shell.py would be submitted in a separate patch. Further change will also pass 'sort_key' and 'sort_dir' to nova-api, as long as nova supports this. This is part of blueprint support-pagination-for-instance-list Change-Id: Ieb5f2c1eb31b9f7e95b62b51ea7dc338e3970d04
This commit is contained in:
parent
72c0a13b0a
commit
756a4333e6
novaclient
@ -26,6 +26,12 @@ class ServersTest(utils.TestCase):
|
||||
cs.assert_called('GET', '/servers')
|
||||
[self.assertTrue(isinstance(s, servers.Server)) for s in sl]
|
||||
|
||||
def test_list_servers_with_marker_limit(self):
|
||||
sl = cs.servers.list(marker=1234, limit=2)
|
||||
cs.assert_called('GET', '/servers/detail?marker=1234&limit=2')
|
||||
for s in sl:
|
||||
self.assertTrue(isinstance(s, servers.Server))
|
||||
|
||||
def test_get_server_details(self):
|
||||
s = cs.servers.get(1234)
|
||||
cs.assert_called('GET', '/servers/1234')
|
||||
|
@ -363,12 +363,15 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
"""
|
||||
return self._get("/servers/%s" % base.getid(server), "server")
|
||||
|
||||
def list(self, detailed=True, search_opts=None):
|
||||
def list(self, detailed=True, search_opts=None, marker=None, limit=None):
|
||||
"""
|
||||
Get a list of servers.
|
||||
|
||||
:param detailed: Whether to return detailed server info (optional).
|
||||
:param search_opts: Search options to filter out servers (optional).
|
||||
:param marker: Begin returning servers that appear later in the server
|
||||
list than that represented by this server id (optional).
|
||||
:param limit: Maximum number of servers to return (optional).
|
||||
|
||||
:rtype: list of :class:`Server`
|
||||
"""
|
||||
@ -381,6 +384,12 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
if val:
|
||||
qparams[opt] = val
|
||||
|
||||
if marker:
|
||||
qparams['marker'] = marker
|
||||
|
||||
if limit:
|
||||
qparams['limit'] = limit
|
||||
|
||||
query_string = "?%s" % urlutils.urlencode(qparams) if qparams else ""
|
||||
|
||||
detail = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user