Add "hardware_offload_type" attribute to "port" · openstack/python-openstackclient@0725bb4 · GitHub
Skip to content

Commit 0725bb4

Browse files
committed
Add "hardware_offload_type" attribute to "port"
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/892771 Related-Bug: #2013228 Change-Id: I2c6fd434be4ae8cc41edf45fefe150a41cbfe0bd
1 parent 03da934 commit 0725bb4

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

openstackclient/network/v2/port.py

Lines changed: 16 additions & 0 deletions

openstackclient/tests/unit/network/v2/fakes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ def create_one_port(attrs=None):
17611761
'subnet_id': 'subnet-id-' + uuid.uuid4().hex,
17621762
}
17631763
],
1764+
'hardware_offload_type': None,
17641765
'hints': {},
17651766
'id': 'port-id-' + uuid.uuid4().hex,
17661767
'mac_address': 'fa:16:3e:a9:4e:72',

openstackclient/tests/unit/network/v2/test_port.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def _get_common_cols_data(fake_port):
5656
'dns_name',
5757
'extra_dhcp_opts',
5858
'fixed_ips',
59+
'hardware_offload_type',
5960
'hints',
6061
'id',
6162
'ip_allocation',
@@ -96,6 +97,7 @@ def _get_common_cols_data(fake_port):
9697
fake_port.dns_name,
9798
format_columns.ListDictColumn(fake_port.extra_dhcp_opts),
9899
format_columns.ListDictColumn(fake_port.fixed_ips),
100+
fake_port.hardware_offload_type,
99101
fake_port.hints,
100102
fake_port.id,
101103
fake_port.ip_allocation,
@@ -1068,6 +1070,48 @@ def test_create_hints_valid_json(self):
10681070
self.assertCountEqual(self.columns, columns)
10691071
self.assertCountEqual(self.data, data)
10701072

1073+
def _test_create_with_hardware_offload_type(self, hwol_type=None):
1074+
arglist = [
1075+
'--network',
1076+
self._port.network_id,
1077+
'test-port',
1078+
]
1079+
if hwol_type:
1080+
arglist += ['--hardware-offload-type', hwol_type]
1081+
1082+
hardware_offload_type = None if not hwol_type else hwol_type
1083+
verifylist = [
1084+
(
1085+
'network',
1086+
self._port.network_id,
1087+
),
1088+
('name', 'test-port'),
1089+
]
1090+
if hwol_type:
1091+
verifylist.append(('hardware_offload_type', hwol_type))
1092+
1093+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1094+
1095+
columns, data = self.cmd.take_action(parsed_args)
1096+
1097+
create_args = {
1098+
'admin_state_up': True,
1099+
'network_id': self._port.network_id,
1100+
'name': 'test-port',
1101+
}
1102+
if hwol_type:
1103+
create_args['hardware_offload_type'] = hardware_offload_type
1104+
self.network_client.create_port.assert_called_once_with(**create_args)
1105+
1106+
self.assertEqual(set(self.columns), set(columns))
1107+
self.assertCountEqual(self.data, data)
1108+
1109+
def test_create_with_hardware_offload_type_switchdev(self):
1110+
self._test_create_with_hardware_offload_type(hwol_type='switchdev')
1111+
1112+
def test_create_with_hardware_offload_type_null(self):
1113+
self._test_create_with_hardware_offload_type()
1114+
10711115

10721116
class TestDeletePort(TestPort):
10731117
# Ports to delete.
Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)