Add --uuid option to OSC "port create" cmd

This adds the --uuid option to the "openstack baremetal port create"
command. It is the UUID of the new port to be created.

Change-Id: Ib7ab29263452f5a4a359049a032cfcd23507180c
Closes-Bug: #1696836
This commit is contained in:
Ruby Loo 2017-06-08 15:34:55 -04:00
parent 725b45376a
commit 64f8871de9
3 changed files with 39 additions and 1 deletions

View File

@ -46,6 +46,11 @@ class CreateBaremetalPort(command.ShowOne):
required=True,
help=_('UUID of the node that this port belongs to.')
)
parser.add_argument(
'--uuid',
dest='uuid',
metavar='<uuid>',
help=_('UUID of the port.'))
parser.add_argument(
'--extra',
metavar="<key=value>",
@ -104,7 +109,7 @@ class CreateBaremetalPort(command.ShowOne):
parsed_args.local_link_connection = (
parsed_args.local_link_connection_deprecated)
field_list = ['address', 'extra', 'node_uuid', 'pxe_enabled',
field_list = ['address', 'uuid', 'extra', 'node_uuid', 'pxe_enabled',
'local_link_connection', 'portgroup_uuid']
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
if k in field_list and v is not None)

View File

@ -121,6 +121,34 @@ class TestCreateBaremetalPort(TestBaremetalPort):
self.check_parser,
self.cmd, arglist, verifylist)
def test_baremetal_port_create_uuid(self):
port_uuid = "da6c8d2e-fbcd-457a-b2a7-cc5c775933af"
arglist = [
baremetal_fakes.baremetal_port_address,
'--node', baremetal_fakes.baremetal_uuid,
'--uuid', port_uuid
]
verifylist = [
('node_uuid', baremetal_fakes.baremetal_uuid),
('address', baremetal_fakes.baremetal_port_address),
('uuid', port_uuid)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
# Set expected values
args = {
'address': baremetal_fakes.baremetal_port_address,
'node_uuid': baremetal_fakes.baremetal_uuid,
'uuid': port_uuid
}
self.baremetal_mock.port.create.assert_called_once_with(**args)
def _test_baremetal_port_create_llc_warning(self, additional_args,
additional_verify_items):
arglist = [

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds the ``--uuid`` option for the ``openstack baremetal port create``
command so that the new port's UUID can be specified.