# Path: neutron_taas/extensions/taas.py
# class TapServiceNotFound(qexception.NotFound):
# class TapFlowNotFound(qexception.NotFound):
# class InvalidDestinationPort(qexception.NotFound):
# class InvalidSourcePort(qexception.NotFound):
# class PortDoesNotBelongToTenant(qexception.NotAuthorized):
# class TapServiceNotBelongToTenant(qexception.NotAuthorized):
# class TapServiceLimitReached(qexception.OverQuota):
# class Taas(extensions.ExtensionDescriptor):
# class TaasPluginBase(service_base.ServicePluginBase):
# RESOURCE_ATTRIBUTE_MAP = {
#     'tap_services': {
#         'id': {'allow_post': False, 'allow_put': False,
#                'validate': {'type:uuid': None}, 'is_visible': True,
#                'primary_key': True},
#         'tenant_id': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:string': None},
#                       'required_by_policy': True, 'is_visible': True},
#         'name': {'allow_post': True, 'allow_put': True,
#                  'validate': {'type:string': None},
#                  'is_visible': True, 'default': ''},
#         'description': {'allow_post': True, 'allow_put': True,
#                         'validate': {'type:string': None},
#                         'is_visible': True, 'default': ''},
#         'port_id': {'allow_post': True, 'allow_put': False,
#                     'validate': {'type:uuid': None},
#                     'is_visible': True},
#         'status': {'allow_post': False, 'allow_put': False,
#                    'is_visible': True}
#     },
#     'tap_flows': {
#         'id': {'allow_post': False, 'allow_put': False,
#                'validate': {'type:uuid': None}, 'is_visible': True,
#                'primary_key': True},
#         'tenant_id': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:string': None},
#                       'required_by_policy': True, 'is_visible': True},
#         'name': {'allow_post': True, 'allow_put': True,
#                  'validate': {'type:string': None},
#                  'is_visible': True, 'default': ''},
#         'description': {'allow_post': True, 'allow_put': True,
#                         'validate': {'type:string': None},
#                         'is_visible': True, 'default': ''},
#         'tap_service_id': {'allow_post': True, 'allow_put': False,
#                            'validate': {'type:uuid': None},
#                            'required_by_policy': True, 'is_visible': True},
#         'source_port': {'allow_post': True, 'allow_put': False,
#                         'validate': {'type:uuid': None},
#                         'required_by_policy': True, 'is_visible': True},
#         'direction': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:values': direction_enum},
#                       'is_visible': True},
#         'status': {'allow_post': False, 'allow_put': False,
#                    'is_visible': True}
#     }
# }
#     def get_name(cls):
#     def get_alias(cls):
#     def get_description(cls):
#     def get_updated(cls):
#     def get_plugin_interface(cls):
#     def get_resources(cls):
#     def update_attributes_map(self, attributes):
#     def get_extended_resources(self, version):
#     def get_plugin_description(self):
#     def get_plugin_type(cls):
#     def create_tap_service(self, context, tap_service):
#     def delete_tap_service(self, context, id):
#     def get_tap_service(self, context, id, fields=None):
#     def get_tap_services(self, context, filters=None, fields=None,
#                          sorts=None, limit=None, marker=None,
#                          page_reverse=False):
#     def update_tap_service(self, context, id, tap_service):
#     def create_tap_flow(self, context, tap_flow):
#     def get_tap_flow(self, context, id, fields=None):
#     def delete_tap_flow(self, context, id):
#     def get_tap_flows(self, context, filters=None, fields=None,
#                       sorts=None, limit=None, marker=None,
#                       page_reverse=False):
#     def update_tap_flow(self, context, id, tap_flow):


import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.orm import exc
from neutron_lib import constants
from neutron_lib.db import model_base
from neutron_lib.db import model_query
from neutron_lib.db import utils as db_utils
from neutron_lib.plugins import directory
from neutron_taas.extensions import taas
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils
                       server_default=constants.ACTIVE)
    vlan_filter = sa.Column(sa.String(1024), nullable=True)


class TapIdAssociation(model_base.BASEV2):

    # Internal mapping between a TAP Service and
    # id to be used by the Agents
    __tablename__ = 'tap_id_associations'
    tap_service_id = sa.Column(sa.String(36),
                               sa.ForeignKey("tap_services.id",
                                             ondelete='SET NULL'),
                               nullable=True)
    taas_id = sa.Column(sa.Integer, primary_key=True, unique=True)
    tap_service = orm.relationship(
        TapService,
        backref=orm.backref("tap_service_id",
                            lazy="joined"),
        primaryjoin='TapService.id==TapIdAssociation.tap_service_id')


class Taas_db_Mixin(taas.TaasPluginBase):

    def _core_plugin(self):
        return directory.get_plugin()

    def _get_tap_service(self, context, id):
        try:
            return model_query.get_by_id(context, TapService, id)
        except exc.NoResultFound:

