Merge "Workaround to OneView pagination"

This commit is contained in:
Jenkins 2016-08-10 00:37:39 +00:00 committed by Gerrit Code Review
commit aab910a9f0
3 changed files with 15 additions and 7 deletions

View File

@ -41,7 +41,10 @@ class OneViewManager(object):
pass
def list(self, **kwargs):
resource_uri = self.uri_prefix
# NOTE(nicodemos) The OneView API documents that count=-1 should
# return everything but it is not, using an extremely large count
# instead.
resource_uri = self.uri_prefix + '?start=0&count=9999999'
resource_json = self.oneview_client._prepare_and_do_request(
uri=resource_uri
)
@ -114,7 +117,10 @@ class OneViewIndexManager(object):
pass
def list(self, **kwargs):
resource_uri = self.uri_index
# NOTE(nicodemos) The OneView API documents that count=-1 should
# return everything but it is not, using an extremely large count
# instead.
resource_uri = self.uri_index + '&start=0&count=9999999'
resource_json = self.oneview_client._prepare_and_do_request(
uri=resource_uri
)

View File

@ -424,7 +424,7 @@ class OneViewClientV2TestCase(unittest.TestCase):
server_hardware_list = oneview_client.server_hardware.list()
mock_get.assert_called_once_with(
url='https://1.2.3.4/rest/server-hardware/',
url='https://1.2.3.4/rest/server-hardware/?start=0&count=9999999',
headers=mock.ANY,
verify=True
)
@ -446,7 +446,7 @@ class OneViewClientV2TestCase(unittest.TestCase):
server_hardware_list = oneview_client.server_hardware_index.list()
mock_get.assert_called_once_with(
url='https://1.2.3.4/rest/index/resources?' +
'category=server-hardware',
'category=server-hardware&start=0&count=9999999',
headers=mock.ANY,
verify=True
)
@ -563,7 +563,8 @@ class OneViewClientV2TestCase(unittest.TestCase):
oneview_client.server_profile_template.list()
)
mock_get.assert_called_once_with(
url='https://1.2.3.4/rest/server-profile-templates/',
url='https://1.2.3.4/rest/server-profile-templates/'
'?start=0&count=9999999',
headers=mock.ANY,
verify=True
)
@ -642,7 +643,7 @@ class OneViewClientV2TestCase(unittest.TestCase):
server_profile_list = oneview_client.server_profile.list()
mock_get.assert_called_once_with(
url='https://1.2.3.4/rest/server-profiles/',
url='https://1.2.3.4/rest/server-profiles/?start=0&count=9999999',
headers=mock.ANY,
verify=True
)

View File

@ -43,7 +43,8 @@ class TestServerHardwareIndexManager(unittest.TestCase):
index_manager = managers.ServerHardwareIndexManager(oneview_client)
objects = index_manager.list()
oneview_client._prepare_and_do_request.assert_called_once_with(
uri=managers.ServerHardwareIndexManager.uri_index
uri=managers.ServerHardwareIndexManager.uri_index + '&start=0'
'&count=9999999'
)
for obj in objects:
self.assertIsInstance(obj, models.ServerHardware)