'Create a trunk via API.
:param tenant_id: ID of the tenant.
:param port_id: Parent port of trunk.
:param name: Name of the trunk.
:param admin_state_up: Admin state of the trunk.
:param sub_ports: List of subport dictionaries in format
{\'port_id\': <ID of neutron port for subport>,
\'segmentation_type\': \'vlan\',
\'segmentation_id\': <VLAN tag>}
:return: Dictionary with trunk\'s data returned from Neutron API.'

def create_trunk(self, tenant_id, port_id, name=None, admin_state_up=None, sub_ports=None):

    spec = {'port_id': port_id, 'tenant_id': tenant_id}
    if (name is not None):
        spec['name'] = name
    if (sub_ports is not None):
        spec['sub_ports'] = sub_ports
    if (admin_state_up is not None):
        spec['admin_state_up'] = admin_state_up
    trunk = self.client.create_trunk({'trunk': spec})['trunk']
    if sub_ports:
        self.addCleanup(_safe_method(self.trunk_remove_subports), tenant_id, trunk['id'], trunk['sub_ports'])
    self.addCleanup(_safe_method(self.client.delete_trunk), trunk['id'])
    return trunk
