diff --git a/ironicclient/osc/v1/baremetal_port.py b/ironicclient/osc/v1/baremetal_port.py index f0a3dc64e..027416b73 100644 --- a/ironicclient/osc/v1/baremetal_port.py +++ b/ironicclient/osc/v1/baremetal_port.py @@ -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='', + help=_('UUID of the port.')) parser.add_argument( '--extra', metavar="", @@ -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) diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_port.py b/ironicclient/tests/unit/osc/v1/test_baremetal_port.py index 6a344b5ed..516585cd0 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_port.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_port.py @@ -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 = [ diff --git a/releasenotes/notes/osc-port-create-uuid-5da551b154540ef7.yaml b/releasenotes/notes/osc-port-create-uuid-5da551b154540ef7.yaml new file mode 100644 index 000000000..8ac6e7522 --- /dev/null +++ b/releasenotes/notes/osc-port-create-uuid-5da551b154540ef7.yaml @@ -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.