¡@

Home 

OpenStack Study: 1b2580001654_nsx_sec_group_mappin.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 security group mappings

    op.create_table(

        'neutron_nsx_security_group_mappings',

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

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

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

                                ondelete='CASCADE'),

        sa.PrimaryKeyConstraint('neutron_id', 'nsx_id'))

    # Execute statement to add a record in security group mappings for

    # each record in securitygroups

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

               "from securitygroups")

**** 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_security_group_mappings')