Add support for service plugins to the migration framework

Implements blueprint migrations-for-service-plugins
Fixes bug 1209151

Change-Id: If7fc7a4488352e9b65b6973d8ea631e0d9ed8b68
This commit is contained in:
Oleg Bondarev 2013-08-07 16:15:51 +04:00
parent 3021cf19d3
commit 47c0d2ebd5
46 changed files with 220 additions and 196 deletions

View File

@ -17,8 +17,8 @@
# @author: Mark McClain, DreamHost # @author: Mark McClain, DreamHost
def should_run(active_plugin, migrate_plugins): def should_run(active_plugins, migrate_plugins):
if '*' in migrate_plugins: if '*' in migrate_plugins:
return True return True
else: else:
return active_plugin in migrate_plugins return set(active_plugins) & set(migrate_plugins)

View File

@ -37,6 +37,8 @@ neutron_config = config.neutron_config
fileConfig(config.config_file_name) fileConfig(config.config_file_name)
plugin_class_path = neutron_config.core_plugin plugin_class_path = neutron_config.core_plugin
active_plugins = [plugin_class_path]
active_plugins += neutron_config.service_plugins
plugin_klass = importutils.import_class(plugin_class_path) plugin_klass = importutils.import_class(plugin_class_path)
@ -59,7 +61,7 @@ def run_migrations_offline():
context.configure(url=neutron_config.database.connection) context.configure(url=neutron_config.database.connection)
with context.begin_transaction(): with context.begin_transaction():
context.run_migrations(active_plugin=plugin_class_path, context.run_migrations(active_plugins=active_plugins,
options=build_options()) options=build_options())
@ -82,7 +84,7 @@ def run_migrations_online():
try: try:
with context.begin_transaction(): with context.begin_transaction():
context.run_migrations(active_plugin=plugin_class_path, context.run_migrations(active_plugins=active_plugins,
options=build_options()) options=build_options())
finally: finally:
connection.close() connection.close()

View File

