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