From e50aecda86ecbd955aaab7e3b37f0d81836be579 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Mon, 24 Feb 2020 16:49:35 +0800 Subject: [PATCH] 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?` rather than `GET /v2.1/hypervisors?`. This patch fixes this bug. Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199 Closes-Bug: 1864428 Signed-off-by: Fan Zhang (cherry picked from commit b68033ecc9d38dcbe339c993338bdca691f73b33) (cherry picked from commit 2f4e3ac3b018128b11a80ec343b333c3a6e4703f) (cherry picked from commit 9030b8a56d46eeef3e2a0ee6e19c3b05a277c77c) --- .../v2.33/hypervisors-detail-resp.json | 2 +- .../os-hypervisors/v2.33/hypervisors-list-resp.json | 2 +- .../v2.53/hypervisors-detail-resp.json | 2 +- .../os-hypervisors/v2.53/hypervisors-list-resp.json | 2 +- nova/api/openstack/compute/views/hypervisors.py | 2 +- .../v2.33/hypervisors-detail-resp.json.tpl | 2 +- .../v2.33/hypervisors-list-resp.json.tpl | 2 +- .../v2.53/hypervisors-detail-resp.json.tpl | 2 +- .../v2.53/hypervisors-list-resp.json.tpl | 2 +- .../unit/api/openstack/compute/test_hypervisors.py | 12 ++++++------ 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json b/doc/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json index 267e9d509981..dd6ce2ace133 100644 --- a/doc/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json +++ b/doc/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json @@ -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" } ] diff --git a/doc/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json b/doc/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json index 9a5771df022d..bb531ace7a5b 100644 --- a/doc/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json +++ b/doc/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json @@ -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" } ] diff --git a/doc/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json b/doc/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json index a2172f69a220..ed62b8cd476d 100644 --- a/doc/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json +++ b/doc/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json @@ -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" } ] diff --git a/doc/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json b/doc/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json index ec10b4a106e0..fd86adce217f 100644 --- a/doc/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json +++ b/doc/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json @@ -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" } ] diff --git a/nova/api/openstack/compute/views/hypervisors.py b/nova/api/openstack/compute/views/hypervisors.py index 2284245993fc..370e383166b9 100644 --- a/nova/api/openstack/compute/views/hypervisors.py +++ b/nova/api/openstack/compute/views/hypervisors.py @@ -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 diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json.tpl index 718246b0b89e..36346c2f6d89 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json.tpl @@ -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" } ] diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json.tpl index 9a5771df022d..bb531ace7a5b 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json.tpl @@ -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" } ] diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json.tpl index 9d27290eb585..91762e075323 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json.tpl @@ -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" } ] diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json.tpl index 38337772dc15..dc0244f4296d 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-hypervisors/v2.53/hypervisors-list-resp.json.tpl @@ -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" } ] diff --git a/nova/tests/unit/api/openstack/compute/test_hypervisors.py b/nova/tests/unit/api/openstack/compute/test_hypervisors.py index 00ce1dd5b539..f5abbb3a7226 100644 --- a/nova/tests/unit/api/openstack/compute/test_hypervisors.py +++ b/nova/tests/unit/api/openstack/compute/test_hypervisors.py @@ -833,7 +833,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'} ] } @@ -894,7 +894,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'} ] } @@ -907,7 +907,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', @@ -1009,7 +1009,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', @@ -1343,7 +1343,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': [ @@ -1419,7 +1419,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': [{