Merge "Fixes the description filter"

This commit is contained in:
Zuul 2024-07-02 12:13:54 +00:00 committed by Gerrit Code Review
commit 85542f0caf
3 changed files with 30 additions and 2 deletions

View File

@ -55,7 +55,8 @@ NODE2 = {'uuid': '66666666-7777-8888-9999-111111111111',
'retired': True,
'lessee': '77777777-8888-5555-2222-999999999999',
'shard': 'myshard',
'parent_node': NODE1['uuid']}
'parent_node': NODE1['uuid'],
'description': 'foo bar'}
PORT = {'uuid': '11111111-2222-3333-4444-555555555555',
'node_uuid': '66666666-7777-8888-9999-000000000000',
'address': 'AA:AA:AA:AA:AA:AA',
@ -298,6 +299,13 @@ fake_responses = {
{"nodes": [NODE2]}
)
},
'/v1/nodes/?description_contains=foo':
{
'GET': (
{},
{"nodes": [NODE2]}
)
},
'/v1/nodes/%s/children' % NODE1['uuid']:
{
'GET': (
@ -1068,6 +1076,16 @@ class NodeManagerTest(testtools.TestCase):
self.assertEqual(1, len(children))
self.assertEqual(NODE2['uuid'], children[0])
def test_node_list_by_description(self):
nodes = self.mgr.list(description_contains='foo')
expect = [
('GET', '/v1/nodes/?description_contains=foo', {}, None),
]
self.assertEqual(expect, self.api.calls)
self.assertThat(nodes, HasLength(1))
self.assertEqual(NODE2['description'],
getattr(nodes[0], 'description'))
def test_node_list_detail(self):
nodes = self.mgr.list(detail=True)
expect = [

View File

@ -65,7 +65,8 @@ class NodeManager(base.CreateManager):
os_ironic_api_version=None, conductor_group=None,
conductor=None, owner=None, retired=None, lessee=None,
shards=None, sharded=None, parent_node=None,
include_children=None, global_request_id=None):
include_children=None, description_contains=None,
global_request_id=None):
"""Retrieve a list of nodes.
:param associated: Optional. Either a Boolean or a string
@ -144,6 +145,8 @@ class NodeManager(base.CreateManager):
Tells the ironic API to enumerate all child
nodes which are normally hidden from the
node list.
:param description_contains: Optional. String value to get nodes
with description contains specified value.
:returns: A list of nodes.
"""
@ -189,6 +192,8 @@ class NodeManager(base.CreateManager):
if include_children:
# NOTE(TheJulia): Only valid if True.
filters.append('include_children=True')
if description_contains is not None:
filters.append('description_contains=%s' % description_contains)
path = ''
if detail:

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes the issue that ``--description-contains`` does not work when trying
to query nodes with description filter.