diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index ceb3a1b0b..257b57e03 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -37,7 +37,7 @@ from ironicclient import exc # http://specs.openstack.org/openstack/ironic-specs/specs/kilo/api-microversions.html # noqa # for full details. DEFAULT_VER = '1.9' -LAST_KNOWN_API_VERSION = 66 +LAST_KNOWN_API_VERSION = 67 LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION) LOG = logging.getLogger(__name__) diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py index e45778415..e7bdb5117 100755 --- a/ironicclient/osc/v1/baremetal_node.py +++ b/ironicclient/osc/v1/baremetal_node.py @@ -1728,6 +1728,11 @@ class VifAttachBaremetalNode(command.Command): metavar='', help=_("Name or UUID of the VIF to attach to a node.") ) + parser.add_argument( + '--port-uuid', + metavar='', + help=_("UUID of the baremetal port to attach the VIF to.") + ) parser.add_argument( '--vif-info', metavar='', @@ -1743,6 +1748,8 @@ class VifAttachBaremetalNode(command.Command): baremetal_client = self.app.client_manager.baremetal fields = utils.key_value_pairs_to_dict(parsed_args.vif_info or []) + if parsed_args.port_uuid: + fields['port_uuid'] = parsed_args.port_uuid baremetal_client.node.vif_attach(parsed_args.node, parsed_args.vif_id, **fields) diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py index 99708f5ef..1c0df28a6 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py @@ -3551,6 +3551,18 @@ class TestVifAttach(TestBaremetal): self.baremetal_mock.node.vif_attach.assert_called_once_with( 'node_uuid', 'aaa-aaa', foo='bar') + def test_baremetal_vif_attach_port_uuid(self): + arglist = ['node_uuid', 'aaa-aaa', '--port-uuid', 'fake-port-uuid'] + verifylist = [('node', 'node_uuid'), + ('vif_id', 'aaa-aaa'), + ('port_uuid', 'fake-port-uuid')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.cmd.take_action(parsed_args) + + self.baremetal_mock.node.vif_attach.assert_called_once_with( + 'node_uuid', 'aaa-aaa', port_uuid='fake-port-uuid') + class TestVifDetach(TestBaremetal): def setUp(self): diff --git a/releasenotes/notes/vif-attach-port-29a421b245e19f2b.yaml b/releasenotes/notes/vif-attach-port-29a421b245e19f2b.yaml new file mode 100644 index 000000000..19b2e3fef --- /dev/null +++ b/releasenotes/notes/vif-attach-port-29a421b245e19f2b.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Updates the node vif attach API action to accept an optional ``port_uuid`` + parameter. If specified, then Ironic will attempt to attach to the + specified port.