Set resource_url when getting all nodes

Since the default value resource_url is None, make sure the
parameter is set to 'nodes' when getting all nodes.

Change-Id: I6cc52eb56c7888a433d24aa79154143d6f35cf83
This commit is contained in:
Arne Wiebalck 2022-01-11 12:37:41 +01:00
parent d3ccd4d3a9
commit 69227c66c2
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')
@ -1613,6 +1617,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)
@ -1652,6 +1657,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)
@ -1856,6 +1862,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
@ -1870,6 +1877,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.