def upgrade():

    if migration.schema_has_table('nsxv3_lbaas_l7rules'):
        op.drop_constraint('fk_nsxv3_lbaas_l7rules_id', 'nsxv3_lbaas_l7rules',
                           'foreignkey')
        op.drop_constraint('l7rule_id', 'nsxv3_lbaas_l7rules', 'primary')
        op.drop_column('nsxv3_lbaas_l7rules', 'loadbalancer_id')
        op.drop_column('nsxv3_lbaas_l7rules', 'l7rule_id')
        op.rename_table('nsxv3_lbaas_l7rules', 'nsxv3_lbaas_l7policies')

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key(
                'fk_nsxv3_lbaas_l7policies_id', 'nsxv3_lbaas_l7policies',
                'lbaas_l7policies', ['l7policy_id'], ['id'],
                ondelete='CASCADE')
    else:
        op.create_table(
            'nsxv3_lbaas_l7policies',
            sa.Column('l7policy_id', sa.String(36), nullable=False),
            sa.Column('lb_rule_id', sa.String(36), nullable=False),
            sa.Column('lb_vs_id', sa.String(36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('l7policy_id'))

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key(
                'fk_nsxv3_lbaas_l7policies_id', 'nsxv3_lbaas_l7policies',
                'lbaas_l7policies', ['l7policy_id'], ['id'],
                ondelete='CASCADE')
def upgrade():

    if migration.schema_has_table('nsxv3_lbaas_l7rules'):
        op.drop_constraint('fk_nsxv3_lbaas_l7rules_id', 'nsxv3_lbaas_l7rules',
                           'foreignkey')
        op.drop_constraint('l7rule_id', 'nsxv3_lbaas_l7rules', 'primary')
        op.drop_column('nsxv3_lbaas_l7rules', 'loadbalancer_id')
        op.drop_column('nsxv3_lbaas_l7rules', 'l7rule_id')
        op.rename_table('nsxv3_lbaas_l7rules', 'nsxv3_lbaas_l7policies')

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key('fk_nsxv3_lbaas_l7policies_id',
                                  'nsxv3_lbaas_l7policies',
                                  'lbaas_l7policies', ['l7policy_id'], ['id'],
                                  ondelete='CASCADE')
    else:
        op.create_table(
            'nsxv3_lbaas_l7policies',
            sa.Column('l7policy_id', sa.String(36), nullable=False),
            sa.Column('lb_rule_id', sa.String(36), nullable=False),
            sa.Column('lb_vs_id', sa.String(36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('l7policy_id'))

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key('fk_nsxv3_lbaas_l7policies_id',
                                  'nsxv3_lbaas_l7policies',
                                  'lbaas_l7policies', ['l7policy_id'], ['id'],
                                  ondelete='CASCADE')
Exemple #3
0
def upgrade():
    if migration.schema_has_table('lbaas_loadbalancers'):
        op.create_foreign_key('fk_lbaas_loadbalancers_id',
                              'nsxv_lbaas_loadbalancer_bindings',
                              'lbaas_loadbalancers', ['loadbalancer_id'],
                              ['id'],
                              ondelete='CASCADE')

    if migration.schema_has_table('lbaas_listeners'):
        op.create_foreign_key('fk_lbaas_listeners_id',
                              'nsxv_lbaas_listener_bindings',
                              'lbaas_listeners', ['listener_id'], ['id'],
                              ondelete='CASCADE')

    if migration.schema_has_table('lbaas_pools'):
        op.create_foreign_key('fk_lbaas_pools_id',
                              'nsxv_lbaas_pool_bindings',
                              'lbaas_pools', ['pool_id'], ['id'],
                              ondelete='CASCADE')

    if migration.schema_has_table('lbaas_healthmonitors'):
        op.create_foreign_key('fk_lbaas_healthmonitors_id',
                              'nsxv_lbaas_monitor_bindings',
                              'lbaas_healthmonitors', ['hm_id'], ['id'],
                              ondelete='CASCADE')
def upgrade():
    if (migration.schema_has_table('nsxv3_lbaas_loadbalancers')
            and migration.schema_has_table('lbaas_loadbalancers')):
        # Mark as ERROR loadbalancers without nsx mapping
        op.execute("UPDATE lbaas_loadbalancers "
                   "SET provisioning_status='ERROR' "
                   "WHERE id not in (SELECT loadbalancer_id FROM "
                   "nsxv3_lbaas_loadbalancers)")
def upgrade():
    if (migration.schema_has_table('nsxv3_lbaas_loadbalancers') and
        migration.schema_has_table('lbaas_loadbalancers')):
        # Mark as ERROR loadbalancers without nsx mapping
        op.execute("UPDATE lbaas_loadbalancers "
                   "SET provisioning_status='ERROR' "
                   "WHERE id not in (SELECT loadbalancer_id FROM "
                   "nsxv3_lbaas_loadbalancers)")
def upgrade():

    if not migration.schema_has_table('ml2_port_bindings'):
        # In the database we are migrating from, the configured plugin
        # did not create the ml2_port_bindings table.
        return

    op.add_column('ml2_port_bindings',
                  sa.Column('vif_details', sa.String(length=4095),
                            nullable=False, server_default=''))
    if op.get_bind().engine.name == 'ibm_db_sa':
        op.execute(
            "UPDATE ml2_port_bindings SET"
            " vif_details = '{\"port_filter\": true}'"
            " WHERE cap_port_filter = 1")
        op.execute(
            "UPDATE ml2_port_bindings SET"
            " vif_details = '{\"port_filter\": false}'"
            " WHERE cap_port_filter = 0")
    else:
        op.execute(
            "UPDATE ml2_port_bindings SET"
            " vif_details = '{\"port_filter\": true}'"
            " WHERE cap_port_filter = true")
        op.execute(
            "UPDATE ml2_port_bindings SET"
            " vif_details = '{\"port_filter\": false}'"
            " WHERE cap_port_filter = false")
    op.drop_column('ml2_port_bindings', 'cap_port_filter')
    if op.get_bind().engine.name == 'ibm_db_sa':
        op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')")
def upgrade():

    if not migration.schema_has_table('ml2_port_bindings'):
        # In the database we are migrating from, the configured plugin
        # did not create the ml2_port_bindings table.
        return

    op.add_column(
        'ml2_port_bindings',
        sa.Column('vif_details',
                  sa.String(length=4095),
                  nullable=False,
                  server_default=''))
    if op.get_bind().engine.name == 'ibm_db_sa':
        op.execute("UPDATE ml2_port_bindings SET"
                   " vif_details = '{\"port_filter\": true}'"
                   " WHERE cap_port_filter = 1")
        op.execute("UPDATE ml2_port_bindings SET"
                   " vif_details = '{\"port_filter\": false}'"
                   " WHERE cap_port_filter = 0")
    else:
        op.execute("UPDATE ml2_port_bindings SET"
                   " vif_details = '{\"port_filter\": true}'"
                   " WHERE cap_port_filter = true")
        op.execute("UPDATE ml2_port_bindings SET"
                   " vif_details = '{\"port_filter\": false}'"
                   " WHERE cap_port_filter = false")
    op.drop_column('ml2_port_bindings', 'cap_port_filter')
    if op.get_bind().engine.name == 'ibm_db_sa':
        op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')")
Exemple #8
0
def upgrade():
    if migration.schema_has_table(TABLE_NAME):
        op.create_unique_constraint(
            name=CONSTRAINT_NAME,
            source=TABLE_NAME,
            local_cols=['pool_id', 'address', 'protocol_port']
        )
def upgrade():

    if not migration.schema_has_table('cisco_n1kv_vlan_allocations'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any n1kv tables.
        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')
def upgrade():

    if not migration.schema_has_table('cisco_n1kv_vlan_allocations'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any n1kv tables.
        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'
    )
Exemple #11
0
def upgrade():

    if not migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        return

    op.create_table(
        'net_partitions',
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('l3dom_tmplt_id', sa.String(length=36), nullable=True),
        sa.Column('l2dom_tmplt_id', sa.String(length=36), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    )
    op.create_table(
        'port_mapping',
        sa.Column('port_id', sa.String(length=36), nullable=False),
        sa.Column('nuage_vport_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_vif_id', sa.String(length=36), nullable=True),
        sa.Column('static_ip', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('port_id'),
    )
    op.create_table(
        'subnet_l2dom_mapping',
        sa.Column('subnet_id', sa.String(length=36), nullable=False),
        sa.Column('net_partition_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_subnet_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_l2dom_tmplt_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_user_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_group_id', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['net_partition_id'], ['net_partitions.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('subnet_id'),
    )
    op.create_table(
        'net_partition_router_mapping',
        sa.Column('net_partition_id', sa.String(length=36), nullable=False),
        sa.Column('router_id', sa.String(length=36), nullable=False),
        sa.Column('nuage_router_id', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['net_partition_id'], ['net_partitions.id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('net_partition_id', 'router_id'),
    )
    op.create_table(
        'router_zone_mapping',
        sa.Column('router_id', sa.String(length=36), nullable=False),
        sa.Column('nuage_zone_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_user_id', sa.String(length=36), nullable=True),
        sa.Column('nuage_group_id', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('router_id'),
    )
Exemple #12
0
def upgrade():
    if migration.schema_has_table('ml2_port_bindings'):
        op.add_column(
            'ml2_port_bindings',
            sa.Column('profile',
                      sa.String(length=4095),
                      nullable=False,
                      server_default=''))
def upgrade():
    if migration.schema_has_table('ml2_port_bindings'):
        op.add_column(
            'ml2_port_bindings',
            sa.Column('vnic_type',
                      sa.String(length=64),
                      nullable=False,
                      server_default='normal'))
Exemple #14
0
def upgrade(active_plugins=None, options=None):
    if migration.schema_has_table('qoses'):
        op.add_column(
            'qoses',
            sa.Column('shared',
                      sa.Boolean(),
                      server_default=sa.sql.false(),
                      nullable=True))
def upgrade():

    if not migration.schema_has_table(TABLE_NAME):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create the agents table.
        return

    op.create_unique_constraint(name=UC_NAME, source=TABLE_NAME, local_cols=["agent_type", "host"])
def upgrade():
    if migration.schema_has_table('meteringlabels'):
        op.alter_column('meteringlabels',
                        'description',
                        type_=sa.String(1024),
                        existing_nullable=True)
    else:
        metering_init_ops.create_meteringlabels()
Exemple #17
0
def upgrade():

    if not migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        return

    op.create_table(
        'routerroutes_mapping',
        sa.Column('router_id', sa.String(length=36), nullable=False),
        sa.Column('nuage_route_id', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                ondelete='CASCADE'),
    )
    # This table might already exist as it might have been created
    # if another plugin was configured before the nuage one
    if not migration.schema_has_table('routerroutes'):
        l3_init_ops.create_routerroutes()
def upgrade():
    op.create_table('cisco_router_types',
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('description', sa.String(length=255), nullable=True),
        sa.Column('template_id', sa.String(length=36), nullable=True),
        sa.Column('ha_enabled_by_default', sa.Boolean(), nullable=False,
                  server_default=sa.sql.false()),
        sa.Column('shared', sa.Boolean(), nullable=False,
                  server_default=sa.sql.true()),
        sa.Column('slot_need', sa.Integer(), autoincrement=False,
                  nullable=True),
        sa.Column('scheduler', sa.String(length=255), nullable=False),
        sa.Column('driver', sa.String(length=255), nullable=False),
        sa.Column('cfg_agent_service_helper', sa.String(length=255),
                  nullable=False),
        sa.Column('cfg_agent_driver', sa.String(length=255), nullable=False),
        sa.ForeignKeyConstraint(['template_id'],
                                ['cisco_hosting_device_templates.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )
    if migration.schema_has_table('cisco_router_mappings'):
        op.add_column('cisco_router_mappings',
                      sa.Column('role', sa.String(255), nullable=True))
        op.add_column('cisco_router_mappings',
                      sa.Column('router_type_id', sa.String(length=36),
                                nullable=False))
        op.create_foreign_key('cisco_router_mappings_ibfk_3',
                              source_table='cisco_router_mappings',
                              referent_table='cisco_router_types',
                              local_cols=['router_type_id'],
                              remote_cols=['id'])
        op.drop_constraint('cisco_router_mappings_ibfk_2',
                           'cisco_router_mappings', type_='foreignkey')
        op.drop_constraint('cisco_router_mappings_ibfk_2',
                           'cisco_router_mappings', type_='primary')
        op.create_foreign_key('cisco_router_mappings_ibfk_2',
                              source_table='cisco_router_mappings',
                              referent_table='routers',
                              local_cols=['router_id'],
                              remote_cols=['id'],
                              ondelete='CASCADE')
        op.create_primary_key(
            constraint_name='pk_cisco_router_mappings',
            table_name='cisco_router_mappings',
            columns=['router_id', 'router_type_id'])
        op.add_column('cisco_router_mappings',
                      sa.Column('inflated_slot_need', sa.Integer(),
                                autoincrement=False, nullable=True,
                                server_default='0'))
        op.add_column('cisco_router_mappings',
                      sa.Column('share_hosting_device', sa.Boolean(),
                                nullable=False, server_default=sa.sql.true()))
        op.create_index(op.f('ix_cisco_router_types_tenant_id'),
                        'cisco_router_types', ['tenant_id'], unique=False)
def upgrade():

    if not migration.schema_has_table(TABLE_NAME):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create the agents table.
        return

    op.create_unique_constraint(name=UC_NAME,
                                source=TABLE_NAME,
                                local_cols=['agent_type', 'host'])
def upgrade():
    # On a previous upgrade this table was created conditionally.
    # It should always be created, and just the ForeignKeyConstraint
    # should be conditional
    if not migration.schema_has_table('nsxv_lbaas_l7policy_bindings'):
        op.create_table(
            'nsxv_lbaas_l7policy_bindings',
            sa.Column('policy_id', sa.String(length=36), nullable=False),
            sa.Column('edge_id', sa.String(length=36), nullable=False),
            sa.Column('edge_app_rule_id',
                      sa.String(length=36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('policy_id'))

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key(
                'fk_lbaas_l7policies_id', 'nsxv_lbaas_l7policy_bindings',
                'lbaas_l7policies', ['policy_id'], ['id'], ondelete='CASCADE')
def upgrade():
    if migration.schema_has_table('poolstatisticss'):
        op.alter_column('poolstatisticss', 'bytes_in',
                        type_=sa.BigInteger(), existing_type=sa.Integer())
        op.alter_column('poolstatisticss', 'bytes_out',
                        type_=sa.BigInteger(), existing_type=sa.Integer())
        op.alter_column('poolstatisticss', 'active_connections',
                        type_=sa.BigInteger(), existing_type=sa.Integer())
        op.alter_column('poolstatisticss', 'total_connections',
                        type_=sa.BigInteger(), existing_type=sa.Integer())
def upgrade():
    if not migration.schema_has_table('apic_ml2_ha_ipaddress_to_port_owner'):
        op.create_table(
            'apic_ml2_ha_ipaddress_to_port_owner',
            sa.Column('ha_ip_address', sa.String(length=64), nullable=False),
            sa.Column('port_id', sa.String(length=64), nullable=False),
            sa.ForeignKeyConstraint(
                ['port_id'], ['ports.id'], ondelete='CASCADE',
                name='apic_ml2_ha_ipaddress_to_port_owner_fk_port_id'),
            sa.PrimaryKeyConstraint('ha_ip_address', 'port_id'))
def upgrade():

    if not migration.schema_has_table("routers"):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        return

    op.create_table(
        "net_partitions",
        sa.Column("id", sa.String(length=36), nullable=False),
        sa.Column("name", sa.String(length=64), nullable=True),
        sa.Column("l3dom_tmplt_id", sa.String(length=36), nullable=True),
        sa.Column("l2dom_tmplt_id", sa.String(length=36), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "port_mapping",
        sa.Column("port_id", sa.String(length=36), nullable=False),
        sa.Column("nuage_vport_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_vif_id", sa.String(length=36), nullable=True),
        sa.Column("static_ip", sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(["port_id"], ["ports.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("port_id"),
    )
    op.create_table(
        "subnet_l2dom_mapping",
        sa.Column("subnet_id", sa.String(length=36), nullable=False),
        sa.Column("net_partition_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_subnet_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_l2dom_tmplt_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_user_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_group_id", sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(["subnet_id"], ["subnets.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["net_partition_id"], ["net_partitions.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("subnet_id"),
    )
    op.create_table(
        "net_partition_router_mapping",
        sa.Column("net_partition_id", sa.String(length=36), nullable=False),
        sa.Column("router_id", sa.String(length=36), nullable=False),
        sa.Column("nuage_router_id", sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(["net_partition_id"], ["net_partitions.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["router_id"], ["routers.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("net_partition_id", "router_id"),
    )
    op.create_table(
        "router_zone_mapping",
        sa.Column("router_id", sa.String(length=36), nullable=False),
        sa.Column("nuage_zone_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_user_id", sa.String(length=36), nullable=True),
        sa.Column("nuage_group_id", sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(["router_id"], ["routers.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("router_id"),
    )
Exemple #24
0
def upgrade():
    if not migration.schema_has_table('apic_ml2_ha_ipaddress_to_port_owner'):
        op.create_table(
            'apic_ml2_ha_ipaddress_to_port_owner',
            sa.Column('ha_ip_address', sa.String(length=64), nullable=False),
            sa.Column('port_id', sa.String(length=64), nullable=False),
            sa.ForeignKeyConstraint(
                ['port_id'], ['ports.id'],
                ondelete='CASCADE',
                name='apic_ml2_ha_ipaddress_to_port_owner_fk_port_id'),
            sa.PrimaryKeyConstraint('ha_ip_address', 'port_id'))
def upgrade():
    # These tables will be created even if the nuage plugin is not enabled.
    # This is fine as they would be created anyway by the healing migration.
    if migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        op.create_table(
            'nuage_floatingip_pool_mapping',
            sa.Column('fip_pool_id', sa.String(length=36), nullable=False),
            sa.Column('net_id', sa.String(length=36), nullable=True),
            sa.Column('router_id', sa.String(length=36), nullable=True),
            sa.ForeignKeyConstraint(['net_id'], ['networks.id'],
                                    ondelete='CASCADE'),
            sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                    ondelete='CASCADE'),
            sa.PrimaryKeyConstraint('fip_pool_id'),
        )
    if migration.schema_has_table('floatingips'):
        # In the database we are migrating from, the configured plugin
        # did not create the floatingips table.
        op.create_table(
            'nuage_floatingip_mapping',
            sa.Column('fip_id', sa.String(length=36), nullable=False),
            sa.Column('router_id', sa.String(length=36), nullable=True),
            sa.Column('nuage_fip_id', sa.String(length=36), nullable=True),
            sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'],
                                    ondelete='CASCADE'),
            sa.PrimaryKeyConstraint('fip_id'),
        )
    migration.rename_table_if_exists('net_partitions',
                                     'nuage_net_partitions')
    migration.rename_table_if_exists('net_partition_router_mapping',
                                     'nuage_net_partition_router_mapping')
    migration.rename_table_if_exists('router_zone_mapping',
                                     'nuage_router_zone_mapping')
    migration.rename_table_if_exists('subnet_l2dom_mapping',
                                     'nuage_subnet_l2dom_mapping')
    migration.rename_table_if_exists('port_mapping',
                                     'nuage_port_mapping')
    migration.rename_table_if_exists('routerroutes_mapping',
                                     'nuage_routerroutes_mapping')
Exemple #26
0
def upgrade():

    if not migration.schema_has_table('floatingips'):
        # In the database we are migrating from, the configured plugin
        # did not create the floatingips table.
        return

    op.add_column(
        'floatingips',
        sa.Column('last_known_router_id', sa.String(length=36), nullable=True))
    op.add_column('floatingips',
                  sa.Column('status', sa.String(length=16), nullable=True))
def upgrade():
    if not migration.schema_has_table("pools"):
        # The lbaas service plugin was not configured.
        return
    op.create_table(
        u"embrane_pool_port",
        sa.Column(u"pool_id", sa.String(length=36), nullable=False),
        sa.Column(u"port_id", sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(["pool_id"], [u"pools.id"], name=u"embrane_pool_port_ibfk_1"),
        sa.ForeignKeyConstraint(["port_id"], [u"ports.id"], name=u"embrane_pool_port_ibfk_2"),
        sa.PrimaryKeyConstraint(u"pool_id"),
    )
def upgrade():
    if not migration.schema_has_table('pools'):
        # The lbaas service plugin was not configured.
        return
    op.create_table(
        u'embrane_pool_port',
        sa.Column(u'pool_id', sa.String(length=36), nullable=False),
        sa.Column(u'port_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'],
                                name=u'embrane_pool_port_ibfk_1'),
        sa.ForeignKeyConstraint(['port_id'], [u'ports.id'],
                                name=u'embrane_pool_port_ibfk_2'),
        sa.PrimaryKeyConstraint(u'pool_id'))
Exemple #29
0
def upgrade():
    # These tables will be created even if the nuage plugin is not enabled.
    # This is fine as they would be created anyway by the healing migration.
    if migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        op.create_table(
            'nuage_floatingip_pool_mapping',
            sa.Column('fip_pool_id', sa.String(length=36), nullable=False),
            sa.Column('net_id', sa.String(length=36), nullable=True),
            sa.Column('router_id', sa.String(length=36), nullable=True),
            sa.ForeignKeyConstraint(['net_id'], ['networks.id'],
                                    ondelete='CASCADE'),
            sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                    ondelete='CASCADE'),
            sa.PrimaryKeyConstraint('fip_pool_id'),
        )
    if migration.schema_has_table('floatingips'):
        # In the database we are migrating from, the configured plugin
        # did not create the floatingips table.
        op.create_table(
            'nuage_floatingip_mapping',
            sa.Column('fip_id', sa.String(length=36), nullable=False),
            sa.Column('router_id', sa.String(length=36), nullable=True),
            sa.Column('nuage_fip_id', sa.String(length=36), nullable=True),
            sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'],
                                    ondelete='CASCADE'),
            sa.PrimaryKeyConstraint('fip_id'),
        )
    migration.rename_table_if_exists('net_partitions', 'nuage_net_partitions')
    migration.rename_table_if_exists('net_partition_router_mapping',
                                     'nuage_net_partition_router_mapping')
    migration.rename_table_if_exists('router_zone_mapping',
                                     'nuage_router_zone_mapping')
    migration.rename_table_if_exists('subnet_l2dom_mapping',
                                     'nuage_subnet_l2dom_mapping')
    migration.rename_table_if_exists('port_mapping', 'nuage_port_mapping')
    migration.rename_table_if_exists('routerroutes_mapping',
                                     'nuage_routerroutes_mapping')
Exemple #30
0
def upgrade():
    if migration.schema_has_table('lbaas_l7policies'):
        op.create_table(
            'nsxv_lbaas_l7policy_bindings',
            sa.Column('policy_id', sa.String(length=36), nullable=False),
            sa.Column('edge_id', sa.String(length=36), nullable=False),
            sa.Column('edge_app_rule_id', sa.String(length=36),
                      nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('policy_id'),
            sa.ForeignKeyConstraint(['policy_id'], ['lbaas_l7policies.id'],
                                    ondelete='CASCADE'))
def upgrade():
    if not migration.schema_has_table('pools'):
        # The lbaas service plugin was not configured.
        return
    op.create_table(
        u'embrane_pool_port',
        sa.Column(u'pool_id', sa.String(length=36), nullable=False),
        sa.Column(u'port_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'],
                                name=u'embrane_pool_port_ibfk_1'),
        sa.ForeignKeyConstraint(['port_id'], [u'ports.id'],
                                name=u'embrane_pool_port_ibfk_2'),
        sa.PrimaryKeyConstraint(u'pool_id'))
def upgrade():

    if not migration.schema_has_table('nvp_network_bindings'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any nvp tables.
        return

    op.rename_table('nvp_network_bindings', 'tz_network_bindings')
    op.rename_table('nvp_multi_provider_networks', 'multi_provider_networks')

    engine = op.get_bind().engine
    if engine.name == 'postgresql':
        op.execute("ALTER TYPE nvp_network_bindings_binding_type "
                   "RENAME TO tz_network_bindings_binding_type;")
def upgrade():

    if not migration.schema_has_table('nvp_network_bindings'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any nvp tables.
        return

    op.rename_table('nvp_network_bindings', 'tz_network_bindings')
    op.rename_table('nvp_multi_provider_networks', 'multi_provider_networks')

    engine = op.get_bind().engine
    if engine.name == 'postgresql':
        op.execute("ALTER TYPE nvp_network_bindings_binding_type "
                   "RENAME TO tz_network_bindings_binding_type;")
def upgrade():
    if migration.schema_has_table('lbaas_l7policies'):
        op.create_table(
            'nsxv_lbaas_l7policy_bindings',
            sa.Column('policy_id', sa.String(length=36), nullable=False),
            sa.Column('edge_id', sa.String(length=36), nullable=False),
            sa.Column('edge_app_rule_id',
                      sa.String(length=36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('policy_id'),
            sa.ForeignKeyConstraint(['policy_id'],
                                    ['lbaas_l7policies.id'],
                                    ondelete='CASCADE'))
Exemple #35
0
def upgrade():
    for table_name in [
            'nsxv3_lbaas_loadbalancers', 'nsxv3_lbaas_listeners',
            'nsxv3_lbaas_pools', 'nsxv3_lbaas_monitors', 'nsxv3_lbaas_l7rules',
            'nsxv3_lbaas_l7policies', 'nsxv_lbaas_loadbalancer_bindings',
            'nsxv_lbaas_listener_bindings', 'nsxv_lbaas_pool_bindings',
            'nsxv_lbaas_monitor_bindings', 'nsxv_lbaas_l7policy_bindings'
    ]:

        if migration.schema_has_table(table_name):
            inspector = reflection.Inspector.from_engine(op.get_bind())
            fk_constraint = inspector.get_foreign_keys(table_name)[0]
            op.drop_constraint(fk_constraint.get('name'),
                               table_name,
                               type_='foreignkey')
def upgrade():

    if not migration.schema_has_table('ofctenantmappings'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any ofc tables.
        return

    for table in ['ofctenantmappings', 'ofcnetworkmappings',
                  'ofcportmappings', 'ofcfiltermappings',
                  'ofcroutermappings',
                  ]:
        op.alter_column(table, 'quantum_id',
                        new_column_name='neutron_id',
                        existing_type=sa.String(length=36),
                        existing_nullable=False)
def upgrade():

    if not migration.schema_has_table('floatingips'):
        # In the database we are migrating from, the configured plugin
        # did not create the floatingips table.
        return

    op.add_column('floatingips',
                  sa.Column('last_known_router_id',
                            sa.String(length=36),
                            nullable=True))
    op.add_column('floatingips',
                  sa.Column('status',
                            sa.String(length=16),
                            nullable=True))
Exemple #38
0
def upgrade():
    if not migration.schema_has_table('ipsec_site_connections'):
        # The vpnaas service plugin was not configured.
        return
    op.create_table(
        'cisco_csr_identifier_map',
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('ipsec_site_conn_id', sa.String(length=64),
                  primary_key=True),
        sa.Column('csr_tunnel_id', sa.Integer(), nullable=False),
        sa.Column('csr_ike_policy_id', sa.Integer(), nullable=False),
        sa.Column('csr_ipsec_policy_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['ipsec_site_conn_id'],
                                ['ipsec_site_connections.id'],
                                ondelete='CASCADE'))
Exemple #39
0
def upgrade():
    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'))

    if migration.schema_has_table('quantum_nvp_port_mapping'):
        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 upgrade():
    if not schema_has_table('snabb_mechanism_props'):
        op.create_table(
            'snabb_mechanism_props',
            sa.Column('tenant_id', sa.String(length=255), nullable=True),
            sa.Column('subnet', sa.String(length=64), nullable=False),
            sa.Column('ip_address', sa.String(length=64), nullable=False),
            sa.PrimaryKeyConstraint('ip_address'),
            mysql_engine='InnoDB',
        )
        op.create_index(
            op.f('ix_snabb_mechanism_props_tenant_id'),
            'snabb_mechanism_props',
            ['tenant_id'],
            unique=False,
        )
def upgrade():
    if not migration.schema_has_table('ipsec_site_connections'):
        # The vpnaas service plugin was not configured.
        return
    op.create_table(
        'cisco_csr_identifier_map',
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('ipsec_site_conn_id', sa.String(length=64),
                  primary_key=True),
        sa.Column('csr_tunnel_id', sa.Integer(), nullable=False),
        sa.Column('csr_ike_policy_id', sa.Integer(), nullable=False),
        sa.Column('csr_ipsec_policy_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['ipsec_site_conn_id'],
                                ['ipsec_site_connections.id'],
                                ondelete='CASCADE')
    )
def upgrade():
    if not schema_has_table('snabb_mechanism_props'):
        op.create_table(
            'snabb_mechanism_props',
            sa.Column('tenant_id', sa.String(length=255), nullable=True),
            sa.Column('subnet', sa.String(length=64), nullable=False),
            sa.Column('ip_address', sa.String(length=64), nullable=False),
            sa.PrimaryKeyConstraint('ip_address'),
            mysql_engine='InnoDB',
        )
        op.create_index(
          op.f('ix_snabb_mechanism_props_tenant_id'),
          'snabb_mechanism_props',
          ['tenant_id'],
          unique=False,
        )
Exemple #43
0
def upgrade():
    if (migration.schema_has_table('lbaas_loadbalancers') and
            migration.schema_has_table('nsxv_lbaas_loadbalancer_bindings')):

        op.execute('delete from nsxv_lbaas_loadbalancer_bindings '
                   'where loadbalancer_id not in '
                   '(select id from lbaas_loadbalancers)')
        op.create_foreign_key('fk_lbaas_loadbalancers_id',
                              'nsxv_lbaas_loadbalancer_bindings',
                              'lbaas_loadbalancers', ['loadbalancer_id'],
                              ['id'],
                              ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_listeners')
            and migration.schema_has_table('nsxv_lbaas_listener_bindings')):

        op.execute('delete from nsxv_lbaas_listener_bindings '
                   'where listener_id  not in '
                   '(select id from lbaas_listeners)')
        op.create_foreign_key('fk_lbaas_listeners_id',
                              'nsxv_lbaas_listener_bindings',
                              'lbaas_listeners', ['listener_id'], ['id'],
                              ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_pools')
            and migration.schema_has_table('nsxv_lbaas_pool_bindings')):

        op.execute('delete from nsxv_lbaas_pool_bindings '
                   'where pool_id not in (select id from lbaas_pools)')
        op.create_foreign_key('fk_lbaas_pools_id',
                              'nsxv_lbaas_pool_bindings',
                              'lbaas_pools', ['pool_id'], ['id'],
                              ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_healthmonitors')
            and migration.schema_has_table('nsxv_lbaas_monitor_bindings')):

        op.execute('delete from nsxv_lbaas_monitor_bindings '
                   'where hm_id not in (select id from lbaas_healthmonitors)')
        op.create_foreign_key('fk_lbaas_healthmonitors_id',
                              'nsxv_lbaas_monitor_bindings',
                              'lbaas_healthmonitors', ['hm_id'], ['id'],
                              ondelete='CASCADE')
def upgrade():
    for table_name in ['nsxv3_lbaas_loadbalancers',
                       'nsxv3_lbaas_listeners',
                       'nsxv3_lbaas_pools',
                       'nsxv3_lbaas_monitors',
                       'nsxv3_lbaas_l7rules',
                       'nsxv3_lbaas_l7policies',
                       'nsxv_lbaas_loadbalancer_bindings',
                       'nsxv_lbaas_listener_bindings',
                       'nsxv_lbaas_pool_bindings',
                       'nsxv_lbaas_monitor_bindings',
                       'nsxv_lbaas_l7policy_bindings']:

        if migration.schema_has_table(table_name):
            inspector = reflection.Inspector.from_engine(op.get_bind())
            fk_constraint = inspector.get_foreign_keys(table_name)[0]
            op.drop_constraint(fk_constraint.get('name'), table_name,
                               type_='foreignkey')
Exemple #45
0
def upgrade():
    if migration.schema_has_table('poolstatisticss'):
        op.alter_column('poolstatisticss',
                        'bytes_in',
                        type_=sa.BigInteger(),
                        existing_type=sa.Integer())
        op.alter_column('poolstatisticss',
                        'bytes_out',
                        type_=sa.BigInteger(),
                        existing_type=sa.Integer())
        op.alter_column('poolstatisticss',
                        'active_connections',
                        type_=sa.BigInteger(),
                        existing_type=sa.Integer())
        op.alter_column('poolstatisticss',
                        'total_connections',
                        type_=sa.BigInteger(),
                        existing_type=sa.Integer())
def upgrade():
    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'))

    if migration.schema_has_table('quantum_nvp_port_mapping'):
        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 upgrade():

    if not migration.schema_has_table("securitygroups"):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create the securitygroups table.
        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")
def upgrade():
    if migration.schema_has_table('firewall_rules'):
        op.add_column('firewall_rules', sa.Column('mode', sa.String(length=12),
                                              nullable=True))
        op.add_column('firewall_rules', sa.Column('rule_profile', sa.String(length=1024),
                                              nullable=True))
        op.create_table('firewall_router_associations',
        sa.Column('fw_id', sa.String(length=36), nullable=False),
        sa.Column('router_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['fw_id'], ['firewalls.id'],
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('fw_id', 'router_id'),
        )

        op.execute(SQL_STATEMENT)
        op.execute(SQL_STATEMENT_2)
def upgrade():

    if not migration.schema_has_table('securitygroups'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create the securitygroups table.
        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")
def upgrade():

    if not migration.schema_has_table('ofctenantmappings'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any ofc tables.
        return

    for table in [
            'ofctenantmappings',
            'ofcnetworkmappings',
            'ofcportmappings',
            'ofcfiltermappings',
            'ofcroutermappings',
    ]:
        op.alter_column(table,
                        'quantum_id',
                        new_column_name='neutron_id',
                        existing_type=sa.String(length=36),
                        existing_nullable=False)
def upgrade():
    if (migration.schema_has_table('lbaas_loadbalancers') and
        migration.schema_has_table('nsxv_lbaas_loadbalancer_bindings')):

        op.execute('delete from nsxv_lbaas_loadbalancer_bindings '
                   'where loadbalancer_id not in '
                   '(select id from lbaas_loadbalancers)')
        op.create_foreign_key(
            'fk_lbaas_loadbalancers_id', 'nsxv_lbaas_loadbalancer_bindings',
            'lbaas_loadbalancers', ['loadbalancer_id'], ['id'],
            ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_listeners') and
        migration.schema_has_table('nsxv_lbaas_listener_bindings')):

        op.execute('delete from nsxv_lbaas_listener_bindings '
                   'where listener_id  not in '
                   '(select id from lbaas_listeners)')
        op.create_foreign_key(
            'fk_lbaas_listeners_id', 'nsxv_lbaas_listener_bindings',
            'lbaas_listeners', ['listener_id'], ['id'], ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_pools') and
        migration.schema_has_table('nsxv_lbaas_pool_bindings')):

        op.execute('delete from nsxv_lbaas_pool_bindings '
                   'where pool_id not in (select id from lbaas_pools)')
        op.create_foreign_key(
            'fk_lbaas_pools_id', 'nsxv_lbaas_pool_bindings',
            'lbaas_pools', ['pool_id'], ['id'], ondelete='CASCADE')

    if (migration.schema_has_table('lbaas_healthmonitors') and
        migration.schema_has_table('nsxv_lbaas_monitor_bindings')):

        op.execute('delete from nsxv_lbaas_monitor_bindings '
                   'where hm_id not in (select id from lbaas_healthmonitors)')
        op.create_foreign_key(
            'fk_lbaas_healthmonitors_id', 'nsxv_lbaas_monitor_bindings',
            'lbaas_healthmonitors', ['hm_id'], ['id'], ondelete='CASCADE')
def upgrade():

    if not migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        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")
def upgrade():

    if not migration.schema_has_table('routers'):
        # In the database we are migrating from, the configured plugin
        # did not create the routers table.
        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")
Exemple #54
0
def upgrade():
    if migration.schema_has_table('firewall_rules'):
        op.add_column('firewall_rules',
                      sa.Column('mode', sa.String(length=12), nullable=True))
        op.add_column(
            'firewall_rules',
            sa.Column('rule_profile', sa.String(length=1024), nullable=True))
        op.create_table(
            'firewall_router_associations',
            sa.Column('fw_id', sa.String(length=36), nullable=False),
            sa.Column('router_id', sa.String(length=36), nullable=False),
            sa.ForeignKeyConstraint(['fw_id'], ['firewalls.id'],
                                    ondelete='CASCADE'),
            sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                    ondelete='CASCADE'),
            sa.PrimaryKeyConstraint('fw_id', 'router_id'),
        )

        op.execute(SQL_STATEMENT)
        op.execute(SQL_STATEMENT_2)
def upgrade():

    if not migration.schema_has_table('networkgatewaydevices'):
        # Assume that, in the database we are migrating from, the
        # configured plugin did not create any nsx tables.
        return

    op.create_table(
        'networkgatewaydevicereferences',
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('network_gateway_id', sa.String(length=36), nullable=True),
        sa.Column('interface_name', sa.String(length=64), nullable=True),
        sa.ForeignKeyConstraint(['network_gateway_id'], ['networkgateways.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', 'network_gateway_id', 'interface_name'))
    # Copy data from networkgatewaydevices into networkgatewaydevicereference
    op.execute("INSERT INTO networkgatewaydevicereferences SELECT "
               "id, network_gateway_id, interface_name FROM "
               "networkgatewaydevices")
    # drop networkgatewaydevices
    op.drop_table('networkgatewaydevices')
    op.create_table(
        'networkgatewaydevices',
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('nsx_id', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('connector_type', sa.String(length=10), nullable=True),
        sa.Column('connector_ip', sa.String(length=64), nullable=True),
        sa.Column('status', sa.String(length=16), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    # Create a networkgatewaydevice for each existing reference.
    # For existing references nsx_id == neutron_id
    # Do not fill conenctor info as they would be unknown
    op.execute("INSERT INTO networkgatewaydevices (id, nsx_id, tenant_id) "
               "SELECT gw_dev_ref.id, gw_dev_ref.id as nsx_id, tenant_id "
               "FROM networkgatewaydevicereferences AS gw_dev_ref "
               "INNER JOIN networkgateways AS net_gw ON "
               "gw_dev_ref.network_gateway_id=net_gw.id")
def upgrade():
    if migration.schema_has_table('meteringlabels'):
        op.alter_column('meteringlabels', 'description', type_=sa.String(1024),
                        existing_nullable=True)
    else:
        metering_init_ops.create_meteringlabels()
Exemple #57
0
 def test_schema_has_table(self):
     self._prepare_mocked_sqlalchemy_inspector()
     self.assertTrue(migration.schema_has_table('foo'))
def upgrade():
    op.create_table('cisco_hosting_device_templates',
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('enabled', sa.Boolean(), nullable=False,
                  server_default=sa.sql.false()),
        sa.Column('host_category', sa.String(length=255), nullable=False),
        sa.Column('service_types', sa.String(length=255), nullable=True),
        sa.Column('image', sa.String(length=255), nullable=True),
        sa.Column('flavor', sa.String(length=255), nullable=True),
        sa.Column('default_credentials_id', sa.String(length=36),
                  nullable=True),
        sa.Column('configuration_mechanism', sa.String(length=255),
                  nullable=True),
        sa.Column('protocol_port', sa.Integer(), nullable=True),
        sa.Column('booting_time', sa.Integer(), nullable=True,
                  server_default='0'),
        sa.Column('slot_capacity', sa.Integer(), autoincrement=False,
                  nullable=False),
        sa.Column('desired_slots_free', sa.Integer(), autoincrement=False,
                  nullable=False, server_default='0'),
        sa.Column('tenant_bound', sa.String(length=512), nullable=True),
        sa.Column('device_driver', sa.String(length=255), nullable=False),
        sa.Column('plugging_driver', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table('cisco_slot_allocations',
        sa.Column('template_id', sa.String(length=36), nullable=False),
        sa.Column('hosting_device_id', sa.String(length=36), nullable=False),
        sa.Column('logical_resource_type', sa.String(155), nullable=False),
        sa.Column('logical_resource_service', sa.String(155), nullable=False),
        sa.Column('logical_resource_id', sa.String(length=36), nullable=False),
        sa.Column('logical_resource_owner', sa.String(length=36),
                  nullable=False),
        sa.Column('num_allocated', sa.Integer(), autoincrement=False,
                  nullable=False),
        sa.Column('tenant_bound', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['template_id'],
                                ['cisco_hosting_device_templates.id']),
        sa.ForeignKeyConstraint(['hosting_device_id'],
                                ['cisco_hosting_devices.id']),
        sa.PrimaryKeyConstraint('logical_resource_id')
    )
    if migration.schema_has_table('cisco_hosting_devices'):
        op.add_column('cisco_hosting_devices',
                      sa.Column('template_id', sa.String(length=36),
                                nullable=False))
        op.create_foreign_key('cisco_hosting_devices_ibfk_3',
                              source_table='cisco_hosting_devices',
                              referent_table='cisco_hosting_device_templates',
                              local_cols=['template_id'], remote_cols=['id'])
        op.create_index('template_id', 'cisco_hosting_devices',
                        ['template_id'])
        op.add_column('cisco_hosting_devices',
                      sa.Column('credentials_id', sa.String(length=36),
                                nullable=True))
        op.add_column('cisco_hosting_devices',
                      sa.Column('name', sa.String(255), nullable=True))
        op.add_column('cisco_hosting_devices',
                      sa.Column('description', sa.String(255), nullable=True))
        op.add_column('cisco_hosting_devices',
                      sa.Column('management_ip_address', sa.String(255),
                                nullable=True))
        op.add_column('cisco_hosting_devices',
                      sa.Column('tenant_bound', sa.String(length=36),
                                nullable=True))
        op.add_column('cisco_hosting_devices',
                      sa.Column('auto_delete', sa.Boolean(), nullable=False,
                                server_default=sa.sql.false()))
    op.create_index(op.f('ix_cisco_hosting_device_templates_tenant_id'),
                    'cisco_hosting_device_templates', ['tenant_id'],
                    unique=False)