¡@

Home 

OpenStack Study: 5ac1c354a051_n1kv_segment_alloc.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.add_column(

        'cisco_n1kv_vlan_allocations',

        sa.Column('network_profile_id',

                  sa.String(length=36),

                  nullable=False)

    )

    op.create_foreign_key(

        'cisco_n1kv_vlan_allocations_ibfk_1',

        source='cisco_n1kv_vlan_allocations',

        referent='cisco_network_profiles',

        local_cols=['network_profile_id'], remote_cols=['id'],

        ondelete='CASCADE'

    )

    op.add_column(

        'cisco_n1kv_vxlan_allocations',

        sa.Column('network_profile_id',

                  sa.String(length=36),

                  nullable=False)

    )

    op.create_foreign_key(

        'cisco_n1kv_vxlan_allocations_ibfk_1',

        source='cisco_n1kv_vxlan_allocations',

        referent='cisco_network_profiles',

        local_cols=['network_profile_id'], remote_cols=['id'],

        ondelete='CASCADE'

    )

**** CubicPower OpenStack Study ****

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

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.drop_constraint('cisco_n1kv_vxlan_allocations_ibfk_1',

                       'cisco_n1kv_vxlan_allocations',

                       'foreignkey')

    op.drop_column('cisco_n1kv_vxlan_allocations', 'network_profile_id')

    op.drop_constraint('cisco_n1kv_vlan_allocations_ibfk_1',

                       'cisco_n1kv_vlan_allocations',

                       'foreignkey')

    op.drop_column('cisco_n1kv_vlan_allocations', 'network_profile_id')