From b4276f95260b64aa0ce0e901c7b4fd655636509e Mon Sep 17 00:00:00 2001 From: Salvatore Date: Sat, 30 Aug 2014 01:49:03 +0200 Subject: [PATCH] Remove logic for conditional migrations This patch removes the logic for handling conditional migrations and adjusts all the patches where it was used accordingly. The alembic environment has been update to not send anymore the active plugins list to migrations. This patch also removes the vestigial 'options' parameter which was sent to every migration but always set to None and never used by any migration. Implements blueprint bp/reorganize-migrations Change-Id: I7285e0276b262a9ea5d22c456a5a8cf34c461a0c --- neutron/db/migration/__init__.py | 16 +----- .../db/migration/alembic_migrations/env.py | 14 +----- .../alembic_migrations/l3_init_ops.py | 20 +++++--- .../alembic_migrations/metering_init_ops.py | 6 ++- .../alembic_migrations/ml2_init_ops.py | 22 ++++---- .../alembic_migrations/script.py.mako | 4 +- .../versions/10cd28e692e9_nuage_extraroute.py | 32 +++++------- .../117643811bca_nec_delete_ofc_mapping.py | 18 +++---- .../1421183d533f_nsx_dhcp_metadata.py | 16 +----- .../157a5d299379_ml2_binding_profile.py | 20 +++----- .../versions/19180cf98af6_nsx_gw_devices.py | 18 +++---- .../1b2580001654_nsx_sec_group_mappin.py | 19 +++---- .../1b837a7125a9_cisco_apic_driver.py | 2 +- .../versions/1d6ee1ae5da5_db_healing.py | 4 +- ...5dd1d09b22_set_not_null_fields_lb_stats.py | 11 +--- ...c149aca4_agents_unique_by_type_and_host.py | 27 +++------- .../versions/2026156eab2f_l2_dvr_models.py | 15 +----- ...f57ab_ml2_refactor_for_dynamic_segments.py | 4 +- .../2447ad0e9585_add_ipv6_mode_props.py | 16 +----- .../versions/24c7ea5160d7_cisco_csr_vpnaas.py | 14 ++---- .../versions/27cc183af192_ml2_vnic_type.py | 22 +++----- .../versions/2db5203cb7a9_nuage_floatingip.py | 50 +++++++++++-------- .../2eeaf963a447_floatingip_status.py | 38 +++----------- ...1d7f831a591_add_constraint_for_routerid.py | 4 +- .../327ee5fde2c7_set_innodb_engine.py | 6 +-- .../32f3915891fd_cisco_apic_driver_update.py | 4 +- ...et_length_of_description_field_metering.py | 24 +++------ .../33dd0a9fa487_embrane_lbaas_driver.py | 14 ++---- ...322991f59_nuage_removing_mapping_tables.py | 20 ++------ ...7f7f7c456_l3_extension_distributed_mode.py | 17 +------ .../3b85b693a95f_remove_service_tables.py | 9 ++-- .../versions/3d2585038b95_vmware_nsx.py | 18 +++---- .../3d3cb89d84ee_nsx_switch_mappings.py | 20 ++------ .../492a106273f8_brocade_ml2_mech_dri.py | 16 +----- .../4ca36cfc898c_nsx_router_mappings.py | 18 +++---- ...c2f4_correct_vxlan_endpoint_primary_key.py | 4 +- .../4eca4a84f08a_remove_ml2_cisco_cred_db.py | 30 ++++------- .../50d5ba354c23_ml2_binding_vif_details.py | 15 +++--- .../versions/50e86cb2637a_nsx_mappings.py | 26 +++------- ...1e1_nec_rename_quantum_id_to_neutron_id.py | 15 +++--- .../5446f2a45467_set_server_default.py | 11 ++-- .../54f7549a0e5f_set_not_null_peer_address.py | 4 +- .../versions/5589aa32bf80_l3_dvr_scheduler.py | 16 +----- .../58fe87a01143_cisco_csr_routing.py | 4 +- .../5ac1c354a051_n1kv_segment_alloc.py | 17 +++---- .../6be312499f9_set_not_null_vlan_id_cisco.py | 5 +- .../81c553f3776c_bsn_consistencyhashes.py | 16 +----- ...6d6d9776e2b_cisco_apic_driver_update_l3.py | 4 +- ...cbf1c_unify_nsx_router_extra_attributes.py | 4 +- .../aae5706a396_nuage_provider_networks.py | 4 +- .../abc88c33f74f_lb_stats_needs_bigint.py | 29 ++++------- ...65aa907aec_set_length_of_protocol_field.py | 4 +- ...871c0d5_set_admin_state_up_not_null_ml2.py | 5 +- .../e197124d4b9_add_unique_constrain.py | 25 +++------- .../versions/e766b19a3bb_nuage_initial.py | 13 +++-- .../versions/havana_initial.py | 4 +- .../versions/icehouse_release.py | 10 ++-- neutron/tests/unit/test_db_migration.py | 7 --- 58 files changed, 278 insertions(+), 572 deletions(-) diff --git a/neutron/db/migration/__init__.py b/neutron/db/migration/__init__.py index 56f51f7990..907279bacf 100644 --- a/neutron/db/migration/__init__.py +++ b/neutron/db/migration/__init__.py @@ -20,10 +20,6 @@ from alembic import context from alembic import op import sqlalchemy as sa -OVS_PLUGIN = ('neutron.plugins.openvswitch.ovs_neutron_plugin' - '.OVSNeutronPluginV2') -CISCO_PLUGIN = 'neutron.plugins.cisco.network_plugin.PluginV2' - def skip_if_offline(func): """Decorator for skipping migrations in offline mode.""" @@ -94,16 +90,6 @@ def rename_table_if_exists(old_table_name, new_table_name): op.rename_table(old_table_name, new_table_name) -def should_run(active_plugins, migrate_plugins): - if '*' in migrate_plugins: - return True - else: - if (CISCO_PLUGIN not in migrate_plugins and - OVS_PLUGIN in migrate_plugins): - migrate_plugins.append(CISCO_PLUGIN) - return set(active_plugins) & set(migrate_plugins) - - def alter_enum(table, column, enum_type, nullable): bind = op.get_bind() engine = bind.engine @@ -137,4 +123,4 @@ def create_table_if_not_exist_psql(table_name, values): op.execute("SELECT execute($$CREATE TABLE %(name)s %(columns)s $$) " "WHERE NOT table_exist(%(name)r);" % {'name': table_name, - 'columns': values}) \ No newline at end of file + 'columns': values}) diff --git a/neutron/db/migration/alembic_migrations/env.py b/neutron/db/migration/alembic_migrations/env.py index 9866068b35..924f16f3dd 100644 --- a/neutron/db/migration/alembic_migrations/env.py +++ b/neutron/db/migration/alembic_migrations/env.py @@ -37,10 +37,6 @@ neutron_config = config.neutron_config # This line sets up loggers basically. logging_config.fileConfig(config.config_file_name) -plugin_class_path = neutron_config.core_plugin -active_plugins = [plugin_class_path] -active_plugins += neutron_config.service_plugins - # set the target for 'autogenerate' support target_metadata = model_base.BASEV2.metadata @@ -76,8 +72,7 @@ def run_migrations_offline(): context.configure(**kwargs) with context.begin_transaction(): - context.run_migrations(active_plugins=active_plugins, - options=build_options()) + context.run_migrations() @event.listens_for(sa.Table, 'after_parent_attach') @@ -104,16 +99,11 @@ def run_migrations_online(): try: with context.begin_transaction(): - context.run_migrations(active_plugins=active_plugins, - options=build_options()) + context.run_migrations() finally: connection.close() -def build_options(): - return - - if context.is_offline_mode(): run_migrations_offline() else: diff --git a/neutron/db/migration/alembic_migrations/l3_init_ops.py b/neutron/db/migration/alembic_migrations/l3_init_ops.py index 209163f42a..47e6b4c19e 100644 --- a/neutron/db/migration/alembic_migrations/l3_init_ops.py +++ b/neutron/db/migration/alembic_migrations/l3_init_ops.py @@ -19,6 +19,17 @@ from alembic import op import sqlalchemy as sa +def create_routerroutes(): + op.create_table( + 'routerroutes', + sa.Column('destination', sa.String(length=64), nullable=False), + sa.Column('nexthop', sa.String(length=64), nullable=False), + sa.Column('router_id', sa.String(length=36), nullable=False), + sa.ForeignKeyConstraint(['router_id'], ['routers.id'], + ondelete='CASCADE'), + sa.PrimaryKeyConstraint('destination', 'nexthop', 'router_id')) + + def upgrade(): op.create_table( 'externalnetworks', @@ -55,14 +66,7 @@ def upgrade(): sa.ForeignKeyConstraint(['router_id'], ['routers.id'], ), sa.PrimaryKeyConstraint('id')) - op.create_table( - 'routerroutes', - sa.Column('destination', sa.String(length=64), nullable=False), - sa.Column('nexthop', sa.String(length=64), nullable=False), - sa.Column('router_id', sa.String(length=36), nullable=False), - sa.ForeignKeyConstraint(['router_id'], ['routers.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('destination', 'nexthop', 'router_id')) + create_routerroutes() op.create_table( 'routerl3agentbindings', diff --git a/neutron/db/migration/alembic_migrations/metering_init_ops.py b/neutron/db/migration/alembic_migrations/metering_init_ops.py index 967589ab8d..6f1a81c3e6 100644 --- a/neutron/db/migration/alembic_migrations/metering_init_ops.py +++ b/neutron/db/migration/alembic_migrations/metering_init_ops.py @@ -24,7 +24,7 @@ direction = sa.Enum('ingress', 'egress', name='meteringlabels_direction') -def upgrade(): +def create_meteringlabels(): op.create_table( 'meteringlabels', sa.Column('tenant_id', sa.String(length=255), nullable=True), @@ -33,6 +33,10 @@ def upgrade(): sa.Column('description', sa.String(length=1024), nullable=True), sa.PrimaryKeyConstraint('id')) + +def upgrade(): + create_meteringlabels() + op.create_table( 'meteringlabelrules', sa.Column('id', sa.String(length=36), nullable=False), diff --git a/neutron/db/migration/alembic_migrations/ml2_init_ops.py b/neutron/db/migration/alembic_migrations/ml2_init_ops.py index 06eb076cc8..8302509299 100644 --- a/neutron/db/migration/alembic_migrations/ml2_init_ops.py +++ b/neutron/db/migration/alembic_migrations/ml2_init_ops.py @@ -20,6 +20,18 @@ from alembic import op import sqlalchemy as sa +def create_cisco_ml2_credentials(): + op.create_table( + 'cisco_ml2_credentials', + sa.Column('credential_id', sa.String(length=255), nullable=True), + sa.Column('tenant_id', sa.String(length=255), nullable=False), + sa.Column('credential_name', sa.String(length=255), nullable=False), + sa.Column('user_name', sa.String(length=255), nullable=True), + sa.Column('password', sa.String(length=255), nullable=True), + sa.PrimaryKeyConstraint('tenant_id', 'credential_name'), + ) + + def upgrade(): op.create_table( 'ml2_vlan_allocations', @@ -96,15 +108,7 @@ def upgrade(): sa.PrimaryKeyConstraint('binding_id'), ) - op.create_table( - 'cisco_ml2_credentials', - sa.Column('credential_id', sa.String(length=255), nullable=True), - sa.Column('tenant_id', sa.String(length=255), nullable=False), - sa.Column('credential_name', sa.String(length=255), nullable=False), - sa.Column('user_name', sa.String(length=255), nullable=True), - sa.Column('password', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('tenant_id', 'credential_name'), - ) + create_cisco_ml2_credentials() op.create_table( 'arista_provisioned_nets', diff --git a/neutron/db/migration/alembic_migrations/script.py.mako b/neutron/db/migration/alembic_migrations/script.py.mako index e31a2719e2..fb56a45527 100644 --- a/neutron/db/migration/alembic_migrations/script.py.mako +++ b/neutron/db/migration/alembic_migrations/script.py.mako @@ -30,9 +30,9 @@ import sqlalchemy as sa ${imports if imports else ""} -def upgrade(active_plugins=None, options=None): +def upgrade(): ${upgrades if upgrades else "pass"} -def downgrade(active_plugins=None, options=None): +def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/neutron/db/migration/alembic_migrations/versions/10cd28e692e9_nuage_extraroute.py b/neutron/db/migration/alembic_migrations/versions/10cd28e692e9_nuage_extraroute.py index 5e624d5e67..72b7f21819 100644 --- a/neutron/db/migration/alembic_migrations/versions/10cd28e692e9_nuage_extraroute.py +++ b/neutron/db/migration/alembic_migrations/versions/10cd28e692e9_nuage_extraroute.py @@ -30,9 +30,16 @@ from alembic import op import sqlalchemy as sa from neutron.db import migration +from neutron.db.migration.alembic_migrations import l3_init_ops -def upgrade(active_plugins=None, options=None): +def upgrade(): + + if not migration.schema_has_table('routers'): + # In the database we are migrating from, the configured plugin + # did not create the routers table. + return + op.create_table( 'routerroutes_mapping', sa.Column('router_id', sa.String(length=36), nullable=False), @@ -42,25 +49,10 @@ def upgrade(active_plugins=None, options=None): ) # This table might already exist as it might have been created # if another plugin was configured before the nuage one - if op.get_bind().engine.dialect.name == 'postgresql': - migration.create_table_if_not_exist_psql( - 'routerroutes', - ("(destination VARCHAR(64) NOT NULL," - "nexthop VARCHAR(64) NOT NULL," - "router_id VARCHAR(36) NOT NULL," - "PRIMARY KEY (destination, nexthop, router_id)," - "FOREIGN KEY (router_id) REFERENCES routers (id) " - "ON DELETE CASCADE ON UPDATE CASCADE)")) - else: - op.execute("CREATE TABLE IF NOT EXISTS routerroutes( " - "destination VARCHAR(64) NOT NULL," - "nexthop VARCHAR(64) NOT NULL," - "router_id VARCHAR(36) NOT NULL," - "PRIMARY KEY (destination, nexthop, router_id)," - "FOREIGN KEY (router_id) REFERENCES routers (id) " - "ON DELETE CASCADE ON UPDATE CASCADE)") + if not migration.schema_has_table('routerroutes'): + l3_init_ops.create_routerroutes() -def downgrade(active_plugins=None, options=None): +def downgrade(): # The routerroutes table should not be dropped - op.execute('DROP TABLE IF EXISTS routerroutes_mapping') + op.drop_table('routerroutes_mapping') diff --git a/neutron/db/migration/alembic_migrations/versions/117643811bca_nec_delete_ofc_mapping.py b/neutron/db/migration/alembic_migrations/versions/117643811bca_nec_delete_ofc_mapping.py index 9c49d47716..2e799aa809 100644 --- a/neutron/db/migration/alembic_migrations/versions/117643811bca_nec_delete_ofc_mapping.py +++ b/neutron/db/migration/alembic_migrations/versions/117643811bca_nec_delete_ofc_mapping.py @@ -25,12 +25,6 @@ Create Date: 2014-03-02 05:26:47.073318 revision = '117643811bca' down_revision = '81c553f3776c' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nec.nec_plugin.NECPluginV2' -] - from alembic import op import sqlalchemy as sa from sqlalchemy.ext import compiler as sa_compiler @@ -71,15 +65,17 @@ def visit_insert_from_select(element, compiler, **kw): return sql -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def upgrade(): # Table definitions below are only used for sqlalchemy to generate # SQL statements, so in networks/ports tables only required field # are declared. Note that 'quantum_id' in OFC ID mapping tables # will be renamed in a later patch (bug 1287432). + if not migration.schema_has_table('ofctenants'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create any ofc tables. + return + ofctenants = sa_expr.table( 'ofctenants', sa_expr.column('id'), @@ -178,5 +174,5 @@ def upgrade(active_plugins=None, options=None): op.drop_table('ofcfilters') -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/1421183d533f_nsx_dhcp_metadata.py b/neutron/db/migration/alembic_migrations/versions/1421183d533f_nsx_dhcp_metadata.py index ae1090e06c..05f6788ce3 100644 --- a/neutron/db/migration/alembic_migrations/versions/1421183d533f_nsx_dhcp_metadata.py +++ b/neutron/db/migration/alembic_migrations/versions/1421183d533f_nsx_dhcp_metadata.py @@ -26,23 +26,11 @@ Create Date: 2013-10-11 14:33:37.303215 revision = '1421183d533f' down_revision = '50e86cb2637a' -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.create_table( 'lsn', sa.Column('net_id', @@ -66,5 +54,5 @@ def upgrade(active_plugins=None, options=None): sa.PrimaryKeyConstraint('lsn_port_id')) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/157a5d299379_ml2_binding_profile.py b/neutron/db/migration/alembic_migrations/versions/157a5d299379_ml2_binding_profile.py index b89b4e9248..715c25836c 100644 --- a/neutron/db/migration/alembic_migrations/versions/157a5d299379_ml2_binding_profile.py +++ b/neutron/db/migration/alembic_migrations/versions/157a5d299379_ml2_binding_profile.py @@ -25,26 +25,18 @@ Create Date: 2014-02-13 23:48:25.147279 revision = '157a5d299379' down_revision = '50d5ba354c23' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.ml2.plugin.Ml2Plugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - - op.add_column('ml2_port_bindings', - sa.Column('profile', sa.String(length=4095), - nullable=False, server_default='')) +def upgrade(): + if migration.schema_has_table('ml2_port_bindings'): + op.add_column('ml2_port_bindings', + sa.Column('profile', sa.String(length=4095), + nullable=False, server_default='')) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py b/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py index 6ab788de8a..7a0bb02ca0 100644 --- a/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py +++ b/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py @@ -25,23 +25,17 @@ Create Date: 2014-02-26 02:46:26.151741 revision = '19180cf98af6' down_revision = '117643811bca' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('networkgatewaydevices'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create any nsx tables. return op.create_table( @@ -78,5 +72,5 @@ def upgrade(active_plugins=None, options=None): "gw_dev_ref.network_gateway_id=net_gw.id") -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/1b2580001654_nsx_sec_group_mappin.py b/neutron/db/migration/alembic_migrations/versions/1b2580001654_nsx_sec_group_mappin.py index 9ad216d4a7..602dc2de5b 100644 --- a/neutron/db/migration/alembic_migrations/versions/1b2580001654_nsx_sec_group_mappin.py +++ b/neutron/db/migration/alembic_migrations/versions/1b2580001654_nsx_sec_group_mappin.py @@ -23,24 +23,19 @@ Create Date: 2013-12-27 13:02:42.894648 revision = '1b2580001654' down_revision = 'abc88c33f74f' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('securitygroups'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create the securitygroups table. return + # Create table for security group mappings op.create_table( 'neutron_nsx_security_group_mappings', @@ -55,5 +50,5 @@ def upgrade(active_plugins=None, options=None): "from securitygroups") -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/1b837a7125a9_cisco_apic_driver.py b/neutron/db/migration/alembic_migrations/versions/1b837a7125a9_cisco_apic_driver.py index bcc2281342..1f77d202a2 100644 --- a/neutron/db/migration/alembic_migrations/versions/1b837a7125a9_cisco_apic_driver.py +++ b/neutron/db/migration/alembic_migrations/versions/1b837a7125a9_cisco_apic_driver.py @@ -30,7 +30,7 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.create_table( 'cisco_ml2_apic_epgs', sa.Column('network_id', sa.String(length=255), nullable=False), diff --git a/neutron/db/migration/alembic_migrations/versions/1d6ee1ae5da5_db_healing.py b/neutron/db/migration/alembic_migrations/versions/1d6ee1ae5da5_db_healing.py index cca605bc71..c6752668c1 100644 --- a/neutron/db/migration/alembic_migrations/versions/1d6ee1ae5da5_db_healing.py +++ b/neutron/db/migration/alembic_migrations/versions/1d6ee1ae5da5_db_healing.py @@ -28,9 +28,9 @@ down_revision = '5446f2a45467' from neutron.db.migration.alembic_migrations import heal_script -def upgrade(active_plugins=None, options=None): +def upgrade(): heal_script.heal() -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/1e5dd1d09b22_set_not_null_fields_lb_stats.py b/neutron/db/migration/alembic_migrations/versions/1e5dd1d09b22_set_not_null_fields_lb_stats.py index daa007a095..eceece9448 100644 --- a/neutron/db/migration/alembic_migrations/versions/1e5dd1d09b22_set_not_null_fields_lb_stats.py +++ b/neutron/db/migration/alembic_migrations/versions/1e5dd1d09b22_set_not_null_fields_lb_stats.py @@ -25,20 +25,13 @@ Create Date: 2014-03-17 11:00:35.370618 revision = '1e5dd1d09b22' down_revision = '54f7549a0e5f' -# Change to ['*'] if this migration applies to all plugins - -# This migration will be executed only if the neutron DB schema -# contains the tables for load balancing service plugin. -# This migration will be skipped when executed in offline mode. - - import sqlalchemy as sa from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): migration.alter_column_if_exists( 'poolstatisticss', 'bytes_in', nullable=False, @@ -58,7 +51,7 @@ def upgrade(active_plugins=None, options=None): @migration.skip_if_offline -def downgrade(active_plugins=None, options=None): +def downgrade(): migration.alter_column_if_exists( 'poolstatisticss', 'bytes_in', nullable=True, diff --git a/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py b/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py index d1339853ef..65edfcfac5 100644 --- a/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py +++ b/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py @@ -25,22 +25,6 @@ Create Date: 2013-11-27 18:35:28.148680 revision = '1fcfc149aca4' down_revision = 'e197124d4b9' -migration_for_plugins = [ - 'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2', - 'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2', - 'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2', - 'neutron.plugins.ml2.plugin.Ml2Plugin', - 'neutron.plugins.nec.nec_plugin.NECPluginV2', - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin', - 'neutron.services.loadbalancer.plugin.LoadBalancerPlugin', - 'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2', - 'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2', - 'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin', -] - from alembic import op from neutron.db import migration @@ -50,8 +34,11 @@ TABLE_NAME = 'agents' UC_NAME = 'uniq_agents0agent_type0host' -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table(TABLE_NAME): + # Assume that, in the database we are migrating from, the + # configured plugin did not create the agents table. return op.create_unique_constraint( @@ -61,5 +48,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): - pass \ No newline at end of file +def downgrade(): + pass diff --git a/neutron/db/migration/alembic_migrations/versions/2026156eab2f_l2_dvr_models.py b/neutron/db/migration/alembic_migrations/versions/2026156eab2f_l2_dvr_models.py index 165117d1fd..3b46acd4d6 100644 --- a/neutron/db/migration/alembic_migrations/versions/2026156eab2f_l2_dvr_models.py +++ b/neutron/db/migration/alembic_migrations/versions/2026156eab2f_l2_dvr_models.py @@ -25,20 +25,12 @@ Create Date: 2014-06-23 19:12:43.392912 revision = '2026156eab2f' down_revision = '3927f7f7c456' -migration_for_plugins = [ - '*' -] from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.create_table( 'dvr_host_macs', sa.Column('host', sa.String(length=255), nullable=False), @@ -70,9 +62,6 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def downgrade(): op.drop_table('ml2_dvr_port_bindings') op.drop_table('dvr_host_macs') diff --git a/neutron/db/migration/alembic_migrations/versions/236b90af57ab_ml2_refactor_for_dynamic_segments.py b/neutron/db/migration/alembic_migrations/versions/236b90af57ab_ml2_refactor_for_dynamic_segments.py index 4a4db3d806..7cad62c40b 100644 --- a/neutron/db/migration/alembic_migrations/versions/236b90af57ab_ml2_refactor_for_dynamic_segments.py +++ b/neutron/db/migration/alembic_migrations/versions/236b90af57ab_ml2_refactor_for_dynamic_segments.py @@ -29,13 +29,13 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.add_column('ml2_network_segments', sa.Column('is_dynamic', sa.Boolean(), nullable=False, server_default=sa.sql.false())) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_column('ml2_network_segments', 'is_dynamic') diff --git a/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py b/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py index dc0e7f5a41..2cdfad931e 100644 --- a/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py +++ b/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py @@ -26,23 +26,11 @@ Create Date: 2013-10-23 16:36:44.188904 revision = '2447ad0e9585' down_revision = '33dd0a9fa487' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - '*' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def upgrade(): # Workaround for Alemic bug #89 # https://bitbucket.org/zzzeek/alembic/issue/89 context = op.get_context() @@ -69,5 +57,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/24c7ea5160d7_cisco_csr_vpnaas.py b/neutron/db/migration/alembic_migrations/versions/24c7ea5160d7_cisco_csr_vpnaas.py index 38b5b2efd9..9f6a37aca8 100644 --- a/neutron/db/migration/alembic_migrations/versions/24c7ea5160d7_cisco_csr_vpnaas.py +++ b/neutron/db/migration/alembic_migrations/versions/24c7ea5160d7_cisco_csr_vpnaas.py @@ -23,22 +23,16 @@ revision = '24c7ea5160d7' down_revision = '492a106273f8' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.services.vpn.plugin.VPNDriverPlugin', -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + if not migration.schema_has_table('ipsec_site_connections'): + # The vpnaas service plugin was not configured. return - op.create_table( 'cisco_csr_identifier_map', sa.Column('tenant_id', sa.String(length=255), nullable=True), @@ -53,5 +47,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/27cc183af192_ml2_vnic_type.py b/neutron/db/migration/alembic_migrations/versions/27cc183af192_ml2_vnic_type.py index c2a368ccc3..806568669e 100644 --- a/neutron/db/migration/alembic_migrations/versions/27cc183af192_ml2_vnic_type.py +++ b/neutron/db/migration/alembic_migrations/versions/27cc183af192_ml2_vnic_type.py @@ -25,27 +25,19 @@ Create Date: 2014-02-09 12:19:21.362967 revision = '27cc183af192' down_revision = '4ca36cfc898c' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.ml2.plugin.Ml2Plugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - - op.add_column('ml2_port_bindings', - sa.Column('vnic_type', sa.String(length=64), - nullable=False, - server_default='normal')) +def upgrade(): + if migration.schema_has_table('ml2_port_bindings'): + op.add_column('ml2_port_bindings', + sa.Column('vnic_type', sa.String(length=64), + nullable=False, + server_default='normal')) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/2db5203cb7a9_nuage_floatingip.py b/neutron/db/migration/alembic_migrations/versions/2db5203cb7a9_nuage_floatingip.py index 950caf4896..9a3cd6055d 100644 --- a/neutron/db/migration/alembic_migrations/versions/2db5203cb7a9_nuage_floatingip.py +++ b/neutron/db/migration/alembic_migrations/versions/2db5203cb7a9_nuage_floatingip.py @@ -37,29 +37,35 @@ from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): # These tables will be created even if the nuage plugin is not enabled. # This is fine as they would be created anyway by the healing migration. - op.create_table( - 'nuage_floatingip_pool_mapping', - sa.Column('fip_pool_id', sa.String(length=36), nullable=False), - sa.Column('net_id', sa.String(length=36), nullable=True), - sa.Column('router_id', sa.String(length=36), nullable=True), - sa.ForeignKeyConstraint(['net_id'], ['networks.id'], - ondelete='CASCADE'), - sa.ForeignKeyConstraint(['router_id'], ['routers.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('fip_pool_id'), - ) - op.create_table( - 'nuage_floatingip_mapping', - sa.Column('fip_id', sa.String(length=36), nullable=False), - sa.Column('router_id', sa.String(length=36), nullable=True), - sa.Column('nuage_fip_id', sa.String(length=36), nullable=True), - sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('fip_id'), - ) + if migration.schema_has_table('routers'): + # In the database we are migrating from, the configured plugin + # did not create the routers table. + op.create_table( + 'nuage_floatingip_pool_mapping', + sa.Column('fip_pool_id', sa.String(length=36), nullable=False), + sa.Column('net_id', sa.String(length=36), nullable=True), + sa.Column('router_id', sa.String(length=36), nullable=True), + sa.ForeignKeyConstraint(['net_id'], ['networks.id'], + ondelete='CASCADE'), + sa.ForeignKeyConstraint(['router_id'], ['routers.id'], + ondelete='CASCADE'), + sa.PrimaryKeyConstraint('fip_pool_id'), + ) + if migration.schema_has_table('floatingips'): + # In the database we are migrating from, the configured plugin + # did not create the floatingips table. + op.create_table( + 'nuage_floatingip_mapping', + sa.Column('fip_id', sa.String(length=36), nullable=False), + sa.Column('router_id', sa.String(length=36), nullable=True), + sa.Column('nuage_fip_id', sa.String(length=36), nullable=True), + sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'], + ondelete='CASCADE'), + sa.PrimaryKeyConstraint('fip_id'), + ) migration.rename_table_if_exists('net_partitions', 'nuage_net_partitions') migration.rename_table_if_exists('net_partition_router_mapping', @@ -75,7 +81,7 @@ def upgrade(active_plugins=None, options=None): @migration.skip_if_offline -def downgrade(active_plugins=None, options=None): +def downgrade(): migration.drop_table_if_exists('nuage_floatingip_mapping') migration.drop_table_if_exists('nuage_floatingip_pool_mapping') migration.rename_table_if_exists('nuage_net_partitions', 'net_partitions') diff --git a/neutron/db/migration/alembic_migrations/versions/2eeaf963a447_floatingip_status.py b/neutron/db/migration/alembic_migrations/versions/2eeaf963a447_floatingip_status.py index b760900dcf..fcce7cb297 100644 --- a/neutron/db/migration/alembic_migrations/versions/2eeaf963a447_floatingip_status.py +++ b/neutron/db/migration/alembic_migrations/versions/2eeaf963a447_floatingip_status.py @@ -25,43 +25,19 @@ Create Date: 2014-01-14 11:58:13.754747 revision = '2eeaf963a447' down_revision = 'e766b19a3bb' -# This migration is applied to all L3 capable plugins - -migration_for_plugins = [ - 'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2', - 'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2', - 'neutron.plugins.cisco.network_plugin.PluginV2', - 'neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2', - 'neutron.plugins.embrane.plugins.embrane_ovs_plugin.EmbraneOvsPlugin', - 'neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin', - 'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2', - 'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2', - 'neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2', - 'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin', - 'neutron.plugins.midonet.plugin.MidonetPluginV2', - 'neutron.plugins.ml2.plugin.Ml2Plugin', - 'neutron.plugins.nec.nec_plugin.NECPluginV2', - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.nuage.plugin.NuagePlugin', - 'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2', - 'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2', - 'neutron.plugins.plumgrid.plumgrid_plugin.plumgrid_plugin.' - 'NeutronPluginPLUMgridV2', - 'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin', -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('floatingips'): + # In the database we are migrating from, the configured plugin + # did not create the floatingips table. return + op.add_column('floatingips', sa.Column('last_known_router_id', sa.String(length=36), @@ -72,5 +48,5 @@ def upgrade(active_plugins=None, options=None): nullable=True)) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/31d7f831a591_add_constraint_for_routerid.py b/neutron/db/migration/alembic_migrations/versions/31d7f831a591_add_constraint_for_routerid.py index 8d79d38e95..7deebe0ede 100644 --- a/neutron/db/migration/alembic_migrations/versions/31d7f831a591_add_constraint_for_routerid.py +++ b/neutron/db/migration/alembic_migrations/versions/31d7f831a591_add_constraint_for_routerid.py @@ -43,7 +43,7 @@ fk_names = {'postgresql': 'routerl3agentbindings_ibfk_1'}} -def upgrade(active_plugins=None, options=None): +def upgrade(): # In order to sanitize the data during migration, # the current records in the table need to be verified # and all the duplicate records which violate the PK @@ -72,7 +72,7 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): context = op.get_context() dialect = context.bind.dialect.name diff --git a/neutron/db/migration/alembic_migrations/versions/327ee5fde2c7_set_innodb_engine.py b/neutron/db/migration/alembic_migrations/versions/327ee5fde2c7_set_innodb_engine.py index 8b34c514b3..9c43497fae 100644 --- a/neutron/db/migration/alembic_migrations/versions/327ee5fde2c7_set_innodb_engine.py +++ b/neutron/db/migration/alembic_migrations/versions/327ee5fde2c7_set_innodb_engine.py @@ -34,13 +34,11 @@ TABLES = ['router_extra_attributes', 'dvr_host_macs', 'ml2_dvr_port_bindings', 'csnat_l3_agent_bindings'] -def upgrade(active_plugins=None, options=None): - +def upgrade(): if op.get_bind().dialect.name == 'mysql': for table in TABLES: op.execute("ALTER TABLE %s ENGINE=InnoDB" % table) -def downgrade(active_plugins=None, options=None): - +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/32f3915891fd_cisco_apic_driver_update.py b/neutron/db/migration/alembic_migrations/versions/32f3915891fd_cisco_apic_driver_update.py index 09d914c24b..f96f3c8def 100644 --- a/neutron/db/migration/alembic_migrations/versions/32f3915891fd_cisco_apic_driver_update.py +++ b/neutron/db/migration/alembic_migrations/versions/32f3915891fd_cisco_apic_driver_update.py @@ -28,7 +28,7 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.drop_table('cisco_ml2_apic_port_profiles') @@ -50,7 +50,7 @@ def upgrade(active_plugins=None, options=None): sa.PrimaryKeyConstraint('neutron_id', 'neutron_type')) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_table('cisco_ml2_apic_names') op.drop_table('cisco_ml2_apic_host_links') diff --git a/neutron/db/migration/alembic_migrations/versions/33c3db036fe4_set_length_of_description_field_metering.py b/neutron/db/migration/alembic_migrations/versions/33c3db036fe4_set_length_of_description_field_metering.py index 67dcbc2365..043f79963f 100644 --- a/neutron/db/migration/alembic_migrations/versions/33c3db036fe4_set_length_of_description_field_metering.py +++ b/neutron/db/migration/alembic_migrations/versions/33c3db036fe4_set_length_of_description_field_metering.py @@ -29,26 +29,16 @@ from alembic import op import sqlalchemy as sa from neutron.db import migration +from neutron.db.migration.alembic_migrations import metering_init_ops -def upgrade(active_plugins=None, options=None): - if op.get_bind().engine.dialect.name == 'postgresql': - migration.create_table_if_not_exist_psql( - 'meteringlabels', - "(tenant_id VARCHAR(255) NULL, " - "id VARCHAR(36) PRIMARY KEY NOT NULL, " - "name VARCHAR(255) NULL, " - "description VARCHAR(255) NULL)") +def upgrade(): + if migration.schema_has_table('meteringlabels'): + op.alter_column('meteringlabels', 'description', type_=sa.String(1024), + existing_nullable=True) else: - op.execute("CREATE TABLE IF NOT EXISTS meteringlabels( " - "tenant_id VARCHAR(255) NULL, " - "id VARCHAR(36) PRIMARY KEY NOT NULL, " - "name VARCHAR(255) NULL, " - "description VARCHAR(255) NULL)") - - op.alter_column('meteringlabels', 'description', type_=sa.String(1024), - existing_nullable=True) + metering_init_ops.create_meteringlabels() -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/33dd0a9fa487_embrane_lbaas_driver.py b/neutron/db/migration/alembic_migrations/versions/33dd0a9fa487_embrane_lbaas_driver.py index e58a07f413..1639cd9db2 100644 --- a/neutron/db/migration/alembic_migrations/versions/33dd0a9fa487_embrane_lbaas_driver.py +++ b/neutron/db/migration/alembic_migrations/versions/33dd0a9fa487_embrane_lbaas_driver.py @@ -25,22 +25,16 @@ Create Date: 2014-02-25 00:15:35.567111 revision = '33dd0a9fa487' down_revision = '19180cf98af6' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.services.loadbalancer.plugin.LoadBalancerPlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + if not migration.schema_has_table('pools'): + # The lbaas service plugin was not configured. return - op.create_table( u'embrane_pool_port', sa.Column(u'pool_id', sa.String(length=36), nullable=False), @@ -52,5 +46,5 @@ def upgrade(active_plugins=None, options=None): sa.PrimaryKeyConstraint(u'pool_id')) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/37f322991f59_nuage_removing_mapping_tables.py b/neutron/db/migration/alembic_migrations/versions/37f322991f59_nuage_removing_mapping_tables.py index 2c86547e99..cec1e51847 100644 --- a/neutron/db/migration/alembic_migrations/versions/37f322991f59_nuage_removing_mapping_tables.py +++ b/neutron/db/migration/alembic_migrations/versions/37f322991f59_nuage_removing_mapping_tables.py @@ -25,22 +25,11 @@ Create Date: 2014-07-09 17:25:29.242948 revision = '37f322991f59' down_revision = '2026156eab2f' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - '*' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.drop_table('nuage_floatingip_mapping') op.drop_table('nuage_floatingip_pool_mapping') op.drop_table('nuage_routerroutes_mapping') @@ -48,10 +37,7 @@ def upgrade(active_plugins=None, options=None): op.drop_table('nuage_router_zone_mapping') -def downgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def downgrade(): op.create_table( 'nuage_router_zone_mapping', sa.Column('router_id', sa.String(length=36), nullable=False), @@ -98,4 +84,4 @@ def downgrade(active_plugins=None, options=None): sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('fip_id'), - ) \ No newline at end of file + ) diff --git a/neutron/db/migration/alembic_migrations/versions/3927f7f7c456_l3_extension_distributed_mode.py b/neutron/db/migration/alembic_migrations/versions/3927f7f7c456_l3_extension_distributed_mode.py index 91387213e0..1dc8456aeb 100644 --- a/neutron/db/migration/alembic_migrations/versions/3927f7f7c456_l3_extension_distributed_mode.py +++ b/neutron/db/migration/alembic_migrations/versions/3927f7f7c456_l3_extension_distributed_mode.py @@ -24,21 +24,11 @@ Create Date: 2014-04-02 23:26:19.303633 revision = '3927f7f7c456' down_revision = 'db_healing' -migration_for_plugins = [ - '*' -] - - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.create_table( 'router_extra_attributes', sa.Column('router_id', sa.String(length=36), nullable=False), @@ -52,8 +42,5 @@ def upgrade(active_plugins=None, options=None): "False as distributed from routers") -def downgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def downgrade(): op.drop_table('router_extra_attributes') diff --git a/neutron/db/migration/alembic_migrations/versions/3b85b693a95f_remove_service_tables.py b/neutron/db/migration/alembic_migrations/versions/3b85b693a95f_remove_service_tables.py index a0fc50d6cd..e87bcf5042 100644 --- a/neutron/db/migration/alembic_migrations/versions/3b85b693a95f_remove_service_tables.py +++ b/neutron/db/migration/alembic_migrations/versions/3b85b693a95f_remove_service_tables.py @@ -31,13 +31,16 @@ down_revision = '327ee5fde2c7' from alembic import op +from neutron.db import migration -def upgrade(active_plugins=None, options=None): + +def upgrade(): for table in ('servicedefinitions', 'servicetypes'): - op.execute("DROP TABLE IF EXISTS %s" % table) + if migration.schema_has_table(table): + op.drop_table(table) -def downgrade(active_plugins=None, options=None): +def downgrade(): """Don't create the tables These tables would be created during downgrade at correct place in diff --git a/neutron/db/migration/alembic_migrations/versions/3d2585038b95_vmware_nsx.py b/neutron/db/migration/alembic_migrations/versions/3d2585038b95_vmware_nsx.py index 3fd3311985..27f73f9606 100644 --- a/neutron/db/migration/alembic_migrations/versions/3d2585038b95_vmware_nsx.py +++ b/neutron/db/migration/alembic_migrations/versions/3d2585038b95_vmware_nsx.py @@ -25,22 +25,16 @@ Create Date: 2014-02-11 18:18:34.319031 revision = '3d2585038b95' down_revision = '157a5d299379' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('nvp_network_bindings'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create any nvp tables. return op.rename_table('nvp_network_bindings', 'tz_network_bindings') @@ -52,5 +46,5 @@ def upgrade(active_plugins=None, options=None): "RENAME TO tz_network_bindings_binding_type;") -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/3d3cb89d84ee_nsx_switch_mappings.py b/neutron/db/migration/alembic_migrations/versions/3d3cb89d84ee_nsx_switch_mappings.py index cc3b529f4e..2d600bca87 100644 --- a/neutron/db/migration/alembic_migrations/versions/3d3cb89d84ee_nsx_switch_mappings.py +++ b/neutron/db/migration/alembic_migrations/versions/3d3cb89d84ee_nsx_switch_mappings.py @@ -23,25 +23,11 @@ Create Date: 2014-01-07 15:37:41.323020 revision = '3d3cb89d84ee' down_revision = '1421183d533f' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): # Create table for network mappings op.create_table( 'neutron_nsx_network_mappings', @@ -54,5 +40,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): - pass \ No newline at end of file +def downgrade(): + pass diff --git a/neutron/db/migration/alembic_migrations/versions/492a106273f8_brocade_ml2_mech_dri.py b/neutron/db/migration/alembic_migrations/versions/492a106273f8_brocade_ml2_mech_dri.py index ed62465068..41186d4475 100644 --- a/neutron/db/migration/alembic_migrations/versions/492a106273f8_brocade_ml2_mech_dri.py +++ b/neutron/db/migration/alembic_migrations/versions/492a106273f8_brocade_ml2_mech_dri.py @@ -25,23 +25,11 @@ Create Date: 2014-03-03 15:35:46.974523 revision = '492a106273f8' down_revision = '2eeaf963a447' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.ml2.plugin.Ml2Plugin' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def upgrade(): op.create_table( 'ml2_brocadenetworks', sa.Column('id', sa.String(length=36), nullable=False), @@ -63,5 +51,5 @@ def upgrade(active_plugins=None, options=None): sa.ForeignKeyConstraint(['network_id'], ['ml2_brocadenetworks.id'])) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/4ca36cfc898c_nsx_router_mappings.py b/neutron/db/migration/alembic_migrations/versions/4ca36cfc898c_nsx_router_mappings.py index 1e9e9d74dc..ece4a55c71 100644 --- a/neutron/db/migration/alembic_migrations/versions/4ca36cfc898c_nsx_router_mappings.py +++ b/neutron/db/migration/alembic_migrations/versions/4ca36cfc898c_nsx_router_mappings.py @@ -23,23 +23,17 @@ Create Date: 2014-01-08 10:41:43.373031 revision = '4ca36cfc898c' down_revision = '3d3cb89d84ee' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('routers'): + # In the database we are migrating from, the configured plugin + # did not create the routers table. return # Create table for router/lrouter mappings @@ -57,5 +51,5 @@ def upgrade(active_plugins=None, options=None): "from routers") -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/4eba2f05c2f4_correct_vxlan_endpoint_primary_key.py b/neutron/db/migration/alembic_migrations/versions/4eba2f05c2f4_correct_vxlan_endpoint_primary_key.py index c6fc2832cd..e885921b17 100644 --- a/neutron/db/migration/alembic_migrations/versions/4eba2f05c2f4_correct_vxlan_endpoint_primary_key.py +++ b/neutron/db/migration/alembic_migrations/versions/4eba2f05c2f4_correct_vxlan_endpoint_primary_key.py @@ -33,11 +33,11 @@ TABLE_NAME = 'ml2_vxlan_endpoints' PK_NAME = 'ml2_vxlan_endpoints_pkey' -def upgrade(active_plugins=None, options=None): +def upgrade(): op.drop_constraint(PK_NAME, TABLE_NAME, type_='primary') op.create_primary_key(PK_NAME, TABLE_NAME, cols=['ip_address']) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_constraint(PK_NAME, TABLE_NAME, type_='primary') op.create_primary_key(PK_NAME, TABLE_NAME, cols=['ip_address', 'udp_port']) diff --git a/neutron/db/migration/alembic_migrations/versions/4eca4a84f08a_remove_ml2_cisco_cred_db.py b/neutron/db/migration/alembic_migrations/versions/4eca4a84f08a_remove_ml2_cisco_cred_db.py index 465441995f..955a0f7dc6 100644 --- a/neutron/db/migration/alembic_migrations/versions/4eca4a84f08a_remove_ml2_cisco_cred_db.py +++ b/neutron/db/migration/alembic_migrations/versions/4eca4a84f08a_remove_ml2_cisco_cred_db.py @@ -29,27 +29,17 @@ down_revision = '33c3db036fe4' from alembic import op from neutron.db import migration +from neutron.db.migration.alembic_migrations import ml2_init_ops -def upgrade(active_plugins=None, options=None): - op.execute('DROP TABLE IF EXISTS cisco_ml2_credentials') +TABLE = 'cisco_ml2_credentials' -def downgrade(active_plugins=None, options=None): - if op.get_bind().engine.dialect.name == 'postgresql': - migration.create_table_if_not_exist_psql( - 'cisco_ml2_credentials', - ("(credential_id VARCHAR(255) NULL," - "tenant_id VARCHAR(255) NOT NULL," - "credential_name VARCHAR(255) NOT NULL," - "user_name VARCHAR(255) NULL," - "password VARCHAR(255) NULL," - "PRIMARY KEY (tenant_id, credential_name))")) - else: - op.execute('CREATE TABLE IF NOT EXISTS cisco_ml2_credentials( ' - 'credential_id VARCHAR(255) NULL,' - 'tenant_id VARCHAR(255) NOT NULL,' - 'credential_name VARCHAR(255) NOT NULL,' - 'user_name VARCHAR(255) NULL,' - 'password VARCHAR(255) NULL,' - 'PRIMARY KEY (tenant_id, credential_name))') +def upgrade(): + if migration.schema_has_table(TABLE): + op.drop_table(TABLE) + + +def downgrade(): + if not migration.schema_has_table(TABLE): + ml2_init_ops.create_cisco_ml2_credentials() diff --git a/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py b/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py index 1f89cf32ac..a1a79841cb 100644 --- a/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py +++ b/neutron/db/migration/alembic_migrations/versions/50d5ba354c23_ml2_binding_vif_details.py @@ -25,20 +25,17 @@ Create Date: 2014-02-11 23:21:59.577972 revision = '50d5ba354c23' down_revision = '27cc183af192' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.ml2.plugin.Ml2Plugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('ml2_port_bindings'): + # In the database we are migrating from, the configured plugin + # did not create the ml2_port_bindings table. return op.add_column('ml2_port_bindings', @@ -67,5 +64,5 @@ def upgrade(active_plugins=None, options=None): op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')") -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/50e86cb2637a_nsx_mappings.py b/neutron/db/migration/alembic_migrations/versions/50e86cb2637a_nsx_mappings.py index 2d081bdf02..4b9b09c925 100644 --- a/neutron/db/migration/alembic_migrations/versions/50e86cb2637a_nsx_mappings.py +++ b/neutron/db/migration/alembic_migrations/versions/50e86cb2637a_nsx_mappings.py @@ -25,25 +25,13 @@ Create Date: 2013-10-26 14:37:30.012149 revision = '50e86cb2637a' down_revision = '1fcfc149aca4' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', - 'neutron.plugins.vmware.plugin.NsxPlugin', - 'neutron.plugins.vmware.plugin.NsxServicePlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def upgrade(): op.create_table('neutron_nsx_port_mappings', sa.Column('neutron_id', sa.String(length=36), nullable=False), @@ -55,11 +43,13 @@ def upgrade(active_plugins=None, options=None): ondelete='CASCADE'), sa.PrimaryKeyConstraint('neutron_id')) - op.execute("INSERT INTO neutron_nsx_port_mappings SELECT quantum_id as " - "neutron_id, nvp_id as nsx_port_id, null as nsx_switch_id from" - " quantum_nvp_port_mapping") - op.drop_table('quantum_nvp_port_mapping') + if migration.schema_has_table('quantum_nvp_port_mapping'): + op.execute( + "INSERT INTO neutron_nsx_port_mappings SELECT quantum_id as " + "neutron_id, nvp_id as nsx_port_id, null as nsx_switch_id from" + " quantum_nvp_port_mapping") + op.drop_table('quantum_nvp_port_mapping') -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/538732fa21e1_nec_rename_quantum_id_to_neutron_id.py b/neutron/db/migration/alembic_migrations/versions/538732fa21e1_nec_rename_quantum_id_to_neutron_id.py index ad3a347892..816b1c8176 100644 --- a/neutron/db/migration/alembic_migrations/versions/538732fa21e1_nec_rename_quantum_id_to_neutron_id.py +++ b/neutron/db/migration/alembic_migrations/versions/538732fa21e1_nec_rename_quantum_id_to_neutron_id.py @@ -25,20 +25,17 @@ Create Date: 2014-03-04 05:43:33.660601 revision = '538732fa21e1' down_revision = '2447ad0e9585' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.nec.nec_plugin.NECPluginV2' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('ofctenantmappings'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create any ofc tables. return for table in ['ofctenantmappings', 'ofcnetworkmappings', @@ -51,5 +48,5 @@ def upgrade(active_plugins=None, options=None): existing_nullable=False) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/5446f2a45467_set_server_default.py b/neutron/db/migration/alembic_migrations/versions/5446f2a45467_set_server_default.py index 9c9f94c2e9..22afd3fff4 100644 --- a/neutron/db/migration/alembic_migrations/versions/5446f2a45467_set_server_default.py +++ b/neutron/db/migration/alembic_migrations/versions/5446f2a45467_set_server_default.py @@ -29,7 +29,6 @@ down_revision = '2db5203cb7a9' import sqlalchemy as sa import sqlalchemy.sql - from neutron.db import migration from neutron.plugins.cisco.common import cisco_constants @@ -50,16 +49,16 @@ from neutron.plugins.cisco.common import cisco_constants # This migration will be skipped when executed offline mode. -def upgrade(active_plugins=None, options=None): - run(active_plugins, True) +def upgrade(): + run(True) -def downgrade(active_plugins=None, options=None): - run(active_plugins, None) +def downgrade(): + run() @migration.skip_if_offline -def run(active_plugins, default): +def run(default=None): set_default_ml2(default) set_default_mlnx(default) set_default_brocade(default) diff --git a/neutron/db/migration/alembic_migrations/versions/54f7549a0e5f_set_not_null_peer_address.py b/neutron/db/migration/alembic_migrations/versions/54f7549a0e5f_set_not_null_peer_address.py index c3ce00b033..73c6d01690 100644 --- a/neutron/db/migration/alembic_migrations/versions/54f7549a0e5f_set_not_null_peer_address.py +++ b/neutron/db/migration/alembic_migrations/versions/54f7549a0e5f_set_not_null_peer_address.py @@ -36,7 +36,7 @@ from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): migration.alter_column_if_exists( 'ipsec_site_connections', 'peer_address', existing_type=sa.String(255), @@ -44,7 +44,7 @@ def upgrade(active_plugins=None, options=None): @migration.skip_if_offline -def downgrade(active_plugins=None, options=None): +def downgrade(): migration.alter_column_if_exists( 'ipsec_site_connections', 'peer_address', nullable=True, diff --git a/neutron/db/migration/alembic_migrations/versions/5589aa32bf80_l3_dvr_scheduler.py b/neutron/db/migration/alembic_migrations/versions/5589aa32bf80_l3_dvr_scheduler.py index a2e6673e9b..2386cdd41e 100644 --- a/neutron/db/migration/alembic_migrations/versions/5589aa32bf80_l3_dvr_scheduler.py +++ b/neutron/db/migration/alembic_migrations/versions/5589aa32bf80_l3_dvr_scheduler.py @@ -25,20 +25,11 @@ Create Date: 2014-07-7 11:00:43.392912 revision = '5589aa32bf80' down_revision = '31d7f831a591' -migration_for_plugins = [ - '*' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.create_table( 'csnat_l3_agent_bindings', sa.Column('router_id', sa.String(length=36), nullable=False), @@ -55,8 +46,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - +def downgrade(): op.drop_table('csnat_l3_agent_bindings') diff --git a/neutron/db/migration/alembic_migrations/versions/58fe87a01143_cisco_csr_routing.py b/neutron/db/migration/alembic_migrations/versions/58fe87a01143_cisco_csr_routing.py index 34ee0ee9ea..a586d58aab 100644 --- a/neutron/db/migration/alembic_migrations/versions/58fe87a01143_cisco_csr_routing.py +++ b/neutron/db/migration/alembic_migrations/versions/58fe87a01143_cisco_csr_routing.py @@ -29,7 +29,7 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.create_table('cisco_hosting_devices', sa.Column('tenant_id', sa.String(length=255), nullable=True), sa.Column('id', sa.String(length=36), nullable=False), @@ -73,7 +73,7 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_table('cisco_router_mappings') op.drop_table('cisco_port_mappings') op.drop_table('cisco_hosting_devices') diff --git a/neutron/db/migration/alembic_migrations/versions/5ac1c354a051_n1kv_segment_alloc.py b/neutron/db/migration/alembic_migrations/versions/5ac1c354a051_n1kv_segment_alloc.py index 09af7f8335..b606faa1a8 100644 --- a/neutron/db/migration/alembic_migrations/versions/5ac1c354a051_n1kv_segment_alloc.py +++ b/neutron/db/migration/alembic_migrations/versions/5ac1c354a051_n1kv_segment_alloc.py @@ -25,20 +25,17 @@ Create Date: 2014-03-05 17:36:52.952608 revision = '5ac1c354a051' down_revision = '538732fa21e1' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.cisco.network_plugin.PluginV2' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('cisco_n1kv_vlan_allocations'): + # Assume that, in the database we are migrating from, the + # configured plugin did not create any n1kv tables. return op.add_column( @@ -69,5 +66,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): - pass \ No newline at end of file +def downgrade(): + pass diff --git a/neutron/db/migration/alembic_migrations/versions/6be312499f9_set_not_null_vlan_id_cisco.py b/neutron/db/migration/alembic_migrations/versions/6be312499f9_set_not_null_vlan_id_cisco.py index 72bf07d015..b4b30c7535 100644 --- a/neutron/db/migration/alembic_migrations/versions/6be312499f9_set_not_null_vlan_id_cisco.py +++ b/neutron/db/migration/alembic_migrations/versions/6be312499f9_set_not_null_vlan_id_cisco.py @@ -31,12 +31,11 @@ down_revision = 'd06e871c0d5' import sqlalchemy as sa - from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): migration.alter_column_if_exists( 'cisco_nexusport_bindings', 'vlan_id', nullable=False, @@ -44,7 +43,7 @@ def upgrade(active_plugins=None, options=None): @migration.skip_if_offline -def downgrade(active_plugins=None, options=None): +def downgrade(): migration.alter_column_if_exists( 'cisco_nexusport_bindings', 'vlan_id', nullable=True, diff --git a/neutron/db/migration/alembic_migrations/versions/81c553f3776c_bsn_consistencyhashes.py b/neutron/db/migration/alembic_migrations/versions/81c553f3776c_bsn_consistencyhashes.py index f24c57bd31..a2d3d0f481 100644 --- a/neutron/db/migration/alembic_migrations/versions/81c553f3776c_bsn_consistencyhashes.py +++ b/neutron/db/migration/alembic_migrations/versions/81c553f3776c_bsn_consistencyhashes.py @@ -25,23 +25,11 @@ Create Date: 2014-02-26 18:56:00.402855 revision = '81c553f3776c' down_revision = '24c7ea5160d7' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2', - 'neutron.plugins.ml2.plugin.Ml2Plugin' -] - from alembic import op import sqlalchemy as sa -from neutron.db import migration - - -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return +def upgrade(): op.create_table( 'consistencyhashes', sa.Column('hash_id', sa.String(255), primary_key=True), @@ -49,5 +37,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/86d6d9776e2b_cisco_apic_driver_update_l3.py b/neutron/db/migration/alembic_migrations/versions/86d6d9776e2b_cisco_apic_driver_update_l3.py index d753b33fa9..b5a196382c 100644 --- a/neutron/db/migration/alembic_migrations/versions/86d6d9776e2b_cisco_apic_driver_update_l3.py +++ b/neutron/db/migration/alembic_migrations/versions/86d6d9776e2b_cisco_apic_driver_update_l3.py @@ -30,7 +30,7 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.drop_table('cisco_ml2_apic_contracts') op.drop_table('cisco_ml2_apic_epgs') @@ -43,7 +43,7 @@ def upgrade(active_plugins=None, options=None): sa.PrimaryKeyConstraint('router_id')) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_table('cisco_ml2_apic_contracts') diff --git a/neutron/db/migration/alembic_migrations/versions/884573acbf1c_unify_nsx_router_extra_attributes.py b/neutron/db/migration/alembic_migrations/versions/884573acbf1c_unify_nsx_router_extra_attributes.py index 2d1938b9ac..15e6e670d3 100644 --- a/neutron/db/migration/alembic_migrations/versions/884573acbf1c_unify_nsx_router_extra_attributes.py +++ b/neutron/db/migration/alembic_migrations/versions/884573acbf1c_unify_nsx_router_extra_attributes.py @@ -47,7 +47,7 @@ def _migrate_data(old_table, new_table): {'new_table': new_table, 'old_table': old_table}) -def upgrade(active_plugins=None, options=None): +def upgrade(): op.add_column('router_extra_attributes', sa.Column('service_router', sa.Boolean(), nullable=False, @@ -56,7 +56,7 @@ def upgrade(active_plugins=None, options=None): op.drop_table('nsxrouterextattributess') -def downgrade(active_plugins=None, options=None): +def downgrade(): op.create_table( 'nsxrouterextattributess', sa.Column('router_id', sa.String(length=36), nullable=False), diff --git a/neutron/db/migration/alembic_migrations/versions/aae5706a396_nuage_provider_networks.py b/neutron/db/migration/alembic_migrations/versions/aae5706a396_nuage_provider_networks.py index 56d5d88b19..bf66730769 100644 --- a/neutron/db/migration/alembic_migrations/versions/aae5706a396_nuage_provider_networks.py +++ b/neutron/db/migration/alembic_migrations/versions/aae5706a396_nuage_provider_networks.py @@ -28,7 +28,7 @@ from alembic import op import sqlalchemy as sa -def upgrade(active_plugins=None, options=None): +def upgrade(): op.create_table( 'nuage_provider_net_bindings', sa.Column('network_id', sa.String(length=36), nullable=False), @@ -41,5 +41,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): op.drop_table('nuage_provider_net_bindings') diff --git a/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py b/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py index 7d8e280b12..5a894eea94 100644 --- a/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py +++ b/neutron/db/migration/alembic_migrations/versions/abc88c33f74f_lb_stats_needs_bigint.py @@ -25,11 +25,6 @@ Create Date: 2014-02-24 20:14:59.577972 revision = 'abc88c33f74f' down_revision = '3d2585038b95' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.services.loadbalancer.plugin.LoadBalancerPlugin' -] from alembic import op import sqlalchemy as sa @@ -37,19 +32,17 @@ import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - - op.alter_column('poolstatisticss', 'bytes_in', - type_=sa.BigInteger(), existing_type=sa.Integer()) - op.alter_column('poolstatisticss', 'bytes_out', - type_=sa.BigInteger(), existing_type=sa.Integer()) - op.alter_column('poolstatisticss', 'active_connections', - type_=sa.BigInteger(), existing_type=sa.Integer()) - op.alter_column('poolstatisticss', 'total_connections', - type_=sa.BigInteger(), existing_type=sa.Integer()) +def upgrade(): + if migration.schema_has_table('poolstatisticss'): + op.alter_column('poolstatisticss', 'bytes_in', + type_=sa.BigInteger(), existing_type=sa.Integer()) + op.alter_column('poolstatisticss', 'bytes_out', + type_=sa.BigInteger(), existing_type=sa.Integer()) + op.alter_column('poolstatisticss', 'active_connections', + type_=sa.BigInteger(), existing_type=sa.Integer()) + op.alter_column('poolstatisticss', 'total_connections', + type_=sa.BigInteger(), existing_type=sa.Integer()) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/b65aa907aec_set_length_of_protocol_field.py b/neutron/db/migration/alembic_migrations/versions/b65aa907aec_set_length_of_protocol_field.py index df55b84107..508ac09a12 100644 --- a/neutron/db/migration/alembic_migrations/versions/b65aa907aec_set_length_of_protocol_field.py +++ b/neutron/db/migration/alembic_migrations/versions/b65aa907aec_set_length_of_protocol_field.py @@ -35,12 +35,12 @@ from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): migration.alter_column_if_exists( 'firewall_rules', 'protocol', type_=sa.String(40), existing_nullable=True) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/d06e871c0d5_set_admin_state_up_not_null_ml2.py b/neutron/db/migration/alembic_migrations/versions/d06e871c0d5_set_admin_state_up_not_null_ml2.py index b8e8eb4d60..a1b5e20712 100644 --- a/neutron/db/migration/alembic_migrations/versions/d06e871c0d5_set_admin_state_up_not_null_ml2.py +++ b/neutron/db/migration/alembic_migrations/versions/d06e871c0d5_set_admin_state_up_not_null_ml2.py @@ -32,12 +32,11 @@ down_revision = '4eca4a84f08a' import sqlalchemy as sa - from neutron.db import migration @migration.skip_if_offline -def upgrade(active_plugins=None, options=None): +def upgrade(): migration.alter_column_if_exists( 'ml2_brocadeports', 'admin_state_up', nullable=False, @@ -45,7 +44,7 @@ def upgrade(active_plugins=None, options=None): @migration.skip_if_offline -def downgrade(active_plugins=None, options=None): +def downgrade(): migration.alter_column_if_exists( 'ml2_brocadeports', 'admin_state_up', nullable=True, diff --git a/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py b/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py index b52cbd73fd..1ed62265cc 100644 --- a/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py +++ b/neutron/db/migration/alembic_migrations/versions/e197124d4b9_add_unique_constrain.py @@ -25,13 +25,6 @@ Create Date: 2013-11-17 10:09:37.728903 revision = 'e197124d4b9' down_revision = 'havana' -# Change to ['*'] if this migration applies to all plugins - -migration_for_plugins = [ - 'neutron.services.loadbalancer.plugin.LoadBalancerPlugin', - 'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin', -] - from alembic import op from neutron.db import migration @@ -41,16 +34,14 @@ CONSTRAINT_NAME = 'uniq_member0pool_id0address0port' TABLE_NAME = 'members' -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): - return - - op.create_unique_constraint( - name=CONSTRAINT_NAME, - source=TABLE_NAME, - local_cols=['pool_id', 'address', 'protocol_port'] - ) +def upgrade(): + if migration.schema_has_table(TABLE_NAME): + op.create_unique_constraint( + name=CONSTRAINT_NAME, + source=TABLE_NAME, + local_cols=['pool_id', 'address', 'protocol_port'] + ) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass \ No newline at end of file diff --git a/neutron/db/migration/alembic_migrations/versions/e766b19a3bb_nuage_initial.py b/neutron/db/migration/alembic_migrations/versions/e766b19a3bb_nuage_initial.py index e21d2dbfbd..a8ae7316dc 100644 --- a/neutron/db/migration/alembic_migrations/versions/e766b19a3bb_nuage_initial.py +++ b/neutron/db/migration/alembic_migrations/versions/e766b19a3bb_nuage_initial.py @@ -25,18 +25,17 @@ Create Date: 2014-02-14 18:03:14.841064 revision = 'e766b19a3bb' down_revision = '1b2580001654' -migration_for_plugins = [ - 'neutron.plugins.nuage.plugin.NuagePlugin' -] - from alembic import op import sqlalchemy as sa from neutron.db import migration -def upgrade(active_plugins=None, options=None): - if not migration.should_run(active_plugins, migration_for_plugins): +def upgrade(): + + if not migration.schema_has_table('routers'): + # In the database we are migrating from, the configured plugin + # did not create the routers table. return op.create_table( @@ -95,5 +94,5 @@ def upgrade(active_plugins=None, options=None): ) -def downgrade(active_plugins=None, options=None): +def downgrade(): pass diff --git a/neutron/db/migration/alembic_migrations/versions/havana_initial.py b/neutron/db/migration/alembic_migrations/versions/havana_initial.py index bd213001e5..995856a671 100644 --- a/neutron/db/migration/alembic_migrations/versions/havana_initial.py +++ b/neutron/db/migration/alembic_migrations/versions/havana_initial.py @@ -47,7 +47,7 @@ from neutron.db.migration.alembic_migrations import vmware_init_ops from neutron.db.migration.alembic_migrations import vpn_init_ops -def upgrade(active_plugins=None, options=None): +def upgrade(): agent_init_ops.upgrade() core_init_ops.upgrade() l3_init_ops.upgrade() @@ -70,7 +70,7 @@ def upgrade(active_plugins=None, options=None): vmware_init_ops.upgrade() -def downgrade(active_plugins=None, options=None): +def downgrade(): vmware_init_ops.downgrade() ryu_init_ops.downgrade() other_plugins_init_ops.downgrade() diff --git a/neutron/db/migration/alembic_migrations/versions/icehouse_release.py b/neutron/db/migration/alembic_migrations/versions/icehouse_release.py index 5b41d8df28..5d8d441c02 100644 --- a/neutron/db/migration/alembic_migrations/versions/icehouse_release.py +++ b/neutron/db/migration/alembic_migrations/versions/icehouse_release.py @@ -25,17 +25,13 @@ Create Date: 2013-03-28 00:00:00.000000 revision = 'icehouse' down_revision = '5ac1c354a051' -# Change to ['*'] if this migration applies to all plugins -migration_for_plugins = ['*'] - - -def upgrade(active_plugins=None, options=None): +def upgrade(): """A no-op migration for marking the Icehouse release.""" pass -def downgrade(active_plugins=None, options=None): +def downgrade(): # We are purging all downgrade methods from icehouse to havana because: # 1) havana is going to become unsupported during Kilo cycle. # 2) most people will upgrade from icehouse, while a minor percentage @@ -44,4 +40,4 @@ def downgrade(active_plugins=None, options=None): # See discussion in https://review.openstack.org/109952 for details raise NotImplementedError("Downgrade from icehouse to havana not " - "supported") \ No newline at end of file + "supported") diff --git a/neutron/tests/unit/test_db_migration.py b/neutron/tests/unit/test_db_migration.py index ca505944cc..5d6dd83ee3 100644 --- a/neutron/tests/unit/test_db_migration.py +++ b/neutron/tests/unit/test_db_migration.py @@ -35,13 +35,6 @@ class TestDbMigration(base.BaseTestCase): self.mock_sa_inspector = mock.patch( 'sqlalchemy.engine.reflection.Inspector').start() - def test_should_run_plugin_in_list(self): - self.assertTrue(migration.should_run(['foo'], ['foo', 'bar'])) - self.assertFalse(migration.should_run(['foo'], ['bar'])) - - def test_should_run_plugin_wildcard(self): - self.assertTrue(migration.should_run(['foo'], ['*'])) - def _prepare_mocked_sqlalchemy_inspector(self): mock_inspector = mock.MagicMock() mock_inspector.get_table_names.return_value = ['foo', 'bar']