1212
1313from unittest import mock
1414from unittest .mock import call
15+ import uuid
1516
1617from osc_lib .cli import format_columns
1718from osc_lib import exceptions
2425
2526
2627LIST_FIELDS_TO_RETRIEVE = ('id' , 'name' , 'mac_address' , 'fixed_ips' , 'status' )
27- LIST_FIELDS_TO_RETRIEVE_LONG = ('security_group_ids' , 'device_owner' , 'tags' )
28+ LIST_FIELDS_TO_RETRIEVE_LONG = (
29+ 'security_group_ids' ,
30+ 'device_owner' ,
31+ 'tags' ,
32+ 'trunk_details' ,
33+ )
2834
2935
3036class TestPort (network_fakes .TestNetworkV2 ):
@@ -116,7 +122,7 @@ def _get_common_cols_data(fake_port):
116122 fake_port .status ,
117123 format_columns .ListColumn (fake_port .tags ),
118124 fake_port .trusted ,
119- fake_port .trunk_details ,
125+ port . SubPortColumn ( fake_port .trunk_details ) ,
120126 fake_port .updated_at ,
121127 )
122128
@@ -1236,7 +1242,37 @@ def test_multi_ports_delete_with_exception(self):
12361242
12371243
12381244class TestListPort (compute_fakes .FakeClientMixin , TestPort ):
1239- _ports = network_fakes .create_ports (count = 3 )
1245+ _project = identity_fakes .FakeProject .create_one_project ()
1246+ _networks = network_fakes .create_networks (count = 3 )
1247+ _sport1 = network_fakes .create_one_port (
1248+ attrs = {'project_id' : _project .id , 'network_id' : _networks [1 ]['id' ]}
1249+ )
1250+ _sport2 = network_fakes .create_one_port (
1251+ attrs = {'project_id' : _project .id , 'network_id' : _networks [2 ]['id' ]}
1252+ )
1253+ _trunk_details = {
1254+ 'trunk_id' : str (uuid .uuid4 ()),
1255+ 'sub_ports' : [
1256+ {
1257+ 'segmentation_id' : 100 ,
1258+ 'segmentation_type' : 'vlan' ,
1259+ 'port_id' : _sport1 .id ,
1260+ },
1261+ {
1262+ 'segmentation_id' : 102 ,
1263+ 'segmentation_type' : 'vlan' ,
1264+ 'port_id' : _sport2 .id ,
1265+ },
1266+ ],
1267+ }
1268+ _pport = network_fakes .create_one_port (
1269+ attrs = {
1270+ 'project_id' : _project .id ,
1271+ 'network_id' : _networks [0 ]['id' ],
1272+ 'trunk_details' : _trunk_details ,
1273+ }
1274+ )
1275+ _ports = (_pport , _sport1 , _sport2 )
12401276
12411277 columns = (
12421278 'ID' ,
@@ -1255,6 +1291,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
12551291 'Security Groups' ,
12561292 'Device Owner' ,
12571293 'Tags' ,
1294+ 'Trunk subports' ,
12581295 )
12591296
12601297 data = []
@@ -1281,6 +1318,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
12811318 format_columns .ListColumn (prt .security_group_ids ),
12821319 prt .device_owner ,
12831320 format_columns .ListColumn (prt .tags ),
1321+ port .SubPortColumn (prt .trunk_details ),
12841322 )
12851323 )
12861324
0 commit comments