diff --git a/neutron/db/migration/alembic_migrations/env.py b/neutron/db/migration/alembic_migrations/env.py index 9966f55e797..f90bf43c307 100644 --- a/neutron/db/migration/alembic_migrations/env.py +++ b/neutron/db/migration/alembic_migrations/env.py @@ -20,6 +20,7 @@ from oslo_db.sqlalchemy import session import sqlalchemy as sa from sqlalchemy import event +from neutron.db.migration.alembic_migrations import external from neutron.db.migration.models import head # noqa from neutron.db import model_base @@ -50,6 +51,13 @@ def set_mysql_engine(): model_base.BASEV2.__table_args__['mysql_engine']) +def include_object(object, name, type_, reflected, compare_to): + if type_ == 'table' and name in external.TABLES: + return False + else: + return True + + def run_migrations_offline(): """Run migrations in 'offline' mode. @@ -67,6 +75,7 @@ def run_migrations_offline(): kwargs['url'] = neutron_config.database.connection else: kwargs['dialect_name'] = neutron_config.database.engine + kwargs['include_object'] = include_object context.configure(**kwargs) with context.begin_transaction(): @@ -92,7 +101,8 @@ def run_migrations_online(): connection = engine.connect() context.configure( connection=connection, - target_metadata=target_metadata + target_metadata=target_metadata, + include_object=include_object ) try: diff --git a/neutron/db/migration/alembic_migrations/external.py b/neutron/db/migration/alembic_migrations/external.py new file mode 100644 index 00000000000..412992db5cc --- /dev/null +++ b/neutron/db/migration/alembic_migrations/external.py @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# These tables are in the neutron database, but their models have moved +# to separate repositories. We skip the migration checks for these tables. + +VPNAAS_TABLES = ['vpnservices', 'ipsecpolicies', 'ipsecpeercidrs', + 'ipsec_site_connections', 'cisco_csr_identifier_map', + 'ikepolicies'] + +LBAAS_TABLES = ['vips', 'sessionpersistences', 'pools', 'healthmonitors', + 'poolstatisticss', 'members', 'poolloadbalanceragentbindings', + 'embrane_pool_port', 'poolmonitorassociations'] + +FWAAS_TABLES = ['firewall_rules', 'firewalls', 'firewall_policies'] + +TABLES = (FWAAS_TABLES + LBAAS_TABLES + VPNAAS_TABLES) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 98e178a158b..a05bbb215e8 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -27,6 +27,7 @@ from oslo_db.sqlalchemy import test_base from oslo_db.sqlalchemy import test_migrations import sqlalchemy +from neutron.db.migration.alembic_migrations import external from neutron.db.migration import cli as migration from neutron.db.migration.models import head as head_models @@ -37,26 +38,6 @@ cfg.CONF.import_opt('core_plugin', 'neutron.common.config') CORE_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin' -# These tables are still in the neutron database, but their models have moved -# to the separate advanced services repositories. We skip the migration checks -# for these tables for now. The checks will be re-instated soon in the tests -# for each separate repository. -# TODO(akamyshnikova): delete these lists when the tables are removed from -# neutron database. -EXTERNAL_VPNAAS_TABLES = ['vpnservices', 'ipsecpolicies', 'ipsecpeercidrs', - 'ipsec_site_connections', 'cisco_csr_identifier_map', - 'ikepolicies'] - -EXTERNAL_LBAAS_TABLES = ['vips', 'sessionpersistences', 'pools', - 'healthmonitors', 'poolstatisticss', 'members', - 'poolloadbalanceragentbindings', 'embrane_pool_port', - 'poolmonitorassociations'] - -EXTERNAL_FWAAS_TABLES = ['firewall_rules', 'firewalls', 'firewall_policies'] - -EXTERNAL_TABLES = (EXTERNAL_FWAAS_TABLES + EXTERNAL_LBAAS_TABLES + - EXTERNAL_VPNAAS_TABLES) - class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): '''Test for checking of equality models state and migrations. @@ -150,7 +131,7 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): def include_object(self, object_, name, type_, reflected, compare_to): if type_ == 'table' and (name == 'alembic_version' - or name in EXTERNAL_TABLES): + or name in external.TABLES): return False return super(_TestModelsMigrations, self).include_object(