Merge "Extend OSC "node list" cmd to fetch nodes without instance UUID"

This commit is contained in:
Jenkins
2017-01-25 05:50:11 +00:00
committed by Gerrit Code Review
3 changed files with 51 additions and 5 deletions

View File

@@ -489,12 +489,16 @@ class ListBaremetalNode(command.Lister):
default=False,
help="List nodes in maintenance mode.",
)
parser.add_argument(
associated_group = parser.add_mutually_exclusive_group()
associated_group.add_argument(
'--associated',
dest='associated',
action='store_true',
default=False,
help="List only nodes associated with an instance."
help=_('List only nodes associated with an instance.'),
)
associated_group.add_argument(
'--unassociated',
action='store_true',
help=_('List only nodes not associated with an instance.'),
)
parser.add_argument(
'--provision-state',
@@ -547,7 +551,9 @@ class ListBaremetalNode(command.Lister):
params['limit'] = parsed_args.limit
params['marker'] = parsed_args.marker
if parsed_args.associated:
params['associated'] = parsed_args.associated
params['associated'] = True
if parsed_args.unassociated:
params['associated'] = False
if parsed_args.maintenance:
params['maintenance'] = parsed_args.maintenance
if parsed_args.provision_state:

View File

@@ -631,6 +631,39 @@ class TestBaremetalList(TestBaremetal):
**kwargs
)
def test_baremetal_list_unassociated(self):
arglist = [
'--unassociated',
]
verifylist = [
('associated', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
'marker': None,
'limit': None,
'associated': False,
}
self.baremetal_mock.node.list.assert_called_with(
**kwargs
)
def test_baremetal_list_both_associated_unassociated_not_allowed(self):
arglist = [
'--associated', '--unassociated',
]
verifylist = []
self.assertRaises(oscutils.ParserException,
self.check_parser,
self.cmd, arglist, verifylist)
def test_baremetal_list_provision_state(self):
arglist = [
'--provision-state', 'active',

View File

@@ -0,0 +1,7 @@
---
features:
- |
Adds an option ``--unassociated`` to the
``openstack baremetal node list`` command. It provides the
ability to get a list of the nodes that are not associated
with instances.