Support setting automated_clean to False

Change-Id: I683d3e2342142d6c87c4b270ccaf82445d22e9ef
This commit is contained in:
Dmitry Tantsur 2020-12-23 17:25:46 +01:00
parent ceceb3ffee
commit c94eaae83b
3 changed files with 54 additions and 5 deletions

View File

@ -456,11 +456,18 @@ class CreateBaremetalNode(command.ShowOne):
'--conductor-group',
metavar='<conductor_group>',
help=_('Conductor group the node will belong to'))
parser.add_argument(
clean = parser.add_mutually_exclusive_group()
clean.add_argument(
'--automated-clean',
action='store_true',
default=None,
help=_('Enable automated cleaning for the node'))
clean.add_argument(
'--no-automated-clean',
action='store_false',
dest='automated_clean',
default=None,
help=_('Explicitly disable automated cleaning for the node'))
parser.add_argument(
'--owner',
metavar='<owner>',
@ -1191,11 +1198,18 @@ class SetBaremetalNode(command.Command):
metavar='<conductor_group>',
help=_('Set the conductor group for the node'),
)
parser.add_argument(
clean = parser.add_mutually_exclusive_group()
clean.add_argument(
'--automated-clean',
action='store_true',
help=_('Enable automated cleaning for the node'),
)
default=None,
help=_('Enable automated cleaning for the node'))
clean.add_argument(
'--no-automated-clean',
action='store_false',
dest='automated_clean',
default=None,
help=_('Explicitly disable automated cleaning for the node'))
parser.add_argument(
'--protected',
action='store_true',
@ -1284,7 +1298,7 @@ class SetBaremetalNode(command.Command):
raid_config)
properties = []
for field in ['automated_clean', 'instance_uuid', 'name',
for field in ['instance_uuid', 'name',
'chassis_uuid', 'driver', 'resource_class',
'conductor_group', 'protected', 'protected_reason',
'retired', 'retired_reason', 'owner', 'lessee',
@ -1294,6 +1308,10 @@ class SetBaremetalNode(command.Command):
properties.extend(utils.args_array_to_patch(
'add', ["%s=%s" % (field, value)]))
if parsed_args.automated_clean is not None:
properties.extend(utils.args_array_to_patch(
'add', ["automated_clean=%s" % parsed_args.automated_clean]))
if parsed_args.reset_interfaces and not parsed_args.driver:
raise exc.CommandError(
_("--reset-interfaces can only be specified with --driver"))

View File

@ -465,6 +465,11 @@ class TestBaremetalCreate(TestBaremetal):
[('automated_clean', True)],
{'automated_clean': True})
def test_baremetal_create_with_no_automated_clean(self):
self.check_with_options(['--no-automated-clean'],
[('automated_clean', False)],
{'automated_clean': False})
def test_baremetal_create_with_owner(self):
self.check_with_options(['--owner', 'owner 1'],
[('owner', 'owner 1')],
@ -2477,6 +2482,26 @@ class TestBaremetalSet(TestBaremetal):
reset_interfaces=None,
)
def test_baremetal_set_no_automated_clean(self):
arglist = [
'node_uuid',
'--no-automated-clean'
]
verifylist = [
('node', 'node_uuid'),
('automated_clean', False)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.update.assert_called_once_with(
'node_uuid',
[{'path': '/automated_clean', 'value': 'False', 'op': 'add'}],
reset_interfaces=None,
)
def test_baremetal_set_protected(self):
arglist = [
'node_uuid',

View File

@ -0,0 +1,6 @@
---
features:
- |
Following a similar change to ironic, it is now possible to set the node's
``automated_clean`` to False using the new ``--no-automated-clean``
argument to ``baremetal node set``.