From bc20421d61cd335066e38e4442f6ad2f392f801a Mon Sep 17 00:00:00 2001 From: Ruby Loo Date: Wed, 31 Aug 2016 20:33:31 -0400 Subject: [PATCH] Adds --chassis-uuid to osc 'baremetal node set' Adds the optional argument '--chassis-uuid ' to the 'openstack baremetal node set' command. This allows the node's chassis to be set (and changed). Change-Id: If7b38fd1c1bba5a26d993df10e06a21213ad78f9 Closes-Bug: #1619060 --- ironicclient/osc/v1/baremetal_node.py | 9 +++++++++ .../tests/unit/osc/v1/test_baremetal_node.py | 20 +++++++++++++++++++ ...osc-node-set-chassis-aae3413489b66b9b.yaml | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 releasenotes/notes/osc-node-set-chassis-aae3413489b66b9b.yaml diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py index 13ab2e01a..e239987a4 100644 --- a/ironicclient/osc/v1/baremetal_node.py +++ b/ironicclient/osc/v1/baremetal_node.py @@ -807,6 +807,11 @@ class SetBaremetalNode(command.Command): metavar="", help="Set the name of the node", ) + parser.add_argument( + "--chassis-uuid", + metavar="", + help="Set the chassis for the node", + ) parser.add_argument( "--driver", metavar="", @@ -886,6 +891,10 @@ class SetBaremetalNode(command.Command): name = ["name=%s" % parsed_args.name] properties.extend(utils.args_array_to_patch( 'add', name)) + if parsed_args.chassis_uuid: + chassis_uuid = ["chassis_uuid=%s" % parsed_args.chassis_uuid] + properties.extend(utils.args_array_to_patch( + 'add', chassis_uuid)) if parsed_args.driver: driver = ["driver=%s" % parsed_args.driver] properties.extend(utils.args_array_to_patch( diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py index ab7b73808..c0187e276 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py @@ -1081,6 +1081,26 @@ class TestBaremetalSet(TestBaremetal): [{'path': '/name', 'value': 'xxxxx', 'op': 'add'}] ) + def test_baremetal_set_chassis(self): + chassis = '4f4135ea-7e58-4e3d-bcc4-b87ca16e980b' + arglist = [ + 'node_uuid', + '--chassis-uuid', chassis, + ] + verifylist = [ + ('node', 'node_uuid'), + ('chassis_uuid', chassis) + ] + + 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': '/chassis_uuid', 'value': chassis, 'op': 'add'}] + ) + def test_baremetal_set_driver(self): arglist = [ 'node_uuid', diff --git a/releasenotes/notes/osc-node-set-chassis-aae3413489b66b9b.yaml b/releasenotes/notes/osc-node-set-chassis-aae3413489b66b9b.yaml new file mode 100644 index 000000000..9d4024264 --- /dev/null +++ b/releasenotes/notes/osc-node-set-chassis-aae3413489b66b9b.yaml @@ -0,0 +1,4 @@ +--- +features: + - The chassis of a node can be set via the new --chassis-uuid + optional argument for ``openstack baremetal node set``.