'Validate that the port can be used in a trunk.
:param parent_port: True if the port is intended for use
as parent in a trunk.'

def validate(self, context, parent_port=True):

    subports = trunk_objects.SubPort.get_objects(context, port_id=self.port_id)
    if subports:
        raise trunk_exc.TrunkPortInUse(port_id=self.port_id)
    trunks = trunk_objects.Trunk.get_objects(context, port_id=self.port_id)
    if trunks:
        raise trunk_exc.ParentPortInUse(port_id=self.port_id)
    if parent_port:
        if (not self.can_be_trunked(context)):
            raise trunk_exc.ParentPortInUse(port_id=self.port_id)
    else:
        self.check_not_in_use(context)
    return self.port_id
