¡@

Home 

OpenStack Study: 46a0efbd8f0_cisco_n1kv_multisegm.py

OpenStack Index

**** CubicPower OpenStack Study ****

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

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.create_table(

        'cisco_n1kv_trunk_segments',

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

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

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

        sa.ForeignKeyConstraint(['trunk_segment_id'], ['networks.id'],

                                ondelete='CASCADE'),

        sa.PrimaryKeyConstraint('trunk_segment_id', 'segment_id', 'dot1qtag')

    )

    op.create_table(

        'cisco_n1kv_multi_segments',

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

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

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

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

        sa.ForeignKeyConstraint(['multi_segment_id'], ['networks.id'],

                                ondelete='CASCADE'),

        sa.PrimaryKeyConstraint('multi_segment_id', 'segment1_id',

                                'segment2_id')

    )

    op.alter_column('cisco_network_profiles', 'segment_type',

                    existing_type=sa.Enum('vlan', 'vxlan', 'trunk',

                                          'multi-segment'),

                    existing_nullable=False)

    op.add_column('cisco_network_profiles',

                  sa.Column('sub_type', sa.String(length=255), nullable=True))

**** CubicPower OpenStack Study ****

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

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.drop_table('cisco_n1kv_trunk_segments')

    op.drop_table('cisco_n1kv_multi_segments')

    op.alter_column('cisco_network_profiles', 'segment_type',

                    existing_type=sa.Enum('vlan', 'vxlan'),

                    existing_nullable=False)

    op.drop_column('cisco_network_profiles', 'sub_type')