Add "hardware_offload_type" attribute to "port"
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/892771 Related-Bug: #2013228 Change-Id: I2c6fd434be4ae8cc41edf45fefe150a41cbfe0bd
This commit is contained in:
parent
03da934605
commit
0725bb474c
@ -74,6 +74,7 @@ def _get_columns(item):
|
||||
'dns_name': 'dns_name',
|
||||
'extra_dhcp_opts': 'extra_dhcp_opts',
|
||||
'fixed_ips': 'fixed_ips',
|
||||
'hardware_offload_type': 'hardware_offload_type',
|
||||
'hints': 'hints',
|
||||
'id': 'id',
|
||||
'ip_allocation': 'ip_allocation',
|
||||
@ -212,6 +213,12 @@ def _get_attrs(client_manager, parsed_args):
|
||||
if 'device_profile' in parsed_args and parsed_args.device_profile:
|
||||
attrs['device_profile'] = parsed_args.device_profile
|
||||
|
||||
if (
|
||||
'hardware_offload_type' in parsed_args
|
||||
and parsed_args.hardware_offload_type
|
||||
):
|
||||
attrs['hardware_offload_type'] = parsed_args.hardware_offload_type
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
@ -560,6 +567,15 @@ class CreatePort(command.ShowOne, common.NeutronCommandWithExtraArgs):
|
||||
metavar='<device-profile>',
|
||||
help=_('Cyborg port device profile'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--hardware-offload-type',
|
||||
metavar='<hardware-offload-type>',
|
||||
dest='hardware_offload_type',
|
||||
help=_(
|
||||
'Hardware offload type this port will request when '
|
||||
'attached to the network backend'
|
||||
),
|
||||
)
|
||||
_tag.add_tag_option_to_parser_for_create(parser, _('port'))
|
||||
return parser
|
||||
|
||||
|
@ -1761,6 +1761,7 @@ def create_one_port(attrs=None):
|
||||
'subnet_id': 'subnet-id-' + uuid.uuid4().hex,
|
||||
}
|
||||
],
|
||||
'hardware_offload_type': None,
|
||||
'hints': {},
|
||||
'id': 'port-id-' + uuid.uuid4().hex,
|
||||
'mac_address': 'fa:16:3e:a9:4e:72',
|
||||
|
@ -56,6 +56,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
||||
'dns_name',
|
||||
'extra_dhcp_opts',
|
||||
'fixed_ips',
|
||||
'hardware_offload_type',
|
||||
'hints',
|
||||
'id',
|
||||
'ip_allocation',
|
||||
@ -96,6 +97,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
||||
fake_port.dns_name,
|
||||
format_columns.ListDictColumn(fake_port.extra_dhcp_opts),
|
||||
format_columns.ListDictColumn(fake_port.fixed_ips),
|
||||
fake_port.hardware_offload_type,
|
||||
fake_port.hints,
|
||||
fake_port.id,
|
||||
fake_port.ip_allocation,
|
||||
@ -1068,6 +1070,48 @@ class TestCreatePort(TestPort):
|
||||
self.assertCountEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
def _test_create_with_hardware_offload_type(self, hwol_type=None):
|
||||
arglist = [
|
||||
'--network',
|
||||
self._port.network_id,
|
||||
'test-port',
|
||||
]
|
||||
if hwol_type:
|
||||
arglist += ['--hardware-offload-type', hwol_type]
|
||||
|
||||
hardware_offload_type = None if not hwol_type else hwol_type
|
||||
verifylist = [
|
||||
(
|
||||
'network',
|
||||
self._port.network_id,
|
||||
),
|
||||
('name', 'test-port'),
|
||||
]
|
||||
if hwol_type:
|
||||
verifylist.append(('hardware_offload_type', hwol_type))
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
create_args = {
|
||||
'admin_state_up': True,
|
||||
'network_id': self._port.network_id,
|
||||
'name': 'test-port',
|
||||
}
|
||||
if hwol_type:
|
||||
create_args['hardware_offload_type'] = hardware_offload_type
|
||||
self.network_client.create_port.assert_called_once_with(**create_args)
|
||||
|
||||
self.assertEqual(set(self.columns), set(columns))
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
def test_create_with_hardware_offload_type_switchdev(self):
|
||||
self._test_create_with_hardware_offload_type(hwol_type='switchdev')
|
||||
|
||||
def test_create_with_hardware_offload_type_null(self):
|
||||
self._test_create_with_hardware_offload_type()
|
||||
|
||||
|
||||
class TestDeletePort(TestPort):
|
||||
# Ports to delete.
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add the port hardware offload attribute to the ``port create`` command.
|
||||
Once defined, the value cannot be modified.
|
Loading…
x
Reference in New Issue
Block a user