From 1df1f38a91afd158336044a57f7e4c8e11108a94 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Tue, 14 Sep 2021 14:24:58 +0200 Subject: [PATCH] Add support for 'smart-nic' vnic-type The 'smart-nic' vnic_type was added in the Train time frame in I91f63810626ce4e054e358f5de5e46434c4da131. This vnic_type will also be used to support off-path SmartNIC port binding with OVN, and it is expected that the user will create ports with this vnic_type as part of the workflow. As such the client must allow users to interact with this vnic_type and this patch addresses that. Partial-Bug: #1932154 Change-Id: I7f80bb47db7f8608db4d6a646b0f4b0ef6d6fb48 --- neutronclient/neutron/v2_0/port.py | 6 +++--- neutronclient/tests/unit/test_cli20_port.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/neutronclient/neutron/v2_0/port.py b/neutronclient/neutron/v2_0/port.py index 0982b049a..3fe73544b 100644 --- a/neutronclient/neutron/v2_0/port.py +++ b/neutronclient/neutron/v2_0/port.py @@ -245,15 +245,15 @@ class CreatePort(neutronV20.CreateCommand, UpdatePortSecGroupMixin, parser.add_argument( '--vnic-type', metavar='', + '| normal | baremetal | smart-nic>', choices=['direct', 'direct-physical', 'macvtap', - 'normal', 'baremetal'], + 'normal', 'baremetal', 'smart-nic'], type=utils.convert_to_lowercase, help=_('VNIC type for this port.')) parser.add_argument( '--vnic_type', choices=['direct', 'direct-physical', 'macvtap', - 'normal', 'baremetal'], + 'normal', 'baremetal', 'smart-nic'], type=utils.convert_to_lowercase, help=argparse.SUPPRESS) parser.add_argument( diff --git a/neutronclient/tests/unit/test_cli20_port.py b/neutronclient/tests/unit/test_cli20_port.py index e1ab411e5..ab7e95655 100644 --- a/neutronclient/tests/unit/test_cli20_port.py +++ b/neutronclient/tests/unit/test_cli20_port.py @@ -214,6 +214,26 @@ class CLITestV20PortJSON(test_cli20.CLITestV20Base): self._test_create_resource(resource, cmd, name, myid, args, position_names, position_values) + def test_create_port_vnic_type_smart_nic(self): + # Create port: --vnic_type smart-nic netid. + resource = 'port' + cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None) + name = 'myname' + myid = 'myid' + netid = 'netid' + args = ['--vnic_type', 'smart-nic', netid] + position_names = ['binding:vnic_type', 'network_id'] + position_values = ['smart-nic', netid] + self._test_create_resource(resource, cmd, name, myid, args, + position_names, position_values) + + # Test dashed options + args = ['--vnic-type', 'smart-nic', netid] + position_names = ['binding:vnic_type', 'network_id'] + position_values = ['smart-nic', netid] + self._test_create_resource(resource, cmd, name, myid, args, + position_names, position_values) + def test_create_port_with_binding_profile(self): resource = 'port' cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)