From f0be5f1a83c21a7ef6ff902fa88550cb286d15d9 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 17 Jul 2020 16:18:09 +0000 Subject: [PATCH] Squash alchemy Liberty branch This patch squashes the DB alchemy migration from Liberty branch. The contract and expand migration steps are added to the initial operation files. The unneeded tables or parameters are not created. Now the starting migration milestone is Mitaka. Change-Id: Ia5bd25411149d1c475c142a60814c6daa8566cae --- neutron/db/migration/__init__.py | 2 - .../alembic_migrations/cisco_init_ops.py | 133 ------------------ .../alembic_migrations/core_init_ops.py | 40 +++++- ...6151_neutrodb_ipam.py => ipam_init_ops.py} | 16 +-- .../alembic_migrations/lb_init_ops.py | 38 ----- .../alembic_migrations/ml2_init_ops.py | 17 +++ .../alembic_migrations/nsxv_initial_opts.py | 13 ++ .../other_extensions_init_ops.py | 42 ++++++ .../other_plugins_init_ops.py | 17 --- .../alembic_migrations/ovs_init_ops.py | 54 ------- ...f051_qos_db_changes.py => qos_init_ops.py} | 16 +-- ...a5c4f_rbac_network.py => rbac_init_ops.py} | 16 +-- ...11926bcfe72d_add_geneve_ml2_type_driver.py | 57 -------- .../2a16083502f3_metaplugin_removal.py | 33 ----- .../2e5352a0ad4d_add_missing_foreign_keys.py | 44 ------ .../liberty/contract/30018084ec99_initial.py | 31 ---- ...f11ca47297_drop_cisco_monolithic_tables.py | 49 ------- .../contract/4ffceebfada_rbac_network.py | 69 --------- .../5498d17be016_drop_legacy_ovs_and_lb.py | 37 ----- ...f79_address_scope_support_in_subnetpool.py | 36 ----- .../1c844d1677f7_dns_nameservers_order.py | 35 ----- .../expand/26c371498592_subnetpool_hash.py | 35 ----- .../liberty/expand/31337ec0ffee_flavors.py | 62 -------- .../34af2b5c5a59_add_dns_name_to_port.py | 42 ------ .../expand/354db87e3225_nsxv_vdr_metadata.py | 47 ------- .../expand/45f955889773_quota_usage.py | 45 ------ .../expand/52c5312f6baf_address_scopes.py | 36 ----- .../expand/9859ac9c136_quota_reservations.py | 47 ------- .../{kilo_initial.py => liberty_initial.py} | 16 ++- .../1b294093239c_remove_embrane_plugin.py | 7 +- .../expand/59cb5b6cf4d_availability_zone.py | 7 +- neutron/db/migration/cli.py | 23 --- neutron/tests/unit/db/test_migration.py | 26 ++-- 33 files changed, 148 insertions(+), 1040 deletions(-) rename neutron/db/migration/alembic_migrations/{versions/liberty/expand/599c6a226151_neutrodb_ipam.py => ipam_init_ops.py} (91%) delete mode 100644 neutron/db/migration/alembic_migrations/lb_init_ops.py delete mode 100644 neutron/db/migration/alembic_migrations/ovs_init_ops.py rename neutron/db/migration/alembic_migrations/{versions/liberty/expand/48153cb5f051_qos_db_changes.py => qos_init_ops.py} (88%) rename neutron/db/migration/alembic_migrations/{versions/liberty/expand/8675309a5c4f_rbac_network.py => rbac_init_ops.py} (84%) delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/11926bcfe72d_add_geneve_ml2_type_driver.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/2a16083502f3_metaplugin_removal.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/30018084ec99_initial.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/4af11ca47297_drop_cisco_monolithic_tables.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/4ffceebfada_rbac_network.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/contract/5498d17be016_drop_legacy_ovs_and_lb.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/1b4c6e320f79_address_scope_support_in_subnetpool.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/1c844d1677f7_dns_nameservers_order.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/26c371498592_subnetpool_hash.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/31337ec0ffee_flavors.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/34af2b5c5a59_add_dns_name_to_port.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/354db87e3225_nsxv_vdr_metadata.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/45f955889773_quota_usage.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/52c5312f6baf_address_scopes.py delete mode 100644 neutron/db/migration/alembic_migrations/versions/liberty/expand/9859ac9c136_quota_reservations.py rename neutron/db/migration/alembic_migrations/versions/{kilo_initial.py => liberty_initial.py} (88%) diff --git a/neutron/db/migration/__init__.py b/neutron/db/migration/__init__.py index e4186044476..91209b3b7a1 100644 --- a/neutron/db/migration/__init__.py +++ b/neutron/db/migration/__init__.py @@ -23,7 +23,6 @@ from sqlalchemy.engine import reflection from neutron._i18n import _ # Neutron milestones for upgrade aliases -LIBERTY = 'liberty' MITAKA = 'mitaka' NEWTON = 'newton' OCATA = 'ocata' @@ -37,7 +36,6 @@ VICTORIA = 'victoria' NEUTRON_MILESTONES = [ # earlier milestones were not tagged - LIBERTY, MITAKA, NEWTON, OCATA, diff --git a/neutron/db/migration/alembic_migrations/cisco_init_ops.py b/neutron/db/migration/alembic_migrations/cisco_init_ops.py index cfc5aaabb71..b3983dfcdcd 100644 --- a/neutron/db/migration/alembic_migrations/cisco_init_ops.py +++ b/neutron/db/migration/alembic_migrations/cisco_init_ops.py @@ -26,139 +26,6 @@ network_profile_type = sa.Enum('vlan', 'vxlan', name='network_profile_type') def upgrade(): - op.create_table( - 'cisco_policy_profiles', - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('name', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('id')) - - op.create_table( - 'cisco_network_profiles', - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('name', sa.String(length=255), nullable=True), - sa.Column('segment_type', segment_type, nullable=False), - sa.Column('sub_type', sa.String(length=255), nullable=True), - sa.Column('segment_range', sa.String(length=255), nullable=True), - sa.Column('multicast_ip_index', sa.Integer(), nullable=True, - server_default='0'), - sa.Column('multicast_ip_range', sa.String(length=255), nullable=True), - sa.Column('physical_network', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('id')) - - op.create_table( - 'cisco_n1kv_vxlan_allocations', - sa.Column('vxlan_id', sa.Integer(), autoincrement=False, - nullable=False), - sa.Column('allocated', sa.Boolean(), nullable=False, - server_default=sa.sql.false()), - sa.Column('network_profile_id', sa.String(length=36), nullable=False), - sa.ForeignKeyConstraint(['network_profile_id'], - ['cisco_network_profiles.id'], - ondelete='CASCADE', - name='cisco_n1kv_vxlan_allocations_ibfk_1'), - sa.PrimaryKeyConstraint('vxlan_id')) - - op.create_table( - 'cisco_n1kv_vlan_allocations', - sa.Column('physical_network', sa.String(length=64), nullable=False), - sa.Column('vlan_id', sa.Integer(), autoincrement=False, - nullable=False), - sa.Column('allocated', sa.Boolean(), autoincrement=False, - nullable=False, server_default=sa.sql.false()), - sa.Column('network_profile_id', sa.String(length=36), nullable=False), - sa.PrimaryKeyConstraint('physical_network', 'vlan_id'), - sa.ForeignKeyConstraint(['network_profile_id'], - ['cisco_network_profiles.id'], - ondelete='CASCADE', - name='cisco_n1kv_vlan_allocations_ibfk_1')) - - op.create_table( - 'cisco_credentials', - sa.Column('credential_id', sa.String(length=255), nullable=True), - sa.Column('credential_name', sa.String(length=255), nullable=False), - sa.Column('user_name', sa.String(length=255), nullable=True), - sa.Column('password', sa.String(length=255), nullable=True), - sa.Column('type', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('credential_name')) - - op.create_table( - 'cisco_qos_policies', - sa.Column('qos_id', sa.String(length=255), nullable=True), - sa.Column('tenant_id', sa.String(length=255), nullable=False), - sa.Column('qos_name', sa.String(length=255), nullable=False), - sa.Column('qos_desc', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('tenant_id', 'qos_name')) - - op.create_table( - 'cisco_n1kv_profile_bindings', - sa.Column('profile_type', profile_type, nullable=True), - sa.Column('tenant_id', sa.String(length=36), nullable=False, - server_default='TENANT_ID_NOT_SET'), - sa.Column('profile_id', sa.String(length=36), nullable=False), - sa.PrimaryKeyConstraint('tenant_id', 'profile_id')) - - op.create_table( - 'cisco_n1kv_vmnetworks', - sa.Column('name', sa.String(length=80), nullable=False), - sa.Column('profile_id', sa.String(length=36), nullable=True), - sa.Column('network_id', sa.String(length=36), nullable=True), - sa.Column('port_count', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['profile_id'], - ['cisco_policy_profiles.id'], ), - sa.PrimaryKeyConstraint('name')) - - 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_provider_networks', - sa.Column('network_id', sa.String(length=36), nullable=False), - sa.Column('network_type', sa.String(length=255), nullable=False), - sa.Column('segmentation_id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['network_id'], ['networks.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('network_id')) - - 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.create_table( - 'cisco_n1kv_network_bindings', - sa.Column('network_id', sa.String(length=36), nullable=False), - sa.Column('network_type', sa.String(length=32), nullable=False), - sa.Column('physical_network', sa.String(length=64), nullable=True), - sa.Column('segmentation_id', sa.Integer(), nullable=True), - sa.Column('multicast_ip', sa.String(length=32), nullable=True), - sa.Column('profile_id', sa.String(length=36), nullable=True), - sa.ForeignKeyConstraint(['network_id'], ['networks.id'], - ondelete='CASCADE'), - sa.ForeignKeyConstraint(['profile_id'], - ['cisco_network_profiles.id']), - sa.PrimaryKeyConstraint('network_id')) - - op.create_table( - 'cisco_n1kv_port_bindings', - sa.Column('port_id', sa.String(length=36), nullable=False), - sa.Column('profile_id', sa.String(length=36), nullable=True), - sa.ForeignKeyConstraint(['port_id'], ['ports.id'], - ondelete='CASCADE'), - sa.ForeignKeyConstraint(['profile_id'], ['cisco_policy_profiles.id']), - sa.PrimaryKeyConstraint('port_id')) - op.create_table( 'cisco_csr_identifier_map', sa.Column('tenant_id', sa.String(length=255), nullable=True), diff --git a/neutron/db/migration/alembic_migrations/core_init_ops.py b/neutron/db/migration/alembic_migrations/core_init_ops.py index 57b3b436238..ae669d85c8f 100644 --- a/neutron/db/migration/alembic_migrations/core_init_ops.py +++ b/neutron/db/migration/alembic_migrations/core_init_ops.py @@ -15,6 +15,7 @@ # Initial operations for core resources from alembic import op +from neutron_lib.db import constants import sqlalchemy as sa @@ -27,7 +28,6 @@ def upgrade(): sa.Column('name', sa.String(length=255), nullable=True), sa.Column('status', sa.String(length=16), nullable=True), sa.Column('admin_state_up', sa.Boolean(), nullable=True), - sa.Column('shared', sa.Boolean(), nullable=True), sa.Column('mtu', sa.Integer(), nullable=True), sa.Column('vlan_transparent', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id')) @@ -44,6 +44,8 @@ def upgrade(): sa.Column('status', sa.String(length=16), nullable=False), sa.Column('device_id', sa.String(length=255), nullable=False), sa.Column('device_owner', sa.String(length=255), nullable=False), + sa.Column('dns_name', sa.String(length=constants.FQDN_FIELD_SIZE), + nullable=True), sa.ForeignKeyConstraint(['network_id'], ['networks.id']), sa.UniqueConstraint('network_id', 'mac_address', name='uniq_ports0network_id0mac_address'), @@ -64,7 +66,6 @@ def upgrade(): sa.Column('cidr', sa.String(length=64), nullable=False), sa.Column('gateway_ip', sa.String(length=64), nullable=True), sa.Column('enable_dhcp', sa.Boolean(), nullable=True), - sa.Column('shared', sa.Boolean(), nullable=True), sa.Column('ipv6_ra_mode', sa.Enum('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless', name='ipv6_ra_modes'), @@ -82,6 +83,7 @@ def upgrade(): 'dnsnameservers', sa.Column('address', sa.String(length=128), nullable=False), sa.Column('subnet_id', sa.String(length=36), nullable=False), + sa.Column('order', sa.Integer(), server_default='0', nullable=False), sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('address', 'subnet_id')) @@ -142,3 +144,37 @@ def upgrade(): sa.ForeignKeyConstraint(['network_id'], ['networks.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id')) + + op.create_table( + 'flavors', + sa.Column('id', sa.String(36)), + sa.Column('name', sa.String(255)), + sa.Column('description', sa.String(1024)), + sa.Column('enabled', sa.Boolean, nullable=False, + server_default=sa.sql.true()), + sa.Column('service_type', sa.String(36), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + + op.create_table( + 'serviceprofiles', + sa.Column('id', sa.String(36)), + sa.Column('description', sa.String(1024)), + sa.Column('driver', sa.String(1024), nullable=False), + sa.Column('enabled', sa.Boolean, nullable=False, + server_default=sa.sql.true()), + sa.Column('metainfo', sa.String(4096)), + sa.PrimaryKeyConstraint('id') + ) + + op.create_table( + 'flavorserviceprofilebindings', + sa.Column('service_profile_id', sa.String(36), nullable=False), + sa.Column('flavor_id', sa.String(36), nullable=False), + sa.ForeignKeyConstraint(['service_profile_id'], + ['serviceprofiles.id'], + ondelete='CASCADE'), + sa.ForeignKeyConstraint(['flavor_id'], ['flavors.id'], + ondelete='CASCADE'), + sa.PrimaryKeyConstraint('service_profile_id', 'flavor_id') + ) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/599c6a226151_neutrodb_ipam.py b/neutron/db/migration/alembic_migrations/ipam_init_ops.py similarity index 91% rename from neutron/db/migration/alembic_migrations/versions/liberty/expand/599c6a226151_neutrodb_ipam.py rename to neutron/db/migration/alembic_migrations/ipam_init_ops.py index 995cb47801c..978ef25da24 100644 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/599c6a226151_neutrodb_ipam.py +++ b/neutron/db/migration/alembic_migrations/ipam_init_ops.py @@ -1,4 +1,5 @@ -# Copyright 2015 OpenStack Foundation +# Copyright (c) 2020 Red Hat, Inc. +# All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -11,23 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# from alembic import op import sqlalchemy as sa -"""neutrodb_ipam - -Revision ID: 599c6a226151 -Revises: 354db87e3225 -Create Date: 2015-03-08 18:12:08.962378 - -""" - -# revision identifiers, used by Alembic. -revision = '599c6a226151' -down_revision = '354db87e3225' - def upgrade(): op.create_table( diff --git a/neutron/db/migration/alembic_migrations/lb_init_ops.py b/neutron/db/migration/alembic_migrations/lb_init_ops.py deleted file mode 100644 index f97961fdf86..00000000000 --- a/neutron/db/migration/alembic_migrations/lb_init_ops.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -# Initial operations for the port security extension - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.create_table( - 'network_states', - sa.Column('physical_network', sa.String(length=64), nullable=False), - sa.Column('vlan_id', sa.Integer(), autoincrement=False, - nullable=False), - sa.Column('allocated', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('physical_network', 'vlan_id')) - - op.create_table( - 'network_bindings', - sa.Column('network_id', sa.String(length=36), nullable=False), - sa.Column('physical_network', sa.String(length=64), nullable=True), - sa.Column('vlan_id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['network_id'], ['networks.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('network_id')) diff --git a/neutron/db/migration/alembic_migrations/ml2_init_ops.py b/neutron/db/migration/alembic_migrations/ml2_init_ops.py index c2b0f0d6ac7..0395376e9a5 100644 --- a/neutron/db/migration/alembic_migrations/ml2_init_ops.py +++ b/neutron/db/migration/alembic_migrations/ml2_init_ops.py @@ -47,6 +47,14 @@ def upgrade(): sa.UniqueConstraint('host', name='unique_ml2_gre_endpoints0host'), sa.PrimaryKeyConstraint('ip_address')) + op.create_table( + 'ml2_geneve_endpoints', + sa.Column('ip_address', sa.String(length=64), nullable=False), + sa.Column('host', sa.String(length=255), nullable=True), + sa.PrimaryKeyConstraint('ip_address'), + sa.UniqueConstraint('host', name='unique_ml2_geneve_endpoints0host'), + ) + op.create_table( 'ml2_vxlan_allocations', sa.Column('vxlan_vni', sa.Integer(), autoincrement=False, @@ -63,6 +71,15 @@ def upgrade(): server_default=sa.sql.false(), index=True), sa.PrimaryKeyConstraint('gre_id')) + op.create_table( + 'ml2_geneve_allocations', + sa.Column('geneve_vni', sa.Integer(), + autoincrement=False, nullable=False), + sa.Column('allocated', sa.Boolean(), nullable=False, + server_default=sa.sql.false(), index=True), + sa.PrimaryKeyConstraint('geneve_vni'), + ) + op.create_table( 'ml2_flat_allocations', sa.Column('physical_network', sa.String(length=64), nullable=False), diff --git a/neutron/db/migration/alembic_migrations/nsxv_initial_opts.py b/neutron/db/migration/alembic_migrations/nsxv_initial_opts.py index 7143aa89242..f58e48bc62f 100644 --- a/neutron/db/migration/alembic_migrations/nsxv_initial_opts.py +++ b/neutron/db/migration/alembic_migrations/nsxv_initial_opts.py @@ -135,3 +135,16 @@ def upgrade(): sa.ForeignKeyConstraint(['router_id'], ['routers.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('router_id')) + + op.create_table( + 'nsxv_vdr_dhcp_bindings', + sa.Column('vdr_router_id', sa.String(length=36), nullable=False), + sa.Column('dhcp_router_id', sa.String(length=36), nullable=False), + sa.Column('dhcp_edge_id', sa.String(length=36), nullable=False), + sa.PrimaryKeyConstraint('vdr_router_id'), + sa.UniqueConstraint( + 'dhcp_router_id', + name='unique_nsxv_vdr_dhcp_bindings0dhcp_router_id'), + sa.UniqueConstraint( + 'dhcp_edge_id', + name='unique_nsxv_vdr_dhcp_bindings0dhcp_edge_id')) diff --git a/neutron/db/migration/alembic_migrations/other_extensions_init_ops.py b/neutron/db/migration/alembic_migrations/other_extensions_init_ops.py index abff73a8c90..65525fef659 100644 --- a/neutron/db/migration/alembic_migrations/other_extensions_init_ops.py +++ b/neutron/db/migration/alembic_migrations/other_extensions_init_ops.py @@ -43,6 +43,35 @@ def upgrade(): sa.Column('limit', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id')) + op.create_table( + 'quotausages', + sa.Column('tenant_id', sa.String(length=255), + nullable=False, primary_key=True, index=True), + sa.Column('resource', sa.String(length=255), + nullable=False, primary_key=True, index=True), + sa.Column('dirty', sa.Boolean(), nullable=False, + server_default=sa.sql.false()), + sa.Column('in_use', sa.Integer(), nullable=False, + server_default='0'), + sa.Column('reserved', sa.Integer(), nullable=False, + server_default='0')) + + op.create_table( + 'reservations', + sa.Column('id', sa.String(length=36), nullable=False), + sa.Column('tenant_id', sa.String(length=255), nullable=True), + sa.Column('expiration', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id')) + + op.create_table( + 'resourcedeltas', + sa.Column('resource', sa.String(length=255), nullable=False), + sa.Column('reservation_id', sa.String(length=36), nullable=False), + sa.Column('amount', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['reservation_id'], ['reservations.id'], + ondelete='CASCADE'), + sa.PrimaryKeyConstraint('resource', 'reservation_id')) + op.create_table( 'allowedaddresspairs', sa.Column('port_id', sa.String(length=36), nullable=False), @@ -87,6 +116,10 @@ def upgrade(): sa.Column('max_prefixlen', sa.Integer(), nullable=False), sa.Column('shared', sa.Boolean(), nullable=False), sa.Column('default_quota', sa.Integer(), nullable=True), + sa.Column('address_scope_id', sa.String(length=36), + nullable=True), + sa.Column('hash', sa.String(36), nullable=False, + server_default=''), sa.PrimaryKeyConstraint('id')) op.create_table('subnetpoolprefixes', sa.Column('cidr', sa.String(length=64), nullable=False), @@ -97,3 +130,12 @@ def upgrade(): ['subnetpools.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('cidr', 'subnetpool_id')) + + op.create_table( + 'address_scopes', + sa.Column('id', sa.String(length=36), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.Column('tenant_id', sa.String(length=255), nullable=True, + index=True), + sa.Column('shared', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('id')) diff --git a/neutron/db/migration/alembic_migrations/other_plugins_init_ops.py b/neutron/db/migration/alembic_migrations/other_plugins_init_ops.py index db044015a1a..047bf49cad6 100644 --- a/neutron/db/migration/alembic_migrations/other_plugins_init_ops.py +++ b/neutron/db/migration/alembic_migrations/other_plugins_init_ops.py @@ -23,23 +23,6 @@ import sqlalchemy as sa def upgrade(): - # metaplugin - op.create_table( - 'networkflavors', - sa.Column('flavor', sa.String(length=255), nullable=True), - sa.Column('network_id', sa.String(length=36), nullable=False), - sa.ForeignKeyConstraint(['network_id'], ['networks.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('network_id')) - - op.create_table( - 'routerflavors', - sa.Column('flavor', sa.String(length=255), nullable=True), - sa.Column('router_id', sa.String(length=36), nullable=False), - sa.ForeignKeyConstraint(['router_id'], ['routers.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('router_id')) - # big switch op.create_table( 'routerrules', diff --git a/neutron/db/migration/alembic_migrations/ovs_init_ops.py b/neutron/db/migration/alembic_migrations/ovs_init_ops.py deleted file mode 100644 index c02a3248941..00000000000 --- a/neutron/db/migration/alembic_migrations/ovs_init_ops.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2014 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -# Initial operations for the OVS plugin - - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.create_table( - 'ovs_tunnel_endpoints', - sa.Column('ip_address', sa.String(length=64), nullable=False), - sa.Column('id', sa.Integer(), nullable=False), - sa.PrimaryKeyConstraint('ip_address'), - sa.UniqueConstraint('id', name='uniq_ovs_tunnel_endpoints0id')) - - op.create_table( - 'ovs_tunnel_allocations', - sa.Column('tunnel_id', sa.Integer(), autoincrement=False, - nullable=False), - sa.Column('allocated', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('tunnel_id')) - - op.create_table( - 'ovs_vlan_allocations', - sa.Column('physical_network', sa.String(length=64), nullable=False), - sa.Column('vlan_id', sa.Integer(), autoincrement=False, - nullable=False), - sa.Column('allocated', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('physical_network', 'vlan_id')) - - op.create_table( - 'ovs_network_bindings', - sa.Column('network_id', sa.String(length=36), nullable=False), - sa.Column('network_type', sa.String(length=32), nullable=False), - sa.Column('physical_network', sa.String(length=64), nullable=True), - sa.Column('segmentation_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['network_id'], ['networks.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('network_id')) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/48153cb5f051_qos_db_changes.py b/neutron/db/migration/alembic_migrations/qos_init_ops.py similarity index 88% rename from neutron/db/migration/alembic_migrations/versions/liberty/expand/48153cb5f051_qos_db_changes.py rename to neutron/db/migration/alembic_migrations/qos_init_ops.py index 4a88aa939bf..8da78010b5a 100644 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/48153cb5f051_qos_db_changes.py +++ b/neutron/db/migration/alembic_migrations/qos_init_ops.py @@ -1,4 +1,5 @@ -# Copyright 2015 Huawei Technologies India Pvt Ltd, Inc +# Copyright (c) 2020 Red Hat, Inc. +# All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -11,23 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# from alembic import op import sqlalchemy as sa -"""qos db changes - -Revision ID: 48153cb5f051 -Revises: 1b4c6e320f79 -Create Date: 2015-06-24 17:03:34.965101 - -""" - -# revision identifiers, used by Alembic. -revision = '48153cb5f051' -down_revision = '1b4c6e320f79' - def upgrade(): op.create_table( diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/8675309a5c4f_rbac_network.py b/neutron/db/migration/alembic_migrations/rbac_init_ops.py similarity index 84% rename from neutron/db/migration/alembic_migrations/versions/liberty/expand/8675309a5c4f_rbac_network.py rename to neutron/db/migration/alembic_migrations/rbac_init_ops.py index 49f50e6d196..0c08a525e39 100644 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/8675309a5c4f_rbac_network.py +++ b/neutron/db/migration/alembic_migrations/rbac_init_ops.py @@ -1,4 +1,5 @@ -# Copyright 2015 OpenStack Foundation +# Copyright (c) 2020 Red Hat, Inc. +# All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -11,23 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# from alembic import op import sqlalchemy as sa -"""network_rbac - -Revision ID: 8675309a5c4f -Revises: 313373c0ffee -Create Date: 2015-06-14 13:12:04.012457 - -""" - -# revision identifiers, used by Alembic. -revision = '8675309a5c4f' -down_revision = '313373c0ffee' - def upgrade(): op.create_table( diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/11926bcfe72d_add_geneve_ml2_type_driver.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/11926bcfe72d_add_geneve_ml2_type_driver.py deleted file mode 100644 index 761bd484cac..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/11926bcfe72d_add_geneve_ml2_type_driver.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""add geneve ml2 type driver - -Revision ID: 11926bcfe72d -Revises: 2e5352a0ad4d -Create Date: 2015-08-27 19:56:16.356522 - -""" - -# revision identifiers, used by Alembic. -revision = '11926bcfe72d' -down_revision = '2e5352a0ad4d' - - -def contract_creation_exceptions(): - """These elements were created by mistake in the contract branch.""" - return { - sa.Table: ['ml2_geneve_allocations', 'ml2_geneve_endpoints'], - sa.Index: ['ml2_geneve_allocations'] - } - - -def upgrade(): - op.create_table( - 'ml2_geneve_allocations', - sa.Column('geneve_vni', sa.Integer(), - autoincrement=False, nullable=False), - sa.Column('allocated', sa.Boolean(), - server_default=sa.sql.false(), nullable=False), - sa.PrimaryKeyConstraint('geneve_vni'), - ) - op.create_index(op.f('ix_ml2_geneve_allocations_allocated'), - 'ml2_geneve_allocations', ['allocated'], unique=False) - op.create_table( - 'ml2_geneve_endpoints', - sa.Column('ip_address', sa.String(length=64), nullable=False), - sa.Column('host', sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint('ip_address'), - sa.UniqueConstraint('host', name='unique_ml2_geneve_endpoints0host'), - ) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2a16083502f3_metaplugin_removal.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/2a16083502f3_metaplugin_removal.py deleted file mode 100644 index 2b424f6a0a8..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2a16083502f3_metaplugin_removal.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op - -"""Metaplugin removal - -Revision ID: 2a16083502f3 -Revises: 5498d17be016 -Create Date: 2015-06-16 09:11:10.488566 - -""" - -# revision identifiers, used by Alembic. -revision = '2a16083502f3' -down_revision = '5498d17be016' - - -def upgrade(): - op.drop_table('networkflavors') - op.drop_table('routerflavors') diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py deleted file mode 100644 index b02d5208a0d..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2015 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -from sqlalchemy.engine import reflection - -from neutron.db import migration - -"""Add missing foreign keys - -Revision ID: 2e5352a0ad4d -Revises: 2a16083502f3 -Create Date: 2015-08-20 12:43:09.110427 - -""" - -# revision identifiers, used by Alembic. -revision = '2e5352a0ad4d' -down_revision = '2a16083502f3' - - -TABLE_NAME = 'flavorserviceprofilebindings' - - -def upgrade(): - inspector = reflection.Inspector.from_engine(op.get_bind()) - fk_constraints = inspector.get_foreign_keys(TABLE_NAME) - for fk in fk_constraints: - fk['options']['ondelete'] = 'CASCADE' - - migration.remove_foreign_keys(TABLE_NAME, fk_constraints) - migration.create_foreign_keys(TABLE_NAME, fk_constraints) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/30018084ec99_initial.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/30018084ec99_initial.py deleted file mode 100644 index 6b813d0e3ed..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/30018084ec99_initial.py +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from neutron.db.migration import cli - -"""Initial no-op Liberty contract rule. - -Revision ID: 30018084ec99 -Revises: None -Create Date: 2015-06-22 00:00:00.000000 - -""" - -# revision identifiers, used by Alembic. -revision = '30018084ec99' -down_revision = 'kilo' -branch_labels = (cli.CONTRACT_BRANCH,) - - -def upgrade(): - pass diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/4af11ca47297_drop_cisco_monolithic_tables.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/4af11ca47297_drop_cisco_monolithic_tables.py deleted file mode 100644 index bb667acdbdf..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/4af11ca47297_drop_cisco_monolithic_tables.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2015 Cisco Systems, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op - -from neutron.db import migration - -"""Drop cisco monolithic tables - -Revision ID: 4af11ca47297 -Revises: 11926bcfe72d -Create Date: 2015-08-13 08:01:19.709839 - -""" - -# revision identifiers, used by Alembic. -revision = '4af11ca47297' -down_revision = '11926bcfe72d' - -# milestone identifier, used by neutron-db-manage -neutron_milestone = [migration.LIBERTY] - - -def upgrade(): - op.drop_table('cisco_n1kv_port_bindings') - op.drop_table('cisco_n1kv_network_bindings') - op.drop_table('cisco_n1kv_multi_segments') - op.drop_table('cisco_provider_networks') - op.drop_table('cisco_n1kv_trunk_segments') - op.drop_table('cisco_n1kv_vmnetworks') - op.drop_table('cisco_n1kv_profile_bindings') - op.drop_table('cisco_qos_policies') - op.drop_table('cisco_credentials') - op.drop_table('cisco_n1kv_vlan_allocations') - op.drop_table('cisco_n1kv_vxlan_allocations') - op.drop_table('cisco_network_profiles') - op.drop_table('cisco_policy_profiles') diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/4ffceebfada_rbac_network.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/4ffceebfada_rbac_network.py deleted file mode 100644 index aa09735deb8..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/4ffceebfada_rbac_network.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -from oslo_utils import uuidutils -import sqlalchemy as sa - -"""network_rbac - -Revision ID: 4ffceebfada -Revises: 30018084ec99 -Create Date: 2015-06-14 13:12:04.012457 - -""" - -# revision identifiers, used by Alembic. -revision = '4ffceebfada' -down_revision = '30018084ec99' -depends_on = ('8675309a5c4f',) - - -# A simple model of the networks table with only the fields needed for -# the migration. -network = sa.Table('networks', sa.MetaData(), - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('tenant_id', sa.String(length=255)), - sa.Column('shared', sa.Boolean(), nullable=False)) - -networkrbacs = sa.Table( - 'networkrbacs', sa.MetaData(), - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('object_id', sa.String(length=36), nullable=False), - sa.Column('tenant_id', sa.String(length=255), nullable=True, - index=True), - sa.Column('target_tenant', sa.String(length=255), nullable=False), - sa.Column('action', sa.String(length=255), nullable=False)) - - -def upgrade(): - op.bulk_insert(networkrbacs, get_values()) - op.drop_column('networks', 'shared') - # the shared column on subnets was just an internal representation of the - # shared status of the network it was related to. This is now handled by - # other logic so we just drop it. - op.drop_column('subnets', 'shared') - - -def get_values(): - session = sa.orm.Session(bind=op.get_bind()) - values = [] - for row in session.query(network).filter(network.c.shared).all(): - values.append({'id': uuidutils.generate_uuid(), 'object_id': row[0], - 'tenant_id': row[1], 'target_tenant': '*', - 'action': 'access_as_shared'}) - # this commit appears to be necessary to allow further operations - session.commit() - return values diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/5498d17be016_drop_legacy_ovs_and_lb.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/5498d17be016_drop_legacy_ovs_and_lb.py deleted file mode 100644 index 623bb6401d4..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/5498d17be016_drop_legacy_ovs_and_lb.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op - -"""Drop legacy OVS and LB plugin tables - -Revision ID: 5498d17be016 -Revises: 4ffceebfada -Create Date: 2015-06-25 14:08:30.984419 - -""" - -# revision identifiers, used by Alembic. -revision = '5498d17be016' -down_revision = '4ffceebfada' - - -def upgrade(): - op.drop_table('ovs_network_bindings') - op.drop_table('ovs_vlan_allocations') - op.drop_table('network_bindings') - op.drop_table('ovs_tunnel_allocations') - op.drop_table('network_states') - op.drop_table('ovs_tunnel_endpoints') diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/1b4c6e320f79_address_scope_support_in_subnetpool.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/1b4c6e320f79_address_scope_support_in_subnetpool.py deleted file mode 100644 index e3a2159fe37..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/1b4c6e320f79_address_scope_support_in_subnetpool.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2015 Huawei Technologies India Pvt. Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""address scope support in subnetpool - -Revision ID: 1b4c6e320f79 -Revises: 1c844d1677f7 -Create Date: 2015-07-03 09:48:39.491058 - -""" - -# revision identifiers, used by Alembic. -revision = '1b4c6e320f79' -down_revision = '1c844d1677f7' - - -def upgrade(): - op.add_column('subnetpools', - sa.Column('address_scope_id', - sa.String(length=36), - nullable=True)) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/1c844d1677f7_dns_nameservers_order.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/1c844d1677f7_dns_nameservers_order.py deleted file mode 100644 index e7a922c924d..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/1c844d1677f7_dns_nameservers_order.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""add order to dnsnameservers - -Revision ID: 1c844d1677f7 -Revises: 26c371498592 -Create Date: 2015-07-21 22:59:03.383850 - -""" - -# revision identifiers, used by Alembic. -revision = '1c844d1677f7' -down_revision = '26c371498592' - - -def upgrade(): - op.add_column('dnsnameservers', - sa.Column('order', sa.Integer(), - server_default='0', nullable=False)) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/26c371498592_subnetpool_hash.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/26c371498592_subnetpool_hash.py deleted file mode 100644 index 9a806eb26f7..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/26c371498592_subnetpool_hash.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2015 Thales Services SAS -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""subnetpool hash - -Revision ID: 26c371498592 -Revises: 45f955889773 -Create Date: 2015-06-02 21:18:19.942076 - -""" - -# revision identifiers, used by Alembic. -revision = '26c371498592' -down_revision = '45f955889773' - - -def upgrade(): - op.add_column( - 'subnetpools', - sa.Column('hash', sa.String(36), nullable=False, server_default='')) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/31337ec0ffee_flavors.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/31337ec0ffee_flavors.py deleted file mode 100644 index aea3ab69363..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/31337ec0ffee_flavors.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2014-2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""Flavor framework - -Revision ID: 313373c0ffee -Revises: 52c5312f6baf - -Create Date: 2014-07-17 03:00:00.00 -""" -# revision identifiers, used by Alembic. -revision = '313373c0ffee' -down_revision = '52c5312f6baf' - - -def upgrade(): - op.create_table( - 'flavors', - sa.Column('id', sa.String(36)), - sa.Column('name', sa.String(255)), - sa.Column('description', sa.String(1024)), - sa.Column('enabled', sa.Boolean, nullable=False, - server_default=sa.sql.true()), - sa.Column('service_type', sa.String(36), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - op.create_table( - 'serviceprofiles', - sa.Column('id', sa.String(36)), - sa.Column('description', sa.String(1024)), - sa.Column('driver', sa.String(1024), nullable=False), - sa.Column('enabled', sa.Boolean, nullable=False, - server_default=sa.sql.true()), - sa.Column('metainfo', sa.String(4096)), - sa.PrimaryKeyConstraint('id') - ) - - op.create_table( - 'flavorserviceprofilebindings', - sa.Column('service_profile_id', sa.String(36), nullable=False), - sa.Column('flavor_id', sa.String(36), nullable=False), - sa.ForeignKeyConstraint(['service_profile_id'], - ['serviceprofiles.id']), - sa.ForeignKeyConstraint(['flavor_id'], ['flavors.id']), - sa.PrimaryKeyConstraint('service_profile_id', 'flavor_id') - ) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/34af2b5c5a59_add_dns_name_to_port.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/34af2b5c5a59_add_dns_name_to_port.py deleted file mode 100644 index 001846827b7..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/34af2b5c5a59_add_dns_name_to_port.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2015 Rackspace -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -from neutron_lib.db import constants -import sqlalchemy as sa - -from neutron.db import migration - -"""Add dns_name to Port - -Revision ID: 34af2b5c5a59 -Revises: 9859ac9c136 -Create Date: 2015-08-23 00:22:47.618593 - -""" - -# revision identifiers, used by Alembic. -revision = '34af2b5c5a59' -down_revision = '9859ac9c136' - -# milestone identifier, used by neutron-db-manage -neutron_milestone = [migration.LIBERTY] - - -def upgrade(): - op.add_column('ports', - sa.Column('dns_name', - sa.String(length=constants.FQDN_FIELD_SIZE), - nullable=True)) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/354db87e3225_nsxv_vdr_metadata.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/354db87e3225_nsxv_vdr_metadata.py deleted file mode 100644 index 3b0361b6afe..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/354db87e3225_nsxv_vdr_metadata.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -from neutron.db.migration import cli - -"""nsxv_vdr_metadata.py - -Revision ID: 354db87e3225 -Revises: kilo -Create Date: 2015-04-19 14:59:15.102609 - -""" - -# revision identifiers, used by Alembic. -revision = '354db87e3225' -down_revision = 'kilo' -branch_labels = (cli.EXPAND_BRANCH,) - - -def upgrade(): - op.create_table( - 'nsxv_vdr_dhcp_bindings', - sa.Column('vdr_router_id', sa.String(length=36), nullable=False), - sa.Column('dhcp_router_id', sa.String(length=36), nullable=False), - sa.Column('dhcp_edge_id', sa.String(length=36), nullable=False), - sa.PrimaryKeyConstraint('vdr_router_id'), - sa.UniqueConstraint( - 'dhcp_router_id', - name='unique_nsxv_vdr_dhcp_bindings0dhcp_router_id'), - sa.UniqueConstraint( - 'dhcp_edge_id', - name='unique_nsxv_vdr_dhcp_bindings0dhcp_edge_id')) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/45f955889773_quota_usage.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/45f955889773_quota_usage.py deleted file mode 100644 index 349353bb52c..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/45f955889773_quota_usage.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa -from sqlalchemy import sql - -"""quota_usage - -Revision ID: 45f955889773 -Revises: 8675309a5c4f -Create Date: 2015-04-17 08:09:37.611546 - -""" - -# revision identifiers, used by Alembic. -revision = '45f955889773' -down_revision = '8675309a5c4f' - - -def upgrade(): - op.create_table( - 'quotausages', - sa.Column('tenant_id', sa.String(length=255), - nullable=False, primary_key=True, index=True), - sa.Column('resource', sa.String(length=255), - nullable=False, primary_key=True, index=True), - sa.Column('dirty', sa.Boolean(), nullable=False, - server_default=sql.false()), - sa.Column('in_use', sa.Integer(), nullable=False, - server_default='0'), - sa.Column('reserved', sa.Integer(), nullable=False, - server_default='0')) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/52c5312f6baf_address_scopes.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/52c5312f6baf_address_scopes.py deleted file mode 100644 index dd7b20a676c..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/52c5312f6baf_address_scopes.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2015 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""Initial operations in support of address scopes - -""" - -# revision identifiers, used by Alembic. -revision = '52c5312f6baf' -down_revision = '599c6a226151' - - -def upgrade(): - op.create_table( - 'address_scopes', - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('tenant_id', sa.String(length=255), nullable=True, - index=True), - sa.Column('shared', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id')) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/expand/9859ac9c136_quota_reservations.py b/neutron/db/migration/alembic_migrations/versions/liberty/expand/9859ac9c136_quota_reservations.py deleted file mode 100644 index b9625ad3c31..00000000000 --- a/neutron/db/migration/alembic_migrations/versions/liberty/expand/9859ac9c136_quota_reservations.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2015 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -from alembic import op -import sqlalchemy as sa - -"""quota_reservations - -Revision ID: 9859ac9c136 -Revises: 48153cb5f051 -Create Date: 2015-03-11 06:40:56.775075 - -""" - -# revision identifiers, used by Alembic. -revision = '9859ac9c136' -down_revision = '48153cb5f051' - - -def upgrade(): - op.create_table( - 'reservations', - sa.Column('id', sa.String(length=36), nullable=False), - sa.Column('tenant_id', sa.String(length=255), nullable=True), - sa.Column('expiration', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id')) - - op.create_table( - 'resourcedeltas', - sa.Column('resource', sa.String(length=255), nullable=False), - sa.Column('reservation_id', sa.String(length=36), nullable=False), - sa.Column('amount', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['reservation_id'], ['reservations.id'], - ondelete='CASCADE'), - sa.PrimaryKeyConstraint('resource', 'reservation_id')) diff --git a/neutron/db/migration/alembic_migrations/versions/kilo_initial.py b/neutron/db/migration/alembic_migrations/versions/liberty_initial.py similarity index 88% rename from neutron/db/migration/alembic_migrations/versions/kilo_initial.py rename to neutron/db/migration/alembic_migrations/versions/liberty_initial.py index f4290e3e758..bec1e007deb 100644 --- a/neutron/db/migration/alembic_migrations/versions/kilo_initial.py +++ b/neutron/db/migration/alembic_migrations/versions/liberty_initial.py @@ -20,8 +20,8 @@ from neutron.db.migration.alembic_migrations import cisco_init_ops from neutron.db.migration.alembic_migrations import core_init_ops from neutron.db.migration.alembic_migrations import dvr_init_opts from neutron.db.migration.alembic_migrations import firewall_init_ops +from neutron.db.migration.alembic_migrations import ipam_init_ops from neutron.db.migration.alembic_migrations import l3_init_ops -from neutron.db.migration.alembic_migrations import lb_init_ops from neutron.db.migration.alembic_migrations import loadbalancer_init_ops from neutron.db.migration.alembic_migrations import metering_init_ops from neutron.db.migration.alembic_migrations import ml2_init_ops @@ -30,21 +30,22 @@ from neutron.db.migration.alembic_migrations import nsxv_initial_opts from neutron.db.migration.alembic_migrations import nuage_init_opts from neutron.db.migration.alembic_migrations import other_extensions_init_ops from neutron.db.migration.alembic_migrations import other_plugins_init_ops -from neutron.db.migration.alembic_migrations import ovs_init_ops from neutron.db.migration.alembic_migrations import portsec_init_ops +from neutron.db.migration.alembic_migrations import qos_init_ops +from neutron.db.migration.alembic_migrations import rbac_init_ops from neutron.db.migration.alembic_migrations import secgroup_init_ops from neutron.db.migration.alembic_migrations import vmware_init_ops from neutron.db.migration.alembic_migrations import vpn_init_ops -"""kilo_initial +"""liberty_initial -Revision ID: kilo +Revision ID: liberty Revises: None """ # revision identifiers, used by Alembic. -revision = 'kilo' +revision = 'liberty' down_revision = None @@ -56,8 +57,6 @@ def upgrade(): secgroup_init_ops.upgrade() portsec_init_ops.upgrade() other_extensions_init_ops.upgrade() - lb_init_ops.upgrade() - ovs_init_ops.upgrade() ml2_init_ops.upgrade() dvr_init_opts.upgrade() firewall_init_ops.upgrade() @@ -71,3 +70,6 @@ def upgrade(): vmware_init_ops.upgrade() nuage_init_opts.upgrade() nsxv_initial_opts.upgrade() + ipam_init_ops.upgrade() + qos_init_ops.upgrade() + rbac_init_ops.upgrade() diff --git a/neutron/db/migration/alembic_migrations/versions/mitaka/contract/1b294093239c_remove_embrane_plugin.py b/neutron/db/migration/alembic_migrations/versions/mitaka/contract/1b294093239c_remove_embrane_plugin.py index 01c90aea0c4..15717ebaec7 100644 --- a/neutron/db/migration/alembic_migrations/versions/mitaka/contract/1b294093239c_remove_embrane_plugin.py +++ b/neutron/db/migration/alembic_migrations/versions/mitaka/contract/1b294093239c_remove_embrane_plugin.py @@ -13,17 +13,20 @@ from alembic import op +from neutron.db.migration import cli + """Drop embrane plugin table Revision ID: 1b294093239c -Revises: 4af11ca47297 +Revises: None Create Date: 2015-10-09 14:07:59.968597 """ # revision identifiers, used by Alembic. revision = '1b294093239c' -down_revision = '4af11ca47297' +down_revision = 'liberty' +branch_labels = (cli.CONTRACT_BRANCH,) def upgrade(): diff --git a/neutron/db/migration/alembic_migrations/versions/mitaka/expand/59cb5b6cf4d_availability_zone.py b/neutron/db/migration/alembic_migrations/versions/mitaka/expand/59cb5b6cf4d_availability_zone.py index faf531b0e4e..53ddc32956a 100644 --- a/neutron/db/migration/alembic_migrations/versions/mitaka/expand/59cb5b6cf4d_availability_zone.py +++ b/neutron/db/migration/alembic_migrations/versions/mitaka/expand/59cb5b6cf4d_availability_zone.py @@ -15,17 +15,20 @@ from alembic import op import sqlalchemy as sa +from neutron.db.migration import cli + """Add availability zone Revision ID: 59cb5b6cf4d -Revises: 34af2b5c5a59 +Revises: None Create Date: 2015-01-20 14:38:47.156574 """ # revision identifiers, used by Alembic. revision = '59cb5b6cf4d' -down_revision = '34af2b5c5a59' +down_revision = 'liberty' +branch_labels = (cli.EXPAND_BRANCH,) def upgrade(): diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index c1b49c7b238..d6825147f94 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -39,7 +39,6 @@ EXPAND_HEAD_FILENAME = 'EXPAND_HEAD' CURRENT_RELEASE = migration.VICTORIA RELEASES = ( - migration.LIBERTY, migration.MITAKA, migration.NEWTON, migration.OCATA, @@ -235,32 +234,10 @@ def do_revision(config, cmd): update_head_files(config) -def _get_release_labels(labels): - result = set() - for label in labels: - # release labels were introduced Liberty for a short time and dropped - # in that same release cycle - result.add('%s_%s' % (migration.LIBERTY, label)) - return result - - def _compare_labels(revision, expected_labels): # validate that the script has expected labels only bad_labels = revision.branch_labels - expected_labels if bad_labels: - # NOTE(ihrachyshka): this hack is temporary to accommodate those - # projects that already initialized their branches with liberty_* - # labels. Let's notify them about the deprecation for now and drop it - # later. - bad_labels_with_release = (revision.branch_labels - - _get_release_labels(expected_labels)) - if not bad_labels_with_release: - log_warning( - _('Release aware branch labels (%s) are deprecated. ' - 'Please switch to expand@ and contract@ ' - 'labels.') % bad_labels) - return - script_name = os.path.basename(revision.path) log_error( _('Unexpected label for script %(script_name)s: %(labels)s') % diff --git a/neutron/tests/unit/db/test_migration.py b/neutron/tests/unit/db/test_migration.py index 76ce43d0540..71f942240f0 100644 --- a/neutron/tests/unit/db/test_migration.py +++ b/neutron/tests/unit/db/test_migration.py @@ -359,12 +359,12 @@ class TestCli(base.BaseTestCase): @mock.patch('alembic.script.ScriptDirectory.walk_revisions') def test_upgrade_milestone_expand_before_contract(self, walk_mock): c_revs = [FakeRevision(labels={cli.CONTRACT_BRANCH}) for r in range(5)] - c_revs[1].module.neutron_milestone = [migration.LIBERTY] + c_revs[1].module.neutron_milestone = [migration.MITAKA] e_revs = [FakeRevision(labels={cli.EXPAND_BRANCH}) for r in range(5)] - e_revs[3].module.neutron_milestone = [migration.LIBERTY] + e_revs[3].module.neutron_milestone = [migration.MITAKA] walk_mock.return_value = c_revs + e_revs self._main_test_helper( - ['prog', '--subproject', 'neutron', 'upgrade', 'liberty'], + ['prog', '--subproject', 'neutron', 'upgrade', 'mitaka'], 'upgrade', [{'desc': cli.EXPAND_BRANCH, 'revision': e_revs[3].revision, @@ -713,40 +713,40 @@ class TestCli(base.BaseTestCase): @mock.patch('alembic.script.ScriptDirectory.walk_revisions') def test__find_milestone_revisions_one_branch(self, walk_mock): c_revs = [FakeRevision(labels={cli.CONTRACT_BRANCH}) for r in range(5)] - c_revs[1].module.neutron_milestone = [migration.LIBERTY] + c_revs[1].module.neutron_milestone = [migration.MITAKA] walk_mock.return_value = c_revs - m = cli._find_milestone_revisions(self.configs[0], 'liberty', + m = cli._find_milestone_revisions(self.configs[0], 'mitaka', cli.CONTRACT_BRANCH) self.assertEqual(1, len(m)) - m = cli._find_milestone_revisions(self.configs[0], 'liberty', + m = cli._find_milestone_revisions(self.configs[0], 'mitaka', cli.EXPAND_BRANCH) self.assertEqual(0, len(m)) @mock.patch('alembic.script.ScriptDirectory.walk_revisions') def test__find_milestone_revisions_two_branches(self, walk_mock): c_revs = [FakeRevision(labels={cli.CONTRACT_BRANCH}) for r in range(5)] - c_revs[1].module.neutron_milestone = [migration.LIBERTY] + c_revs[1].module.neutron_milestone = [migration.MITAKA] e_revs = [FakeRevision(labels={cli.EXPAND_BRANCH}) for r in range(5)] - e_revs[3].module.neutron_milestone = [migration.LIBERTY] + e_revs[3].module.neutron_milestone = [migration.MITAKA] walk_mock.return_value = c_revs + e_revs - m = cli._find_milestone_revisions(self.configs[0], 'liberty') + m = cli._find_milestone_revisions(self.configs[0], 'mitaka') self.assertEqual(2, len(m)) - m = cli._find_milestone_revisions(self.configs[0], 'mitaka') + m = cli._find_milestone_revisions(self.configs[0], 'newton') self.assertEqual(0, len(m)) @mock.patch('alembic.script.ScriptDirectory.walk_revisions') def test__find_milestone_revisions_branchless(self, walk_mock): revisions = [FakeRevision() for r in range(5)] - revisions[2].module.neutron_milestone = [migration.LIBERTY] + revisions[2].module.neutron_milestone = [migration.MITAKA] walk_mock.return_value = revisions - m = cli._find_milestone_revisions(self.configs[0], 'liberty') + m = cli._find_milestone_revisions(self.configs[0], 'mitaka') self.assertEqual(1, len(m)) - m = cli._find_milestone_revisions(self.configs[0], 'mitaka') + m = cli._find_milestone_revisions(self.configs[0], 'newton') self.assertEqual(0, len(m))