Use same variable for --[no-]maintenance
This changes the code to use the same parsed_args.maintenance
variable to keep track of whether --maintenance or --no-maintenance
arguments were specified in the 'openstack baremetal node list'
command.
This is a follow up to 4487a37202
.
Change-Id: I4058b34881ff36f9e0b0d93bf0ed252c5e3f94ee
This commit is contained in:
parent
be0bc81d88
commit
814e6c0628
|
@ -487,14 +487,14 @@ class ListBaremetalNode(command.Lister):
|
|||
'--maintenance',
|
||||
dest='maintenance',
|
||||
action='store_true',
|
||||
default=False,
|
||||
default=None,
|
||||
help="Limit list to nodes in maintenance mode",
|
||||
)
|
||||
maint_group.add_argument(
|
||||
'--no-maintenance',
|
||||
dest='no_maintenance',
|
||||
action='store_true',
|
||||
default=False,
|
||||
dest='maintenance',
|
||||
action='store_false',
|
||||
default=None,
|
||||
help="Limit list to nodes not in maintenance mode",
|
||||
)
|
||||
associated_group = parser.add_mutually_exclusive_group()
|
||||
|
@ -562,10 +562,8 @@ class ListBaremetalNode(command.Lister):
|
|||
params['associated'] = True
|
||||
if parsed_args.unassociated:
|
||||
params['associated'] = False
|
||||
if parsed_args.maintenance:
|
||||
params['maintenance'] = True
|
||||
elif parsed_args.no_maintenance:
|
||||
params['maintenance'] = False
|
||||
if parsed_args.maintenance is not None:
|
||||
params['maintenance'] = parsed_args.maintenance
|
||||
if parsed_args.provision_state:
|
||||
params['provision_state'] = parsed_args.provision_state
|
||||
if parsed_args.resource_class:
|
||||
|
|
|
@ -583,12 +583,12 @@ class TestBaremetalList(TestBaremetal):
|
|||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_baremetal_list_maintenance(self):
|
||||
def _test_baremetal_list_maintenance(self, maint_option, maint_value):
|
||||
arglist = [
|
||||
'--maintenance',
|
||||
maint_option,
|
||||
]
|
||||
verifylist = [
|
||||
('maintenance', True),
|
||||
('maintenance', maint_value),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
@ -600,19 +600,23 @@ class TestBaremetalList(TestBaremetal):
|
|||
kwargs = {
|
||||
'marker': None,
|
||||
'limit': None,
|
||||
'maintenance': True,
|
||||
'maintenance': maint_value,
|
||||
}
|
||||
|
||||
self.baremetal_mock.node.list.assert_called_with(
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def test_baremetal_list_maintenance(self):
|
||||
self._test_baremetal_list_maintenance('--maintenance', True)
|
||||
|
||||
def test_baremetal_list_no_maintenance(self):
|
||||
self._test_baremetal_list_maintenance('--no-maintenance', False)
|
||||
|
||||
def test_baremetal_list_none_maintenance(self):
|
||||
arglist = [
|
||||
'--no-maintenance',
|
||||
]
|
||||
verifylist = [
|
||||
('no_maintenance', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
@ -624,7 +628,6 @@ class TestBaremetalList(TestBaremetal):
|
|||
kwargs = {
|
||||
'marker': None,
|
||||
'limit': None,
|
||||
'maintenance': False,
|
||||
}
|
||||
|
||||
self.baremetal_mock.node.list.assert_called_with(
|
||||
|
|
Loading…
Reference in New Issue