@@ -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
10721116class TestDeletePort (TestPort ):
10731117 # Ports to delete.
0 commit comments