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."""
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
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})
# 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
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')
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:
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',
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',
name='meteringlabels_direction')
-def upgrade():
+def create_meteringlabels():
op.create_table(
'meteringlabels',
sa.Column('tenant_id', sa.String(length=255), nullable=True),
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),
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',
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',
${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"}
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),
)
# 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')
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
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'),
op.drop_table('ofcfilters')
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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',
sa.PrimaryKeyConstraint('lsn_port_id'))
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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
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(
"gw_dev_ref.network_gateway_id=net_gw.id")
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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',
"from securitygroups")
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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),
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
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,
@migration.skip_if_offline
-def downgrade(active_plugins=None, options=None):
+def downgrade():
migration.alter_column_if_exists(
'poolstatisticss', 'bytes_in',
nullable=True,
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
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(
)
-def downgrade(active_plugins=None, options=None):
- pass
\ No newline at end of file
+def downgrade():
+ pass
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),
)
-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')
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')
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()
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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),
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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
@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',
@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')
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),
nullable=True))
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
'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
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
context = op.get_context()
dialect = context.bind.dialect.name
'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
import sqlalchemy as sa
-def upgrade(active_plugins=None, options=None):
+def upgrade():
op.drop_table('cisco_ml2_apic_port_profiles')
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')
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)")
+ metering_init_ops.create_meteringlabels()
- op.alter_column('meteringlabels', 'description', type_=sa.String(1024),
- existing_nullable=True)
-
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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),
sa.PrimaryKeyConstraint(u'pool_id'))
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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')
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),
sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('fip_id'),
- )
\ No newline at end of file
+ )
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),
"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')
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
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')
"RENAME TO tz_network_bindings_binding_type;")
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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',
)
-def downgrade(active_plugins=None, options=None):
- pass
\ No newline at end of file
+def downgrade():
+ pass
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),
sa.ForeignKeyConstraint(['network_id'], ['ml2_brocadenetworks.id']))
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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
"from routers")
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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'])
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')
-
-
-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))')
+TABLE = 'cisco_ml2_credentials'
+
+
+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()
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',
op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')")
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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),
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
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',
existing_nullable=False)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
import sqlalchemy as sa
import sqlalchemy.sql
-
from neutron.db import migration
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)
@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),
@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,
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),
)
-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')
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),
)
-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')
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(
)
-def downgrade(active_plugins=None, options=None):
- pass
\ No newline at end of file
+def downgrade():
+ pass
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,
@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,
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),
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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')
sa.PrimaryKeyConstraint('router_id'))
-def downgrade(active_plugins=None, options=None):
+def downgrade():
op.drop_table('cisco_ml2_apic_contracts')
{'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,
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),
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),
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
op.drop_table('nuage_provider_net_bindings')
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
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
@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
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,
@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,
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
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
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(
)
-def downgrade(active_plugins=None, options=None):
+def downgrade():
pass
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()
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()
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
# 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")
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']