# Path: networking_odl/db/head.py
# def get_metadata():


from oslo_config import cfg
from sqlalchemy import sql
from sqlalchemy.sql import schema
from neutron.db.migration.alembic_migrations import external
from neutron.db.migration import cli as migration
from neutron.tests.functional.db import test_migrations
from neutron.tests.unit import testlib_api
from networking_odl.db import head
BGPVPN_TABLES = (
    'bgpvpns',
    'bgpvpn_network_associations',
    'bgpvpn_router_associations',
    'ml2_route_target_allocations',
    'sfc_bagpipe_ppg_rtnn_associations',
    'sfc_bagpipe_chain_hops',
)

# Tables from other repos that we depend on but do not manage.
IGNORED_TABLES_MATCH = set(
    FWAAS_TABLES + L2GW_TABLES + BGPVPN_TABLES
)

# EXTERNAL_TABLES should contain all names of tables that are not related to
# current repo.
EXTERNAL_TABLES = set(external.TABLES)

VERSION_TABLE = 'odl_alembic_version'


class _TestModelsMigrationsODL(test_migrations._TestModelsMigrations):
    def db_sync(self, engine):
        self.cfg.config(connection=engine.url, group='database')
        for conf in migration.get_alembic_configs():
            self.alembic_config = conf
            self.alembic_config.neutron_config = cfg.CONF
            migration.do_alembic_command(conf, 'upgrade', 'heads')

    def get_metadata(self):

# Path: networking_odl/db/head.py
# def get_metadata():


# Path: networking_odl/tests/functional/db/test_migrations.py
from oslo_config import cfg
from sqlalchemy import sql
from sqlalchemy.sql import schema
from neutron.db.migration.alembic_migrations import external
from neutron.db.migration import cli as migration
from neutron.tests.functional.db import test_migrations
from neutron.tests.unit import testlib_api
from networking_odl.db import head

BGPVPN_TABLES = (
    'bgpvpns',
    'bgpvpn_network_associations',
    'bgpvpn_router_associations',
    'ml2_route_target_allocations',
    'sfc_bagpipe_ppg_rtnn_associations',
    'sfc_bagpipe_chain_hops',
)

# Tables from other repos that we depend on but do not manage.
IGNORED_TABLES_MATCH = set(
    FWAAS_TABLES + L2GW_TABLES + BGPVPN_TABLES
)

# EXTERNAL_TABLES should contain all names of tables that are not related to
# current repo.
EXTERNAL_TABLES = set(external.TABLES)

VERSION_TABLE = 'odl_alembic_version'


class _TestModelsMigrationsODL(test_migrations._TestModelsMigrations):
    def db_sync(self, engine):
        self.cfg.config(connection=engine.url, group='database')
        for conf in migration.get_alembic_configs():
            self.alembic_config = conf
            self.alembic_config.neutron_config = cfg.CONF
            migration.do_alembic_command(conf, 'upgrade', 'heads')

    def get_metadata(self):

        return head.get_metadata()