# Path: neutron_taas/extensions/taas.py
# class TapServiceNotFound(qexception.NotFound):
# class TapFlowNotFound(qexception.NotFound):
# class InvalidDestinationPort(qexception.NotFound):
# class InvalidSourcePort(qexception.NotFound):
# class PortDoesNotBelongToTenant(qexception.NotAuthorized):
# class TapServiceNotBelongToTenant(qexception.NotAuthorized):
# class TapServiceLimitReached(qexception.OverQuota):
# class Taas(extensions.ExtensionDescriptor):
# class TaasPluginBase(service_base.ServicePluginBase):
# RESOURCE_ATTRIBUTE_MAP = {
#     'tap_services': {
#         'id': {'allow_post': False, 'allow_put': False,
#                'validate': {'type:uuid': None}, 'is_visible': True,
#                'primary_key': True},
#         'tenant_id': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:string': None},
#                       'required_by_policy': True, 'is_visible': True},
#         'name': {'allow_post': True, 'allow_put': True,
#                  'validate': {'type:string': None},
#                  'is_visible': True, 'default': ''},
#         'description': {'allow_post': True, 'allow_put': True,
#                         'validate': {'type:string': None},
#                         'is_visible': True, 'default': ''},
#         'port_id': {'allow_post': True, 'allow_put': False,
#                     'validate': {'type:uuid': None},
#                     'is_visible': True},
#         'status': {'allow_post': False, 'allow_put': False,
#                    'is_visible': True}
#     },
#     'tap_flows': {
#         'id': {'allow_post': False, 'allow_put': False,
#                'validate': {'type:uuid': None}, 'is_visible': True,
#                'primary_key': True},
#         'tenant_id': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:string': None},
#                       'required_by_policy': True, 'is_visible': True},
#         'name': {'allow_post': True, 'allow_put': True,
#                  'validate': {'type:string': None},
#                  'is_visible': True, 'default': ''},
#         'description': {'allow_post': True, 'allow_put': True,
#                         'validate': {'type:string': None},
#                         'is_visible': True, 'default': ''},
#         'tap_service_id': {'allow_post': True, 'allow_put': False,
#                            'validate': {'type:uuid': None},
#                            'required_by_policy': True, 'is_visible': True},
#         'source_port': {'allow_post': True, 'allow_put': False,
#                         'validate': {'type:uuid': None},
#                         'required_by_policy': True, 'is_visible': True},
#         'direction': {'allow_post': True, 'allow_put': False,
#                       'validate': {'type:values': direction_enum},
#                       'is_visible': True},
#         'status': {'allow_post': False, 'allow_put': False,
#                    'is_visible': True}
#     }
# }
#     def get_name(cls):
#     def get_alias(cls):
#     def get_description(cls):
#     def get_updated(cls):
#     def get_plugin_interface(cls):
#     def get_resources(cls):
#     def update_attributes_map(self, attributes):
#     def get_extended_resources(self, version):
#     def get_plugin_description(self):
#     def get_plugin_type(cls):
#     def create_tap_service(self, context, tap_service):
#     def delete_tap_service(self, context, id):
#     def get_tap_service(self, context, id, fields=None):
#     def get_tap_services(self, context, filters=None, fields=None,
#                          sorts=None, limit=None, marker=None,
#                          page_reverse=False):
#     def update_tap_service(self, context, id, tap_service):
#     def create_tap_flow(self, context, tap_flow):
#     def get_tap_flow(self, context, id, fields=None):
#     def delete_tap_flow(self, context, id):
#     def get_tap_flows(self, context, filters=None, fields=None,
#                       sorts=None, limit=None, marker=None,
#                       page_reverse=False):
#     def update_tap_flow(self, context, id, tap_flow):


# Path: neutron_taas/db/taas_db.py
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.orm import exc
from neutron_lib import constants
from neutron_lib.db import model_base
from neutron_lib.db import model_query
from neutron_lib.db import utils as db_utils
from neutron_lib.plugins import directory
from neutron_taas.extensions import taas
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils

                       server_default=constants.ACTIVE)
    vlan_filter = sa.Column(sa.String(1024), nullable=True)


class TapIdAssociation(model_base.BASEV2):

    # Internal mapping between a TAP Service and
    # id to be used by the Agents
    __tablename__ = 'tap_id_associations'
    tap_service_id = sa.Column(sa.String(36),
                               sa.ForeignKey("tap_services.id",
                                             ondelete='SET NULL'),
                               nullable=True)
    taas_id = sa.Column(sa.Integer, primary_key=True, unique=True)
    tap_service = orm.relationship(
        TapService,
        backref=orm.backref("tap_service_id",
                            lazy="joined"),
        primaryjoin='TapService.id==TapIdAssociation.tap_service_id')


class Taas_db_Mixin(taas.TaasPluginBase):

    def _core_plugin(self):
        return directory.get_plugin()

    def _get_tap_service(self, context, id):
        try:
            return model_query.get_by_id(context, TapService, id)
        except exc.NoResultFound:

            raise taas.TapServiceNotFound(tap_id=id)