# Path: apic_ml2/neutron/extensions/cisco_apic_l3.py
# ALIAS = 'cisco-apic-l3'
# USE_ROUTING_CONTEXT = 'apic:use_routing_context'
# EXT_GW_ATTRIBUTES = {
#     USE_ROUTING_CONTEXT: {
#         'allow_post': True, 'allow_put': False,
#         'is_visible': True, 'default': None,
#         'validate': {'type:uuid_or_none': None},
#     }
# }
# EXTENDED_ATTRIBUTES_2_0 = {
#     l3.ROUTERS: dict(EXT_GW_ATTRIBUTES.items())
# }
# class Cisco_apic_l3(extensions.ExtensionDescriptor):
#     def get_name(cls):
#     def get_alias(cls):
#     def get_description(cls):
#     def get_updated(cls):
#     def get_extended_resources(self, version):
# 
# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/extension_db.py
# class NetworkExtensionDb(model_base.BASEV2):
# class RouterExtensionDb(model_base.BASEV2):
# class ExtensionDbMixin(object):
#     def _set_if_not_none(self, res_dict, res_attr, db_attr):
#     def get_network_extn_db(self, session, network_id):
#     def set_network_extn_db(self, session, network_id, res_dict):
#     def get_router_extn_db(self, session, router_id):
#     def set_router_extn_db(self, session, router_id, res_dict):
# 
# Path: apic_ml2/neutron/services/l3_router/apic_driver.py
# LOG = logging.getLogger(__name__)
# class InterTenantRouterInterfaceNotAllowedOnPerTenantContext(n_exc.BadRequest):
# class ApicL3Driver(apic_driver_api.ApicL3DriverBase):
#     def __init__(self, plugin):
#     def aci_mech_driver(self):
#     def _map_names(self, context, tenant_id, router, network, subnet):
#     def _get_port_id_for_router_interface(self, context, router_id, subnet_id):
#     def _add_apic_router_interface(self, context, router_id, interface_info):
#     def add_router_interface_postcommit(self, context, router_id,
#                                         interface_info):
#     def remove_router_interface_precommit(self, context, router_id,
#                                           interface_info):
#     def create_router_postcommit(self, context, router):
#     def delete_router_precommit(self, context, router_id):
#     def update_router_postcommit(self, context, router):
#     def create_floatingip_postcommit(self, context, floatingip):
#     def update_floatingip_precommit(self, context, id, floatingip):
#     def update_floatingip_postcommit(self, context, id, floatingip):
#     def delete_floatingip_precommit(self, context, id):
#     def delete_floatingip_postcommit(self, context, id):
#     def _get_port_mapped_to_floatingip(self, context, fip_id):
#     def _notify_port_update(self, port_id):
#     def _update_floatingip_status(self, context, fip_id):


from neutron.api import extensions
from neutron.common import constants as q_const
from neutron.common import exceptions as n_exc
from neutron.db import common_db_mixin
from neutron.db import extraroute_db
from neutron.db import l3_db
from neutron.db import l3_gwmode_db
from neutron.extensions import l3
from neutron.plugins.common import constants
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy import inspect
from apic_ml2.neutron import extensions as extensions_pkg
from apic_ml2.neutron.extensions import cisco_apic_l3 as l3_ext
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import (
    extension_db as extn_db)
