Adds --chassis-uuid to osc 'baremetal node set'

Adds the optional argument '--chassis-uuid <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
This commit is contained in:
Ruby Loo 2016-08-31 20:33:31 -04:00
parent 1d3a813234
commit bc20421d61
3 changed files with 33 additions and 0 deletions

View File

@ -807,6 +807,11 @@ class SetBaremetalNode(command.Command):
metavar="<name>",
help="Set the name of the node",
)
parser.add_argument(
"--chassis-uuid",
metavar="<chassis UUID>",
help="Set the chassis for the node",
)
parser.add_argument(
"--driver",
metavar="<driver>",
@ -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(

View File

@ -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',

View File

@ -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``.