def _extend_port_trunk_details(core_plugin, port_res, port_db):
 if port_db.trunk_port:
  subports = {x.port_id: {'segmentation_id': x.segmentation_id, 'segmentation_type': x.segmentation_type, 'port_id': x.port_id} for x in port_db.trunk_port.sub_ports}
  ports = core_plugin.get_ports(context.get_admin_context(), filters={'id': subports})
  for port in ports:
   subports[port['id']]['mac_address'] = port['mac_address']
  trunk_details = {'trunk_id': port_db.trunk_port.id, 'sub_ports': [x for x in subports.values()]}
  port_res['trunk_details'] = trunk_details
 return port_res

def _extend_port_trunk_details ( core_plugin , port_res , port_db ) : if port_db . trunk_port : subports = { x . port_id : { 'segmentation_id' : x . segmentation_id , 'segmentation_type' : x . segmentation_type , 'port_id' : x . port_id } for x in port_db . trunk_port . sub_ports } ports = core_plugin . get_ports ( context . get_admin_context ( ) , filters = { 'id' : subports } ) for port in ports : subports [ port [ 'id' ] ] [ 'mac_address' ] = port [ 'mac_address' ] trunk_details = { 'trunk_id' : port_db . trunk_port . id , 'sub_ports' : [ x for x in subports . values ( ) ] } port_res [ 'trunk_details' ] = trunk_details return port_res
add trunk details to a port .