Fix usage of --owner filter during node list
When using --owner filter during node list, the CLI returns this error: list() got an unexpected keyword argument 'owner' Change-Id: Id751336d8d8cb99e62e465e17114e610f619c520 Story: 2006563 Task: 36660
This commit is contained in:
parent
87c0171fd6
commit
89088e2aaa
@ -51,7 +51,8 @@ NODE2 = {'uuid': '66666666-7777-8888-9999-111111111111',
|
||||
'driver_info': {'user': 'foo', 'password': 'bar'},
|
||||
'properties': {'num_cpu': 4},
|
||||
'resource_class': 'bar',
|
||||
'extra': {}}
|
||||
'extra': {},
|
||||
'owner': '33333333-2222-1111-0000-111111111111'}
|
||||
PORT = {'uuid': '11111111-2222-3333-4444-555555555555',
|
||||
'node_uuid': '66666666-7777-8888-9999-000000000000',
|
||||
'address': 'AA:AA:AA:AA:AA:AA',
|
||||
@ -187,6 +188,13 @@ fake_responses = {
|
||||
{"nodes": [NODE1]},
|
||||
)
|
||||
},
|
||||
'/v1/nodes/?owner=%s' % NODE2['owner']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"nodes": [NODE2]},
|
||||
)
|
||||
},
|
||||
'/v1/nodes/?driver=fake':
|
||||
{
|
||||
'GET': (
|
||||
@ -803,6 +811,15 @@ class NodeManagerTest(testtools.TestCase):
|
||||
self.assertThat(nodes, HasLength(1))
|
||||
self.assertEqual(NODE1['uuid'], getattr(nodes[0], 'uuid'))
|
||||
|
||||
def test_node_list_owner(self):
|
||||
nodes = self.mgr.list(owner=NODE2['owner'])
|
||||
expect = [
|
||||
('GET', '/v1/nodes/?owner=%s' % NODE2['owner'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(nodes, HasLength(1))
|
||||
self.assertEqual(NODE2['owner'], getattr(nodes[0], 'owner'))
|
||||
|
||||
def test_node_list_provision_state_fail(self):
|
||||
self.assertRaises(KeyError, self.mgr.list,
|
||||
provision_state="test")
|
||||
|
@ -60,7 +60,7 @@ class NodeManager(base.CreateManager):
|
||||
detail=False, sort_key=None, sort_dir=None, fields=None,
|
||||
provision_state=None, driver=None, resource_class=None,
|
||||
chassis=None, fault=None, os_ironic_api_version=None,
|
||||
conductor_group=None, conductor=None):
|
||||
conductor_group=None, conductor=None, owner=None):
|
||||
"""Retrieve a list of nodes.
|
||||
|
||||
:param associated: Optional. Either a Boolean or a string
|
||||
@ -116,6 +116,8 @@ class NodeManager(base.CreateManager):
|
||||
with the given conductor group set.
|
||||
:param conductor: Optional. String value to get only nodes
|
||||
mapped to the given conductor.
|
||||
:param owner: Optional. String value to get only nodes
|
||||
mapped to a specific owner.
|
||||
|
||||
:returns: A list of nodes.
|
||||
|
||||
@ -147,6 +149,8 @@ class NodeManager(base.CreateManager):
|
||||
filters.append('conductor_group=%s' % conductor_group)
|
||||
if conductor is not None:
|
||||
filters.append('conductor=%s' % conductor)
|
||||
if owner is not None:
|
||||
filters.append('owner=%s' % owner)
|
||||
|
||||
path = ''
|
||||
if detail:
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
``openstack baremetal node list --owner`` was returning an error
|
||||
instead of a list of nodes for the specified owner. It has been
|
||||
fixed.
|
||||
|
||||
See `story 2006563
|
||||
<https://storyboard.openstack.org/#!/story/2006563>`__ for details.
|
Loading…
Reference in New Issue
Block a user