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
def should_run(active_plugin, migrate_plugins):
def should_run(active_plugins, migrate_plugins):
if '*' in migrate_plugins:
return True
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)
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)
@ -59,7 +61,7 @@ def run_migrations_offline():
context.configure(url=neutron_config.database.connection)
with context.begin_transaction():
context.run_migrations(active_plugin=plugin_class_path,
context.run_migrations(active_plugins=active_plugins,
options=build_options())
@ -82,7 +84,7 @@ def run_migrations_online():
try:
with context.begin_transaction():
context.run_migrations(active_plugin=plugin_class_path,
context.run_migrations(active_plugins=active_plugins,
options=build_options())
finally:
connection.close()

View File

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

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -71,8 +71,8 @@ def upgrade(active_plugin=None, options=None):
"False as port_security_enabled from ports")
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

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

View File

@ -46,8 +46,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
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")
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.drop_column('routers', 'enable_snat')

View File

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

View File

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

View File

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

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -55,8 +55,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.create_table(
@ -52,8 +52,8 @@ def upgrade(active_plugin=None, options=None):
sa.PrimaryKeyConstraint('neutron_id'))
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
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
migration_for_plugins = ['*']
migration_for_plugins = [
'neutron.services.firewall.fwaas_plugin.FirewallPlugin',
]
from alembic import op
import sqlalchemy as sa
@ -37,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.drop_table('firewall_rules')
@ -46,8 +48,8 @@ def downgrade(active_plugin=None, options=None):
op.drop_table('firewall_policies')
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.create_table(

View File

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

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -54,8 +54,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

@ -43,8 +43,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -88,8 +88,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

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

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -80,8 +80,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

@ -44,8 +44,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -73,8 +73,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

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

View File

@ -39,8 +39,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
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'))
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.drop_table(u'servicedefinitions')

View File

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

View File

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

View File

@ -27,11 +27,19 @@ Create Date: 2013-06-14 03:23:47.815865
revision = '52c5e4a18807'
down_revision = '2032abe8edac'
migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op
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! ###
op.create_table(
'poolloadbalanceragentbindings',
@ -47,7 +55,9 @@ def upgrade(active_plugin=None, options=None):
### 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! ###
op.drop_table('poolloadbalanceragentbindings')
### end Alembic commands ###

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,8 +40,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###
@ -73,8 +73,8 @@ def upgrade(active_plugin=None, options=None):
### end Alembic commands ###
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
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! ###

View File

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

View File

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

View File

@ -27,7 +27,9 @@ Create Date: 2013-02-04 16:32:32.048731
revision = 'f489cf14a79c'
down_revision = 'grizzly'
migration_for_plugins = ['*']
migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
]
from alembic import op
import sqlalchemy as sa
@ -35,8 +37,8 @@ import sqlalchemy as sa
from neutron.db import migration
def upgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
op.create_table(
@ -147,8 +149,8 @@ def upgrade(active_plugin=None, options=None):
)
def downgrade(active_plugin=None, options=None):
if not migration.should_run(active_plugin, migration_for_plugins):
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
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.
def upgrade(active_plugin=None, options=None):
def upgrade(active_plugins=None, options=None):
# general model
upgrade_base()
if active_plugin in L3_CAPABLE:
if set(active_plugins) & set(L3_CAPABLE):
common_ext_ops.upgrade_l3()
if active_plugin in FOLSOM_QUOTA:
if set(active_plugins) & set(FOLSOM_QUOTA):
common_ext_ops.upgrade_quota(options)
if active_plugin == PLUGINS['lbr']:
if PLUGINS['lbr'] in active_plugins:
upgrade_linuxbridge()
elif active_plugin == PLUGINS['ovs']:
elif PLUGINS['ovs'] in active_plugins:
upgrade_ovs()
elif active_plugin == PLUGINS['cisco']:
elif PLUGINS['cisco'] in active_plugins:
upgrade_cisco()
# Cisco plugin imports OVS models too
upgrade_ovs()
elif active_plugin == PLUGINS['meta']:
elif PLUGINS['meta'] in active_plugins:
upgrade_meta()
elif active_plugin == PLUGINS['nec']:
elif PLUGINS['nec'] in active_plugins:
upgrade_nec()
elif active_plugin == PLUGINS['ryu']:
elif PLUGINS['ryu'] in active_plugins:
upgrade_ryu()
@ -428,26 +428,26 @@ def upgrade_cisco():
)
def downgrade(active_plugin=None, options=None):
if active_plugin == PLUGINS['lbr']:
def downgrade(active_plugins=None, options=None):
if PLUGINS['lbr'] in active_plugins:
downgrade_linuxbridge()
elif active_plugin == PLUGINS['ovs']:
elif PLUGINS['ovs'] in active_plugins:
downgrade_ovs()
elif active_plugin == PLUGINS['cisco']:
elif PLUGINS['cisco'] in active_plugins:
# Cisco plugin imports OVS models too
downgrade_ovs()
downgrade_cisco()
elif active_plugin == PLUGINS['meta']:
elif PLUGINS['meta'] in active_plugins:
downgrade_meta()
elif active_plugin == PLUGINS['nec']:
elif PLUGINS['nec'] in active_plugins:
downgrade_nec()
elif active_plugin == PLUGINS['ryu']:
elif PLUGINS['ryu'] in active_plugins:
downgrade_ryu()
if active_plugin in FOLSOM_QUOTA:
if set(active_plugins) & set(FOLSOM_QUOTA):
common_ext_ops.downgrade_quota(options)
if active_plugin in L3_CAPABLE:
if set(active_plugins) & set(L3_CAPABLE):
common_ext_ops.downgrade_l3()
downgrade_base()

View File

@ -32,11 +32,11 @@ down_revision = '1341ed32cc1e'
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."""
pass
def downgrade(active_plugin=None, options=None):
def downgrade(active_plugins=None, options=None):
"""A no-op migration for marking the Grizzly release."""
pass

View File

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

View File

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