Add port-uuid parameter to node vif attach

vif_attach has the capability to attach to a specific baremetal port.
This change provides an explicit (and optional) parameter for the
baremetal port UUID.

Change-Id: Ie2bedda11ccf479db0cbc3dc51f100ae49f81bc2
This commit is contained in:
Tzu-Mainn Chen 2020-06-23 17:13:32 +00:00
parent 57cb1e5e4c
commit ea4ecf7b40
4 changed files with 26 additions and 1 deletions

View File

@ -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__)

View File

@ -1728,6 +1728,11 @@ class VifAttachBaremetalNode(command.Command):
metavar='<vif-id>',
help=_("Name or UUID of the VIF to attach to a node.")
)
parser.add_argument(
'--port-uuid',
metavar='<port-uuid>',
help=_("UUID of the baremetal port to attach the VIF to.")
)
parser.add_argument(
'--vif-info',
metavar='<key=value>',
@ -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)

View File

@ -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):

View File

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