Merge "Set resource_url when getting all nodes"

This commit is contained in:
Zuul 2022-01-18 10:46:18 +00:00 committed by Gerrit Code Review
commit c65cbb7aef
3 changed files with 15 additions and 0 deletions

View File

@ -2288,6 +2288,7 @@ class NodesController(rest.RestController):
fields = api_utils.get_request_return_fields(fields, detail,
_DEFAULT_RETURN_FIELDS)
resource_url = 'nodes'
extra_args = {'description_contains': description_contains}
return self._get_nodes_collection(chassis_uuid, instance_uuid,
associated, maintenance, retired,
@ -2295,6 +2296,7 @@ class NodesController(rest.RestController):
limit, sort_key, sort_dir,
driver=driver,
resource_class=resource_class,
resource_url=resource_url,
fields=fields, fault=fault,
conductor_group=conductor_group,
detail=detail,

View File

@ -1347,6 +1347,7 @@ class TestListNodes(test_api_base.BaseApiTest):
next_marker = data['nodes'][-1]['uuid']
self.assertIn(next_marker, data['next'])
self.assertIn('nodes', data['next'])
def test_collection_links_default_limit(self):
cfg.CONF.set_override('max_limit', 3, 'api')
@ -1360,6 +1361,7 @@ class TestListNodes(test_api_base.BaseApiTest):
next_marker = data['nodes'][-1]['uuid']
self.assertIn(next_marker, data['next'])
self.assertIn('nodes', data['next'])
def test_collection_links_custom_fields(self):
fields = 'driver_info,uuid'
@ -1379,6 +1381,7 @@ class TestListNodes(test_api_base.BaseApiTest):
next_marker = data['nodes'][-1]['uuid']
self.assertIn(next_marker, data['next'])
self.assertIn('fields', data['next'])
self.assertIn('nodes', data['next'])
def test_get_collection_pagination_no_uuid(self):
fields = 'name'
@ -1396,6 +1399,7 @@ class TestListNodes(test_api_base.BaseApiTest):
self.assertEqual(limit, len(data['nodes']))
self.assertIn('marker=%s' % nodes[limit - 1].uuid, data['next'])
self.assertIn('nodes', data['next'])
def test_collection_links_instance_uuid_param(self):
cfg.CONF.set_override('max_limit', 1, 'api')
@ -1615,6 +1619,7 @@ class TestListNodes(test_api_base.BaseApiTest):
headers={api_base.Version.string: str(api_v1.max_version())})
self.assertEqual(1, len(data['connectors']))
self.assertIn('next', data)
self.assertIn('volume/connectors', data['next'])
def test_volume_connectors_subresource_noid(self):
node = obj_utils.create_test_node(self.context)
@ -1654,6 +1659,7 @@ class TestListNodes(test_api_base.BaseApiTest):
headers={api_base.Version.string: str(api_v1.max_version())})
self.assertEqual(1, len(data['targets']))
self.assertIn('next', data)
self.assertIn('volume/target', data['next'])
def test_volume_targets_subresource_noid(self):
node = obj_utils.create_test_node(self.context)
@ -1858,6 +1864,7 @@ class TestListNodes(test_api_base.BaseApiTest):
data = self.get_json('/nodes/?limit=3&associated=True')
self.assertThat(data['nodes'], matchers.HasLength(3))
self.assertIn('associated=True', data['next'])
self.assertIn('nodes', data['next'])
def test_detail_with_association_filter(self):
associated_nodes = (self
@ -1872,6 +1879,7 @@ class TestListNodes(test_api_base.BaseApiTest):
self.assertThat(data['nodes'], matchers.HasLength(3))
self.assertIn('driver', data['nodes'][0])
self.assertIn('associated=True', data['next'])
self.assertIn('nodes', data['next'])
def test_detail_with_instance_uuid(self):
node = obj_utils.create_test_node(

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes an issue where clients would get a 404 due to the node pagination
breaking at max_limit due to an uninitialised resource_url.