Workaround to OneView pagination

Since the OneView API for get a list of resources using count=-1 doesn't
work properly, this patch set a high value to workaround that case.

Change-Id: I5867556578072442c8fdafa5bcdd4338d38840a1
This commit is contained in:
Hugo Nicodemos 2016-07-28 16:51:38 +03:00 committed by Gabriel Bezerra
parent dca44ab0dd
commit fe213ff553
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

@ -419,7 +419,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
)
@ -441,7 +441,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
)
@ -558,7 +558,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
)
@ -637,7 +638,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)