Merge "Add marker option for get_instance_list()"
This commit is contained in:
@@ -86,12 +86,14 @@ class NovaHelper(object):
|
||||
LOG.exception(exc)
|
||||
raise exception.ComputeNodeNotFound(name=node_hostname)
|
||||
|
||||
def get_instance_list(self, filters=None, limit=-1):
|
||||
def get_instance_list(self, filters=None, marker=None, limit=-1):
|
||||
"""List servers for all tenants with details.
|
||||
|
||||
This always gets servers with the all_tenants=True filter.
|
||||
|
||||
:param filters: dict of additional filters (optional).
|
||||
:param filters: Dict of additional filters (optional).
|
||||
:param marker: Get 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).
|
||||
If limit == -1, all servers will be returned,
|
||||
note that limit == -1 will have a performance
|
||||
@@ -102,8 +104,8 @@ class NovaHelper(object):
|
||||
search_opts = {'all_tenants': True}
|
||||
if filters:
|
||||
search_opts.update(filters)
|
||||
# TODO(chenker) Add marker param to list Server objects.
|
||||
return self.nova.servers.list(search_opts=search_opts,
|
||||
marker=marker,
|
||||
limit=limit)
|
||||
|
||||
def get_instance_by_uuid(self, instance_uuid):
|
||||
|
||||
@@ -168,14 +168,14 @@ class TestNovaHelper(base.TestCase):
|
||||
with mock.patch.object(nova_util, 'nova') as nova_mock:
|
||||
result = nova_util.get_instance_list()
|
||||
nova_mock.servers.list.assert_called_once_with(
|
||||
search_opts={'all_tenants': True}, limit=-1)
|
||||
search_opts={'all_tenants': True}, marker=None, limit=-1)
|
||||
self.assertIs(result, nova_mock.servers.list.return_value)
|
||||
# Call it again with filters.
|
||||
with mock.patch.object(nova_util, 'nova') as nova_mock:
|
||||
result = nova_util.get_instance_list(filters={'host': 'fake-host'})
|
||||
nova_mock.servers.list.assert_called_once_with(
|
||||
search_opts={'all_tenants': True, 'host': 'fake-host'},
|
||||
limit=-1)
|
||||
marker=None, limit=-1)
|
||||
self.assertIs(result, nova_mock.servers.list.return_value)
|
||||
|
||||
@mock.patch.object(time, 'sleep', mock.Mock())
|
||||
|
||||
Reference in New Issue
Block a user