@ -40,15 +40,15 @@ ${imports if imports else ""}
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
${upgrades if upgrades else "pass"} ${upgrades if upgrades else "pass"}
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
${downgrades if downgrades else "pass"} ${downgrades if downgrades else "pass"}

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -71,8 +71,8 @@ def upgrade(active_plugin=None, options=None):
"False as port_security_enabled from ports") "False as port_security_enabled from ports")
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -29,7 +29,9 @@ down_revision = '52ff27f7567a'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -37,12 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
# Change to ['*'] if this migration applies to all plugins def upgrade(active_plugins=None, options=None):
migration_for_plugins = ['*'] if not migration.should_run(active_plugins, migration_for_plugins):
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
return return
op.add_column('poolmonitorassociations', sa.Column('status', op.add_column('poolmonitorassociations', sa.Column('status',
@ -55,8 +53,8 @@ def upgrade(active_plugin=None, options=None):
op.execute("UPDATE poolmonitorassociations SET status='ACTIVE'") op.execute("UPDATE poolmonitorassociations SET status='ACTIVE'")
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_column('poolmonitorassociations', 'status') op.drop_column('poolmonitorassociations', 'status')

View File

@ -46,8 +46,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.add_column('routers', sa.Column('enable_snat', sa.Boolean(), op.add_column('routers', sa.Column('enable_snat', sa.Boolean(),
@ -56,8 +56,8 @@ def upgrade(active_plugin=None, options=None):
op.execute("UPDATE routers SET enable_snat=True") op.execute("UPDATE routers SET enable_snat=True")
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_column('routers', 'enable_snat') op.drop_column('routers', 'enable_snat')

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.alter_column('nvp_network_bindings', 'tz_uuid', op.alter_column('nvp_network_bindings', 'tz_uuid',
name='phy_uuid', name='phy_uuid',
@ -53,8 +53,8 @@ def upgrade(active_plugin=None, options=None):
existing_nullable=True) existing_nullable=True)
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.alter_column('nvp_network_bindings', 'phy_uuid', op.alter_column('nvp_network_bindings', 'phy_uuid',
name='tz_uuid', name='tz_uuid',

View File

@ -40,16 +40,16 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.add_column('packetfilters', op.add_column('packetfilters',
sa.Column('name', sa.String(length=255), nullable=True)) sa.Column('name', sa.String(length=255), nullable=True))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_column('packetfilters', 'name') op.drop_column('packetfilters', 'name')

View File

@ -41,8 +41,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -54,7 +54,7 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('portbindingports') op.drop_table('portbindingports')

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -55,8 +55,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -43,8 +43,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.rename_table( op.rename_table(
@ -63,8 +63,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.rename_table( op.rename_table(

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -57,8 +57,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint('network_id')) sa.PrimaryKeyConstraint('network_id'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('nvp_network_bindings') op.drop_table('nvp_network_bindings')

View File

@ -29,7 +29,9 @@ down_revision = '477a4488d3f4'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -39,16 +41,16 @@ from neutron.db import migration
ENTITIES = ['vips', 'pools', 'members', 'healthmonitors'] ENTITIES = ['vips', 'pools', 'members', 'healthmonitors']
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
for entity in ENTITIES: for entity in ENTITIES:
op.add_column(entity, sa.Column('status_description', sa.String(255))) op.add_column(entity, sa.Column('status_description', sa.String(255)))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
for entity in ENTITIES: for entity in ENTITIES:

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -58,8 +58,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ml2_gre_allocations') op.drop_table('ml2_gre_allocations')

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
if 'credentials' in sa.MetaData().tables: if 'credentials' in sa.MetaData().tables:
@ -53,8 +53,8 @@ def upgrade(active_plugin=None, options=None):
op.drop_table('cisco_vlan_ids') op.drop_table('cisco_vlan_ids')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table(u'port_bindings') op.drop_table(u'port_bindings')
@ -49,8 +49,8 @@ def upgrade(active_plugin=None, options=None):
op.drop_table(u'portprofile_bindings') op.drop_table(u'portprofile_bindings')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -40,13 +40,13 @@ from neutron.db import migration
from neutron.db.migration.alembic_migrations import common_ext_ops from neutron.db.migration.alembic_migrations import common_ext_ops
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
common_ext_ops.upgrade_l3() common_ext_ops.upgrade_l3()
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
common_ext_ops.downgrade_l3() common_ext_ops.downgrade_l3()

View File

@ -40,15 +40,15 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ovs_tunnel_ips') op.drop_table('ovs_tunnel_ips')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -29,7 +29,9 @@ down_revision = '11c6e18605c8'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -38,15 +40,15 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_column('healthmonitors', 'status') op.drop_column('healthmonitors', 'status')
op.drop_column('healthmonitors', 'status_description') op.drop_column('healthmonitors', 'status_description')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.add_column('healthmonitors', sa.Column('status', op.add_column('healthmonitors', sa.Column('status',

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table('networkgateways', op.create_table('networkgateways',
sa.Column('id', sa.String(length=36), nullable=False), sa.Column('id', sa.String(length=36), nullable=False),
@ -88,8 +88,8 @@ def upgrade(active_plugin=None, options=None):
'segmentation_id')) 'segmentation_id'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('networkconnections') op.drop_table('networkconnections')

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -52,8 +52,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint('neutron_id')) sa.PrimaryKeyConstraint('neutron_id'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('neutron_nvp_port_mapping') op.drop_table('neutron_nvp_port_mapping')

View File

@ -29,7 +29,9 @@ down_revision = 'e6b16a30d97'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.firewall.fwaas_plugin.FirewallPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -37,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('firewall_rules') op.drop_table('firewall_rules')
@ -46,8 +48,8 @@ def downgrade(active_plugin=None, options=None):
op.drop_table('firewall_policies') op.drop_table('firewall_policies')
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -74,8 +74,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ofcfiltermappings') op.drop_table('ofcfiltermappings')

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -54,8 +54,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -43,8 +43,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -88,8 +88,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -53,8 +53,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint('port_id')) sa.PrimaryKeyConstraint('port_id'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('maclearningstates') op.drop_table('maclearningstates')

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -80,8 +80,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -44,8 +44,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -73,8 +73,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -61,8 +61,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ml2_vxlan_allocations') op.drop_table('ml2_vxlan_allocations')

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -68,8 +68,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint(u'id', u'service_class', u'service_type_id')) sa.PrimaryKeyConstraint(u'id', u'service_class', u'service_type_id'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table(u'servicedefinitions') op.drop_table(u'servicedefinitions')

View File

@ -39,15 +39,15 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ofp_server') op.drop_table('ofp_server')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -35,6 +35,7 @@ migration_for_plugins = [
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2', 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
'neutron.plugins.nec.nec_plugin.NECPluginV2', 'neutron.plugins.nec.nec_plugin.NECPluginV2',
'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2', 'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2',
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
] ]
from alembic import op from alembic import op
@ -44,8 +45,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -67,8 +68,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -27,11 +27,19 @@ Create Date: 2013-06-14 03:23:47.815865
revision = '52c5e4a18807' revision = '52c5e4a18807'
down_revision = '2032abe8edac' down_revision = '2032abe8edac'
migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
op.create_table( op.create_table(
'poolloadbalanceragentbindings', 'poolloadbalanceragentbindings',
@ -47,7 +55,9 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
op.drop_table('poolloadbalanceragentbindings') op.drop_table('poolloadbalanceragentbindings')
### end Alembic commands ### ### end Alembic commands ###

View File

@ -30,7 +30,7 @@ down_revision = '39cf3f799352'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = [ migration_for_plugins = [
'*' 'neutron.services.vpn.plugin.VPNPlugin',
] ]
from alembic import op from alembic import op
@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -172,8 +172,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('ipsecpeercidrs') op.drop_table('ipsecpeercidrs')

View File

@ -38,8 +38,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -150,8 +150,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table(u'poolstatisticss') op.drop_table(u'poolstatisticss')

View File

@ -29,7 +29,9 @@ down_revision = '52c5e4a18807'
# Change to ['*'] if this migration applies to all plugins # Change to ['*'] if this migration applies to all plugins
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -38,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
'providerresourceassociations', 'providerresourceassociations',
@ -53,8 +55,8 @@ def upgrade(active_plugin=None, options=None):
op.drop_table('servicetypes') op.drop_table('servicetypes')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
'servicetypes', 'servicetypes',

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table('routerrules', op.create_table('routerrules',
@ -63,8 +63,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint('rule_id', 'nexthop')) sa.PrimaryKeyConstraint('rule_id', 'nexthop'))
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('nexthops') op.drop_table('nexthops')

View File

@ -44,8 +44,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -66,8 +66,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('tunnelkeylasts') op.drop_table('tunnelkeylasts')

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###
@ -73,8 +73,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ### ### end Alembic commands ###
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
### commands auto generated by Alembic - please adjust! ### ### commands auto generated by Alembic - please adjust! ###

View File

@ -40,15 +40,15 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('cisco_vlan_bindings') op.drop_table('cisco_vlan_bindings')
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -53,8 +53,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table('cisco_provider_networks') op.drop_table('cisco_provider_networks')

View File

@ -27,7 +27,9 @@ Create Date: 2013-02-04 16:32:32.048731
revision = 'f489cf14a79c' revision = 'f489cf14a79c'
down_revision = 'grizzly' down_revision = 'grizzly'
migration_for_plugins = ['*'] migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -35,8 +37,8 @@ import sqlalchemy as sa
from neutron.db import migration from neutron.db import migration
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.create_table( op.create_table(
@ -147,8 +149,8 @@ def upgrade(active_plugin=None, options=None):
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins): if not migration.should_run(active_plugins, migration_for_plugins):
return return
op.drop_table(u'poolstatisticss') op.drop_table(u'poolstatisticss')

View File

@ -64,29 +64,29 @@ from neutron.db.migration.alembic_migrations import common_ext_ops
# NOTE: This is a special migration that creates a Folsom compatible database. # NOTE: This is a special migration that creates a Folsom compatible database.
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
# general model # general model
upgrade_base() upgrade_base()
if active_plugin in L3_CAPABLE: if set(active_plugins) & set(L3_CAPABLE):
common_ext_ops.upgrade_l3() common_ext_ops.upgrade_l3()
if active_plugin in FOLSOM_QUOTA: if set(active_plugins) & set(FOLSOM_QUOTA):
common_ext_ops.upgrade_quota(options) common_ext_ops.upgrade_quota(options)
if active_plugin == PLUGINS['lbr']: if PLUGINS['lbr'] in active_plugins:
upgrade_linuxbridge() upgrade_linuxbridge()
elif active_plugin == PLUGINS['ovs']: elif PLUGINS['ovs'] in active_plugins:
upgrade_ovs() upgrade_ovs()
elif active_plugin == PLUGINS['cisco']: elif PLUGINS['cisco'] in active_plugins:
upgrade_cisco() upgrade_cisco()
# Cisco plugin imports OVS models too # Cisco plugin imports OVS models too
upgrade_ovs() upgrade_ovs()
elif active_plugin == PLUGINS['meta']: elif PLUGINS['meta'] in active_plugins:
upgrade_meta() upgrade_meta()
elif active_plugin == PLUGINS['nec']: elif PLUGINS['nec'] in active_plugins:
upgrade_nec() upgrade_nec()
elif active_plugin == PLUGINS['ryu']: elif PLUGINS['ryu'] in active_plugins:
upgrade_ryu() upgrade_ryu()
@ -428,26 +428,26 @@ def upgrade_cisco():
) )
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
if active_plugin == PLUGINS['lbr']: if PLUGINS['lbr'] in active_plugins:
downgrade_linuxbridge() downgrade_linuxbridge()
elif active_plugin == PLUGINS['ovs']: elif PLUGINS['ovs'] in active_plugins:
downgrade_ovs() downgrade_ovs()
elif active_plugin == PLUGINS['cisco']: elif PLUGINS['cisco'] in active_plugins:
# Cisco plugin imports OVS models too # Cisco plugin imports OVS models too
downgrade_ovs() downgrade_ovs()
downgrade_cisco() downgrade_cisco()
elif active_plugin == PLUGINS['meta']: elif PLUGINS['meta'] in active_plugins:
downgrade_meta() downgrade_meta()
elif active_plugin == PLUGINS['nec']: elif PLUGINS['nec'] in active_plugins:
downgrade_nec() downgrade_nec()
elif active_plugin == PLUGINS['ryu']: elif PLUGINS['ryu'] in active_plugins:
downgrade_ryu() downgrade_ryu()
if active_plugin in FOLSOM_QUOTA: if set(active_plugins) & set(FOLSOM_QUOTA):
common_ext_ops.downgrade_quota(options) common_ext_ops.downgrade_quota(options)
if active_plugin in L3_CAPABLE: if set(active_plugins) & set(L3_CAPABLE):
common_ext_ops.downgrade_l3() common_ext_ops.downgrade_l3()
downgrade_base() downgrade_base()

View File

@ -32,11 +32,11 @@ down_revision = '1341ed32cc1e'
migration_for_plugins = ['*'] migration_for_plugins = ['*']
def upgrade(active_plugin=None, options=None): def upgrade(active_plugins=None, options=None):
"""A no-op migration for marking the Grizzly release.""" """A no-op migration for marking the Grizzly release."""
pass pass
def downgrade(active_plugin=None, options=None): def downgrade(active_plugins=None, options=None):
"""A no-op migration for marking the Grizzly release.""" """A no-op migration for marking the Grizzly release."""
pass pass

View File

@ -30,6 +30,9 @@ _core_opts = [
cfg.StrOpt('core_plugin', cfg.StrOpt('core_plugin',
default='', default='',
help=_('Neutron plugin provider module')), help=_('Neutron plugin provider module')),
cfg.ListOpt('service_plugins',
default=[],
help=_("The service plugins Neutron will use")),
] ]
_quota_opts = [ _quota_opts = [

View File

@ -28,11 +28,11 @@ from neutron.tests import base
class TestDbMigration(base.BaseTestCase): class TestDbMigration(base.BaseTestCase):
def test_should_run_plugin_in_list(self): def test_should_run_plugin_in_list(self):
self.assertTrue(migration.should_run('foo', ['foo', 'bar'])) self.assertTrue(migration.should_run(['foo'], ['foo', 'bar']))
self.assertFalse(migration.should_run('foo', ['bar'])) self.assertFalse(migration.should_run(['foo'], ['bar']))
def test_should_run_plugin_wildcard(self): def test_should_run_plugin_wildcard(self):
self.assertTrue(migration.should_run('foo', ['*'])) self.assertTrue(migration.should_run(['foo'], ['*']))
class TestCli(base.BaseTestCase): class TestCli(base.BaseTestCase):