Add --chassis to 'openstack baremetal node list'
This adds an optional '--chassis <chassis UUID>' to the 'openstack baremetal node list' command. It provides the ability to get a list of nodes of a specified chassis. Change-Id: I5dbc0521858823d2e83506b6f873eda9a143f80b Partial-Bug: #1526479
This commit is contained in:
parent
62a416034b
commit
1345372cb3
ironicclient
releasenotes/notes
@ -395,6 +395,11 @@ class ListBaremetalNode(command.Lister):
|
||||
dest='resource_class',
|
||||
metavar='<resource class>',
|
||||
help="Limit list to nodes with resource class <resource class>")
|
||||
parser.add_argument(
|
||||
'--chassis',
|
||||
dest='chassis',
|
||||
metavar='<chassis UUID>',
|
||||
help="Limit list to nodes of this chassis")
|
||||
display_group = parser.add_mutually_exclusive_group(required=False)
|
||||
display_group.add_argument(
|
||||
'--long',
|
||||
@ -436,6 +441,8 @@ class ListBaremetalNode(command.Lister):
|
||||
params['provision_state'] = parsed_args.provision_state
|
||||
if parsed_args.resource_class:
|
||||
params['resource_class'] = parsed_args.resource_class
|
||||
if parsed_args.chassis:
|
||||
params['chassis'] = parsed_args.chassis
|
||||
if parsed_args.long:
|
||||
params['detail'] = parsed_args.long
|
||||
columns = res_fields.NODE_DETAILED_RESOURCE.fields
|
||||
|
@ -552,6 +552,31 @@ class TestBaremetalList(TestBaremetal):
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def test_baremetal_list_chassis(self):
|
||||
chassis_uuid = 'aaaaaaaa-1111-bbbb-2222-cccccccccccc'
|
||||
arglist = [
|
||||
'--chassis', chassis_uuid,
|
||||
]
|
||||
verifylist = [
|
||||
('chassis', chassis_uuid),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'marker': None,
|
||||
'limit': None,
|
||||
'chassis': chassis_uuid
|
||||
}
|
||||
|
||||
self.baremetal_mock.node.list.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def test_baremetal_list_fields(self):
|
||||
arglist = [
|
||||
'--fields', 'uuid', 'name',
|
||||
|
@ -181,6 +181,13 @@ fake_responses = {
|
||||
{"nodes": [NODE1]},
|
||||
)
|
||||
},
|
||||
'/v1/nodes/?chassis_uuid=%s' % NODE2['chassis_uuid']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"nodes": [NODE2]},
|
||||
)
|
||||
},
|
||||
'/v1/nodes/detail?instance_uuid=%s' % NODE2['instance_uuid']:
|
||||
{
|
||||
'GET': (
|
||||
@ -567,6 +574,16 @@ class NodeManagerTest(testtools.TestCase):
|
||||
self.assertThat(nodes, HasLength(1))
|
||||
self.assertEqual(NODE1['uuid'], getattr(nodes[0], 'uuid'))
|
||||
|
||||
def test_node_list_chassis(self):
|
||||
ch2 = NODE2['chassis_uuid']
|
||||
nodes = self.mgr.list(chassis=ch2)
|
||||
expect = [
|
||||
('GET', '/v1/nodes/?chassis_uuid=%s' % ch2, {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(nodes, HasLength(1))
|
||||
self.assertEqual(NODE2['uuid'], getattr(nodes[0], 'uuid'))
|
||||
|
||||
def test_node_list_no_maintenance(self):
|
||||
nodes = self.mgr.list(maintenance=False)
|
||||
expect = [
|
||||
|
@ -49,7 +49,8 @@ class NodeManager(base.CreateManager):
|
||||
|
||||
def list(self, associated=None, maintenance=None, marker=None, limit=None,
|
||||
detail=False, sort_key=None, sort_dir=None, fields=None,
|
||||
provision_state=None, driver=None, resource_class=None):
|
||||
provision_state=None, driver=None, resource_class=None,
|
||||
chassis=None):
|
||||
"""Retrieve a list of nodes.
|
||||
|
||||
:param associated: Optional. Either a Boolean or a string
|
||||
@ -93,6 +94,9 @@ class NodeManager(base.CreateManager):
|
||||
:param resource_class: Optional. String value to get only nodes
|
||||
with the given resource class set.
|
||||
|
||||
:param chassis: Optional, the UUID of a chassis. Used to get only
|
||||
nodes of this chassis.
|
||||
|
||||
:returns: A list of nodes.
|
||||
|
||||
"""
|
||||
@ -115,6 +119,8 @@ class NodeManager(base.CreateManager):
|
||||
filters.append('driver=%s' % driver)
|
||||
if resource_class is not None:
|
||||
filters.append('resource_class=%s' % resource_class)
|
||||
if chassis is not None:
|
||||
filters.append('chassis_uuid=%s' % chassis)
|
||||
|
||||
path = ''
|
||||
if detail:
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds an optional '--chassis' (chassis UUID) to the
|
||||
"openstack baremetal node list" command. It provides the
|
||||
ability to get a list of the nodes of the specified chassis.
|
Loading…
x
Reference in New Issue
Block a user