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
This commit is contained in:
Salvatore 2014-08-30 01:49:03 +02:00 committed by Henry Gessau
parent 65e498acb3
commit b4276f9526
58 changed files with 278 additions and 572 deletions

View File

@ -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})
'columns': values})

View File

@ -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:

View File

@ -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',

View File

@ -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),

View File

@ -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',

View File

@ -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"}

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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),

View File

@ -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

View File

@ -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,

View File

@ -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
def downgrade():
pass

View File

@ -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')

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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'),
)
)

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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
def downgrade():
pass

View File

@ -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

View File

@ -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

View File

@ -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'])

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,

View File

@ -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')

View File

@ -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')

View File

@ -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
def downgrade():
pass

View File

@ -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,

View File

@ -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

View File

@ -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')

View File

@ -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),

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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")
"supported")

View File

@ -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']