Merge "Add options for osc 'port set' command"
This commit is contained in:
commit
2601419586
@ -254,12 +254,37 @@ class SetBaremetalPort(command.Command):
|
||||
help=_('Extra to set on this baremetal port '
|
||||
'(repeat option to set multiple extras)')
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--port-group",
|
||||
metavar="<uuid>",
|
||||
dest='portgroup_uuid',
|
||||
help=_('Set UUID of the port group that this port belongs to.'))
|
||||
parser.add_argument(
|
||||
"--local-link-connection",
|
||||
metavar="<key=value>",
|
||||
action='append',
|
||||
help=_("Key/value metadata describing local link connection "
|
||||
"information. Valid keys are switch_info, switch_id, "
|
||||
"port_id; switch_id and port_id are obligatory (repeat "
|
||||
"option to specify multiple keys).")
|
||||
)
|
||||
pxe_enabled_group = parser.add_mutually_exclusive_group(required=False)
|
||||
pxe_enabled_group.add_argument(
|
||||
"--pxe-enabled",
|
||||
dest='pxe_enabled',
|
||||
default=None,
|
||||
action='store_true',
|
||||
help=_("Indicates that this port should be used when "
|
||||
"PXE booting this node (default)")
|
||||
)
|
||||
pxe_enabled_group.add_argument(
|
||||
"--pxe-disabled",
|
||||
dest='pxe_enabled',
|
||||
default=None,
|
||||
action='store_false',
|
||||
help=_("Indicates that this port should not be used when "
|
||||
"PXE booting this node")
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
@ -282,6 +307,13 @@ class SetBaremetalPort(command.Command):
|
||||
if parsed_args.portgroup_uuid:
|
||||
portgroup_uuid = ["portgroup_uuid=%s" % parsed_args.portgroup_uuid]
|
||||
properties.extend(utils.args_array_to_patch('add', portgroup_uuid))
|
||||
if parsed_args.local_link_connection:
|
||||
properties.extend(utils.args_array_to_patch(
|
||||
'add', ['local_link_connection/' + x for x in
|
||||
parsed_args.local_link_connection]))
|
||||
if parsed_args.pxe_enabled is not None:
|
||||
properties.extend(utils.args_array_to_patch(
|
||||
'add', ['pxe_enabled=%s' % parsed_args.pxe_enabled]))
|
||||
|
||||
if properties:
|
||||
baremetal_client.port.update(parsed_args.port, properties)
|
||||
|
@ -431,6 +431,51 @@ class TestBaremetalPortSet(TestBaremetalPort):
|
||||
[{'path': '/portgroup_uuid', 'value': new_portgroup_uuid,
|
||||
'op': 'add'}])
|
||||
|
||||
def test_baremetal_set_local_link_connection(self):
|
||||
arglist = [
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
'--local-link-connection', 'switch_info=bar']
|
||||
verifylist = [('port', baremetal_fakes.baremetal_port_uuid),
|
||||
('local_link_connection', ['switch_info=bar'])]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.baremetal_mock.port.update.assert_called_once_with(
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
[{'path': '/local_link_connection/switch_info', 'value': 'bar',
|
||||
'op': 'add'}])
|
||||
|
||||
def test_baremetal_port_set_pxe_enabled(self):
|
||||
arglist = [
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
'--pxe-enabled']
|
||||
verifylist = [
|
||||
('port', baremetal_fakes.baremetal_port_uuid),
|
||||
('pxe_enabled', True)]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.baremetal_mock.port.update.assert_called_once_with(
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
[{'path': '/pxe_enabled', 'value': 'True', 'op': 'add'}])
|
||||
|
||||
def test_baremetal_port_set_pxe_disabled(self):
|
||||
arglist = [
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
'--pxe-disabled']
|
||||
verifylist = [
|
||||
('port', baremetal_fakes.baremetal_port_uuid),
|
||||
('pxe_enabled', False)]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.baremetal_mock.port.update.assert_called_once_with(
|
||||
baremetal_fakes.baremetal_port_uuid,
|
||||
[{'path': '/pxe_enabled', 'value': 'False', 'op': 'add'}])
|
||||
|
||||
def test_baremetal_port_set_no_options(self):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
For ``openstack baremetal port set``, adds these options:
|
||||
|
||||
* ``--local-link-connection <key=value>``: Key/value metadata describing
|
||||
local link connection information. Valid keys are switch_info, switch_id,
|
||||
port_id; switch_id and port_id are obligatory (repeat option to specify
|
||||
multiple keys).
|
||||
* ``--pxe-enabled``: Indicates that this port should be used when PXE
|
||||
booting this node (default)
|
||||
* ``--pxe-disabled``: Indicates that this port should not be used when PXE
|
||||
booting this node
|
Loading…
Reference in New Issue
Block a user