¡@

Home 

OpenStack Study: 4ca36cfc898c_nsx_router_mappings.py

OpenStack Index

**** CubicPower OpenStack Study ****

def upgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    # Create table for router/lrouter mappings

    op.create_table(

        'neutron_nsx_router_mappings',

        sa.Column('neutron_id', sa.String(length=36), nullable=False),

        sa.Column('nsx_id', sa.String(length=36), nullable=True),

        sa.ForeignKeyConstraint(['neutron_id'], ['routers.id'],

                                ondelete='CASCADE'),

        sa.PrimaryKeyConstraint('neutron_id'),

    )

    # Execute statement to a record in nsx_router_mappings for

    # each record in routers

    op.execute("INSERT INTO neutron_nsx_router_mappings SELECT id,id "

               "from routers")

**** CubicPower OpenStack Study ****

def downgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.drop_table('neutron_nsx_router_mappings')