from apic_ml2.neutron.services.l3_router import apic_driver

    def _extend_router_dict_apic(self, router_res, router_db):
        session = inspect(router_db).session
        attr = self.get_router_extn_db(session, router_res['id'])
        if not attr:
            attr = {l3_ext.USE_ROUTING_CONTEXT: None}
        router_res.update(attr)
        LOG.debug("APIC L3 Plugin extending router dict: %s", router_res)

    common_db_mixin.CommonDbMixin.register_dict_extend_funcs(
        l3.ROUTERS, ['_extend_router_dict_apic'])

    # Router API

    def create_router(self, context, router):
        r = router['router']
        gw_info = r.pop(l3_db.EXTERNAL_GW_INFO, None)
        tenant_id = self._get_tenant_id_for_create(context, r)
        router_db = self._create_router_db(context, r, tenant_id)
        try:
            if gw_info:
                self._update_router_gw_info(context, router_db['id'],
                                            gw_info, router=router_db)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.exception(_("An exception occurred while creating "
                                "the router: %s"), router)
                self.delete_router(context, router_db.id)
        result = self._make_router_dict(router_db)
        res_dict = {l3_ext.USE_ROUTING_CONTEXT:

# Path: apic_ml2/neutron/extensions/cisco_apic_l3.py
# ALIAS = 'cisco-apic-l3'
# USE_ROUTING_CONTEXT = 'apic:use_routing_context'
# EXT_GW_ATTRIBUTES = {
#     USE_ROUTING_CONTEXT: {
#         'allow_post': True, 'allow_put': False,
#         'is_visible': True, 'default': None,
#         'validate': {'type:uuid_or_none': None},
#     }
# }
# EXTENDED_ATTRIBUTES_2_0 = {
#     l3.ROUTERS: dict(EXT_GW_ATTRIBUTES.items())
# }
# class Cisco_apic_l3(extensions.ExtensionDescriptor):
#     def get_name(cls):
#     def get_alias(cls):
#     def get_description(cls):
#     def get_updated(cls):
#     def get_extended_resources(self, version):
# 
# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/extension_db.py
# class NetworkExtensionDb(model_base.BASEV2):
# class RouterExtensionDb(model_base.BASEV2):
# class ExtensionDbMixin(object):
#     def _set_if_not_none(self, res_dict, res_attr, db_attr):
#     def get_network_extn_db(self, session, network_id):
#     def set_network_extn_db(self, session, network_id, res_dict):
#     def get_router_extn_db(self, session, router_id):
#     def set_router_extn_db(self, session, router_id, res_dict):
# 
# Path: apic_ml2/neutron/services/l3_router/apic_driver.py
# LOG = logging.getLogger(__name__)
# class InterTenantRouterInterfaceNotAllowedOnPerTenantContext(n_exc.BadRequest):
# class ApicL3Driver(apic_driver_api.ApicL3DriverBase):
#     def __init__(self, plugin):
#     def aci_mech_driver(self):
#     def _map_names(self, context, tenant_id, router, network, subnet):
#     def _get_port_id_for_router_interface(self, context, router_id, subnet_id):
#     def _add_apic_router_interface(self, context, router_id, interface_info):
#     def add_router_interface_postcommit(self, context, router_id,
#                                         interface_info):
#     def remove_router_interface_precommit(self, context, router_id,
#                                           interface_info):
#     def create_router_postcommit(self, context, router):
#     def delete_router_precommit(self, context, router_id):
#     def update_router_postcommit(self, context, router):
#     def create_floatingip_postcommit(self, context, floatingip):
#     def update_floatingip_precommit(self, context, id, floatingip):
#     def update_floatingip_postcommit(self, context, id, floatingip):
#     def delete_floatingip_precommit(self, context, id):
#     def delete_floatingip_postcommit(self, context, id):
#     def _get_port_mapped_to_floatingip(self, context, fip_id):
#     def _notify_port_update(self, port_id):
#     def _update_floatingip_status(self, context, fip_id):


# Path: apic_ml2/neutron/services/l3_router/l3_apic.py
from neutron.api import extensions
from neutron.common import constants as q_const
from neutron.common import exceptions as n_exc
from neutron.db import common_db_mixin
from neutron.db import extraroute_db
from neutron.db import l3_db
from neutron.db import l3_gwmode_db
from neutron.extensions import l3
from neutron.plugins.common import constants
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy import inspect
from apic_ml2.neutron import extensions as extensions_pkg
from apic_ml2.neutron.extensions import cisco_apic_l3 as l3_ext
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import (
    extension_db as extn_db)
from apic_ml2.neutron.services.l3_router import apic_driver


    def _extend_router_dict_apic(self, router_res, router_db):
        session = inspect(router_db).session
        attr = self.get_router_extn_db(session, router_res['id'])
        if not attr:
            attr = {l3_ext.USE_ROUTING_CONTEXT: None}
        router_res.update(attr)
        LOG.debug("APIC L3 Plugin extending router dict: %s", router_res)

    common_db_mixin.CommonDbMixin.register_dict_extend_funcs(
        l3.ROUTERS, ['_extend_router_dict_apic'])

    # Router API

    def create_router(self, context, router):
        r = router['router']
        gw_info = r.pop(l3_db.EXTERNAL_GW_INFO, None)
        tenant_id = self._get_tenant_id_for_create(context, r)
        router_db = self._create_router_db(context, r, tenant_id)
        try:
            if gw_info:
                self._update_router_gw_info(context, router_db['id'],
                                            gw_info, router=router_db)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.exception(_("An exception occurred while creating "
                                "the router: %s"), router)
                self.delete_router(context, router_db.id)
        result = self._make_router_dict(router_db)
        res_dict = {l3_ext.USE_ROUTING_CONTEXT:

                    r.get(l3_ext.USE_ROUTING_CONTEXT)}