diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-12-23 17:25:46 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-12-23 17:25:46 +0100 |
commit | c94eaae83bf94bdf557be95f2623381f2d76eba3 (patch) | |
tree | f50e0ad108fdc0268bec6632e2946066bda71332 | |
parent | ceceb3ffeed3f06d60cc299a90cc0012680d75d8 (diff) | |
download | python-ironicclient-c94eaae83bf94bdf557be95f2623381f2d76eba3.tar.gz |
Support setting automated_clean to False
Change-Id: I683d3e2342142d6c87c4b270ccaf82445d22e9ef
-rwxr-xr-x | ironicclient/osc/v1/baremetal_node.py | 28 | ||||
-rw-r--r-- | ironicclient/tests/unit/osc/v1/test_baremetal_node.py | 25 | ||||
-rw-r--r-- | releasenotes/notes/no-automated-clean-0e437581ded44eb3.yaml | 6 |
3 files changed, 54 insertions, 5 deletions
diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py index e7bdb51..fe08859 100755 --- a/ironicclient/osc/v1/baremetal_node.py +++ b/ironicclient/osc/v1/baremetal_node.py @@ -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")) diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py index 1c0df28..b69373a 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py @@ -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', diff --git a/releasenotes/notes/no-automated-clean-0e437581ded44eb3.yaml b/releasenotes/notes/no-automated-clean-0e437581ded44eb3.yaml new file mode 100644 index 0000000..9ecffe8 --- /dev/null +++ b/releasenotes/notes/no-automated-clean-0e437581ded44eb3.yaml @@ -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``. |