Fix hypervisors paginted collection_name.

Hypervisor view builder's _collection_name,
'hypervisors' is used to build next link that
sdk use as uri to do paginated query. But correct
API should be `GET /v2.1/os-hypervisors?<params>`
rather than `GET /v2.1/hypervisors?<params>`.

This patch fixes this bug.

Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199
Closes-Bug: 1864428
Signed-off-by: Fan Zhang <zh.f@outlook.com>
(cherry picked from commit b68033ecc9)
(cherry picked from commit 2f4e3ac3b0)
This commit is contained in:
Fan Zhang 2020-02-24 16:49:35 +08:00 committed by Stephen Finucane
parent 2bc043b51f
commit 9030b8a56d
10 changed files with 15 additions and 15 deletions

View File

@ -42,7 +42,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=2",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors/detail?limit=1&marker=2",
"rel": "next"
}
]

View File

@ -9,7 +9,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=2",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors?limit=1&marker=2",
"rel": "next"
}
]

View File

@ -42,7 +42,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors/detail?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
"rel": "next"
}
]

View File

@ -9,7 +9,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
"rel": "next"
}
]

View File

@ -17,7 +17,7 @@ from nova.api.openstack import common
class ViewBuilder(common.ViewBuilder):
_collection_name = "hypervisors"
_collection_name = "os-hypervisors"
def get_links(self, request, hypervisors, detail=False):
coll_name = (self._collection_name + '/detail' if detail else

View File

@ -42,7 +42,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=2",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors/detail?limit=1&marker=2",
"rel": "next"
}
]

View File

@ -9,7 +9,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=2",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors?limit=1&marker=2",
"rel": "next"
}
]

View File

@ -42,7 +42,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=%(hypervisor_id)s",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors/detail?limit=1&marker=%(hypervisor_id)s",
"rel": "next"
}
]

View File

@ -9,7 +9,7 @@
],
"hypervisors_links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=%(hypervisor_id)s",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/os-hypervisors?limit=1&marker=%(hypervisor_id)s",
"rel": "next"
}
]

View File

@ -834,7 +834,7 @@ class HypervisorsTestV233(HypervisorsTestV228):
'status': 'enabled'}
],
'hypervisors_links': [
{'href': 'http://localhost/v2/hypervisors?limit=1&marker=2',
{'href': 'http://localhost/v2/os-hypervisors?limit=1&marker=2',
'rel': 'next'}
]
}
@ -895,7 +895,7 @@ class HypervisorsTestV233(HypervisorsTestV228):
'status': 'enabled'}
],
'hypervisors_links': [
{'href': 'http://localhost/v2/hypervisors?limit=1&marker=2',
{'href': 'http://localhost/v2/os-hypervisors?limit=1&marker=2',
'rel': 'next'}
]
}
@ -908,7 +908,7 @@ class HypervisorsTestV233(HypervisorsTestV228):
req = self._get_request(
True, '/v2/1234/os-hypervisors/detail?limit=1&marker=1')
result = self.controller.detail(req)
link = 'http://localhost/v2/hypervisors/detail?limit=1&marker=2'
link = 'http://localhost/v2/os-hypervisors/detail?limit=1&marker=2'
expected = {
'hypervisors': [
{'cpu_info': {'arch': 'x86_64',
@ -1010,7 +1010,7 @@ class HypervisorsTestV233(HypervisorsTestV228):
self.assertEqual(expected, result['hypervisors'])
def test_detail_pagination_with_additional_filter(self):
link = 'http://localhost/v2/hypervisors/detail?limit=1&marker=2'
link = 'http://localhost/v2/os-hypervisors/detail?limit=1&marker=2'
expected = {
'hypervisors': [
{'cpu_info': {'arch': 'x86_64',
@ -1344,7 +1344,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
url='/os-hypervisors/detail?limit=1&marker=%s' %
TEST_HYPERS_OBJ[0].uuid)
result = self.controller.detail(req)
link = ('http://localhost/v2/hypervisors/detail?limit=1&marker=%s' %
link = ('http://localhost/v2/os-hypervisors/detail?limit=1&marker=%s' %
TEST_HYPERS_OBJ[1].uuid)
expected = {
'hypervisors': [
@ -1420,7 +1420,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
url='/os-hypervisors?limit=1&marker=%s' %
TEST_HYPERS_OBJ[0].uuid)
result = self.controller.index(req)
link = ('http://localhost/v2/hypervisors?limit=1&marker=%s' %
link = ('http://localhost/v2/os-hypervisors?limit=1&marker=%s' %
TEST_HYPERS_OBJ[1].uuid)
expected = {
'hypervisors': [{