# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/apic_model.py
# def get_current_session():
#     def get_session(self, session=None):
#     def get_contract_for_router(self, router_id):
#     def write_contract_for_router(self, project_id, router_id, session=None):
#     def update_contract_for_router(self, project_id, router_id):
#     def delete_contract_for_router(self, router_id):
#     def add_hostlink(self, host, ifname, ifmac, swid, module, port):
#     def get_hostlinks(self):
#     def get_hostlink(self, host, ifname):
#     def get_hostlinks_for_host(self, host):
#     def get_hostlinks_for_host_switchport(self, host, swid, module, port):
#     def get_hostlinks_for_switchport(self, swid, module, port):
#     def delete_hostlink(self, host, ifname):
#     def get_switches(self):
#     def get_modules_for_switch(self, swid):
#     def get_ports_for_switch_module(self, swid, module):
#     def get_switch_and_port_for_host(self, host):
#     def get_tenant_network_vlan_for_host(self, host):
#     def add_apic_name(self, neutron_id, neutron_type, apic_name,
#                       session=None):
#     def update_apic_name(self, neutron_id, neutron_type, apic_name,
#                          session=None):
#     def get_apic_names(self):
#     def get_apic_name(self, neutron_id, neutron_type):
#     def delete_apic_name(self, neutron_id, session=None):
# class RouterContract(model_base.BASEV2, model_base.HasProject):
# class HostLink(model_base.BASEV2):
# class ApicName(model_base.BASEV2):
# class ApicDbModel(object):


import eventlet
import oslo_messaging
from oslo_concurrency import lockutils
from oslo_db import exception as db_exc
from oslo_log import log as logging
from neutron.common import rpc
from neutron import context as nctx
from neutron.db import api as db_api
from neutron.extensions import providernet as api
from neutron import manager
from neutron.plugins.common import constants
from neutron.plugins.ml2.drivers import type_vlan  # noqa
from neutron.plugins.ml2 import models
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import apic_model
            atenant_id = self.mech_apic.name_mapper.tenant(
                context, network['tenant_id'])
            anetwork_id = self.mech_apic.name_mapper.network(
                context, network['id'])
            seg = None
            if network.get(api.NETWORK_TYPE) == constants.TYPE_VLAN:
                seg = network.get(api.SEGMENTATION_ID)

            if seg:
                self.apic_manager.ensure_path_created_for_port(
                    atenant_id, anetwork_id, host, seg)
            else:
                LOG.warn("Network with empty segmentation id can't be pushed "
                         "on APIC: %s", network['id'])

    def _get_networks_from_host(self, context, plugin, host):
        # Retrieve Plugin Context and core plugin
        bindings = context.session.query(
            models.PortBinding).filter_by(host=host).all()
        port_ids = [x.port_id for x in bindings]
        networks = []
        if port_ids:
            # There are ports bound in that host
            ports = plugin.get_ports(context, {'id': port_ids})
            networks = plugin.get_networks(context, {'id': [x['network_id'] for
                                                            x in ports]})
        return networks

    def _get_hostlinks_for_host(self, host, module, port):
        session = db_api.get_session()

# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/apic_model.py
# def get_current_session():
#     def get_session(self, session=None):
#     def get_contract_for_router(self, router_id):
#     def write_contract_for_router(self, project_id, router_id, session=None):
#     def update_contract_for_router(self, project_id, router_id):
#     def delete_contract_for_router(self, router_id):
#     def add_hostlink(self, host, ifname, ifmac, swid, module, port):
#     def get_hostlinks(self):
#     def get_hostlink(self, host, ifname):
#     def get_hostlinks_for_host(self, host):
#     def get_hostlinks_for_host_switchport(self, host, swid, module, port):
#     def get_hostlinks_for_switchport(self, swid, module, port):
#     def delete_hostlink(self, host, ifname):
#     def get_switches(self):
#     def get_modules_for_switch(self, swid):
#     def get_ports_for_switch_module(self, swid, module):
#     def get_switch_and_port_for_host(self, host):
#     def get_tenant_network_vlan_for_host(self, host):
#     def add_apic_name(self, neutron_id, neutron_type, apic_name,
#                       session=None):
#     def update_apic_name(self, neutron_id, neutron_type, apic_name,
#                          session=None):
#     def get_apic_names(self):
#     def get_apic_name(self, neutron_id, neutron_type):
#     def delete_apic_name(self, neutron_id, session=None):
# class RouterContract(model_base.BASEV2, model_base.HasProject):
# class HostLink(model_base.BASEV2):
# class ApicName(model_base.BASEV2):
# class ApicDbModel(object):


# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/rpc.py
import eventlet
import oslo_messaging
from oslo_concurrency import lockutils
from oslo_db import exception as db_exc
from oslo_log import log as logging
from neutron.common import rpc
from neutron import context as nctx
from neutron.db import api as db_api
from neutron.extensions import providernet as api
from neutron import manager
from neutron.plugins.common import constants
from neutron.plugins.ml2.drivers import type_vlan  # noqa
from neutron.plugins.ml2 import models
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import apic_model

            atenant_id = self.mech_apic.name_mapper.tenant(
                context, network['tenant_id'])
            anetwork_id = self.mech_apic.name_mapper.network(
                context, network['id'])
            seg = None
            if network.get(api.NETWORK_TYPE) == constants.TYPE_VLAN:
                seg = network.get(api.SEGMENTATION_ID)

            if seg:
                self.apic_manager.ensure_path_created_for_port(
                    atenant_id, anetwork_id, host, seg)
            else:
                LOG.warn("Network with empty segmentation id can't be pushed "
                         "on APIC: %s", network['id'])

    def _get_networks_from_host(self, context, plugin, host):
        # Retrieve Plugin Context and core plugin
        bindings = context.session.query(
            models.PortBinding).filter_by(host=host).all()
        port_ids = [x.port_id for x in bindings]
        networks = []
        if port_ids:
            # There are ports bound in that host
            ports = plugin.get_ports(context, {'id': port_ids})
            networks = plugin.get_networks(context, {'id': [x['network_id'] for
                                                            x in ports]})
        return networks

    def _get_hostlinks_for_host(self, host, module, port):
        session = db_api.get_session()

        return session.query(apic_model.HostLink).filter_by(