Fix Migration 50e86cb2637a and 38335592a0dc

When the rename of quantum->neutron occurred here ee3fe4e8 it also renamed
the the table creation from quantum_nvp_port_mapping to
neutron_nvp_port_mapping. This went undetected for a long time because
when neutron-server starts up it pushes down the scheme for tables that
are not there so the table would be created.

Because of this the following migration 50e86cb2637a called
op.rename_table('neutron_nvp_port_mapping', 'neutron_nsx_port_mappings')
though the table name being used was quantum_nvp_port_mapping. Because of this
the quantum_id->nvp_id mapping was never migrated over to the new table and
you would be left with a quantum_nvp_port_mapping table hanging around.

In addition, the downgrade would rename the table to neutron_nvp_port_mapping
instead of quantum_nvp_port_mapping. This patch addresses this issues.

Change-Id: I4f80b7b9dc56996ecd83826ee65918f5311c7c4f
Closes-bug: #1267619
This commit is contained in:
Aaron Rosen 2014-01-09 13:49:10 -08:00
parent 641e7c6214
commit 251159c90a
2 changed files with 33 additions and 22 deletions

View File

@ -44,16 +44,16 @@ def upgrade(active_plugins=None, options=None):
return
op.create_table(
'neutron_nvp_port_mapping',
sa.Column('neutron_id', sa.String(length=36), nullable=False),
'quantum_nvp_port_mapping',
sa.Column('quantum_id', sa.String(length=36), nullable=False),
sa.Column('nvp_id', sa.String(length=36), nullable=True),
sa.ForeignKeyConstraint(['neutron_id'], ['ports.id'],
sa.ForeignKeyConstraint(['quantum_id'], ['ports.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('neutron_id'))
sa.PrimaryKeyConstraint('quantum_id'))
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')
op.drop_table('quantum_nvp_port_mapping')

View File

@ -44,26 +44,37 @@ def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
# Update table for port/lswitchport mappings
op.rename_table('neutron_nvp_port_mapping', 'neutron_nsx_port_mappings')
op.add_column(
'neutron_nsx_port_mappings',
sa.Column('nsx_switch_id', sa.String(length=36), nullable=True))
op.alter_column(
'neutron_nsx_port_mappings', 'nvp_id',
new_column_name='nsx_port_id',
existing_nullable=True,
existing_type=sa.String(length=36))
op.create_table('neutron_nsx_port_mappings',
sa.Column('neutron_id', sa.String(length=36),
nullable=False),
sa.Column('nsx_port_id', sa.String(length=36),
nullable=False),
sa.Column('nsx_switch_id', sa.String(length=36),
nullable=True),
sa.ForeignKeyConstraint(['neutron_id'], ['ports.id'],
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')
def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return
# Restore table to pre-icehouse version
op.drop_column('neutron_nsx_port_mappings', 'nsx_switch_id')
op.alter_column(
'neutron_nsx_port_mappings', 'nsx_port_id',
new_column_name='nvp_id',
existing_nullable=True,
existing_type=sa.String(length=36))
op.rename_table('neutron_nsx_port_mappings', 'neutron_nvp_port_mapping')
op.create_table('quantum_nvp_port_mapping',
sa.Column('quantum_id', sa.String(length=36),
nullable=False),
sa.Column('nvp_id', sa.String(length=36),
nullable=False),
sa.ForeignKeyConstraint(['quantum_id'], ['ports.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('quantum_id'))
op.execute("INSERT INTO quantum_nvp_port_mapping SELECT neutron_id as "
"quantum_id, nsx_port_id as nvp_id from"
" neutron_nsx_port_mappings")
op.drop_table('neutron_nsx_port_mappings')