From 2387f23f12fdc546df0a160ca791d00ce492a795 Mon Sep 17 00:00:00 2001 From: ronak Date: Wed, 25 Feb 2015 14:55:18 -0800 Subject: [PATCH] Adding DB model changes for Nuage Plugin post decomposition Due to decomposition of plugin work initiated during K release, nuage plugin have gone through much changes without them being incorporated upstream. But as per the decomp spec guideline, we need to keep migration and model definition upstream. So adding new schema along with migration script into K release. Change-Id: Ia825c764917b15910bae232edc340fa315b9ffab Closes-bug: #1424113 --- .../57dd745253a6_nuage_kilo_migrate.py | 67 +++++++++++++++++++ .../alembic_migrations/versions/HEAD | 2 +- neutron/plugins/nuage/nuage_models.py | 9 ++- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 neutron/db/migration/alembic_migrations/versions/57dd745253a6_nuage_kilo_migrate.py diff --git a/neutron/db/migration/alembic_migrations/versions/57dd745253a6_nuage_kilo_migrate.py b/neutron/db/migration/alembic_migrations/versions/57dd745253a6_nuage_kilo_migrate.py new file mode 100644 index 00000000000..b6df86ca565 --- /dev/null +++ b/neutron/db/migration/alembic_migrations/versions/57dd745253a6_nuage_kilo_migrate.py @@ -0,0 +1,67 @@ +# 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. +# + +"""nuage_kilo_migrate + +Revision ID: 57dd745253a6 +Revises: 2b801560a332 +Create Date: 2015-02-12 18:32:27.343786 + +""" + +# revision identifiers, used by Alembic. +revision = '57dd745253a6' +down_revision = '2b801560a332' + +from alembic import op +import sqlalchemy as sa + +CONSTRAINT_NAME_NR = 'uniq_nuage_net_partition_router_mapping0nuage_router_id' +CONSTRAINT_NAME_NS = 'uniq_nuage_subnet_l2dom_mapping0nuage_subnet_id' + + +def upgrade(): + op.add_column('nuage_net_partition_router_mapping', + sa.Column('nuage_rtr_rd', sa.String(length=36), nullable=True)) + op.add_column('nuage_net_partition_router_mapping', + sa.Column('nuage_rtr_rt', sa.String(length=36), nullable=True)) + op.add_column('nuage_net_partitions', + sa.Column('isolated_zone', sa.String(length=64), nullable=True)) + op.add_column('nuage_net_partitions', + sa.Column('shared_zone', sa.String(length=64), nullable=True)) + op.add_column('nuage_subnet_l2dom_mapping', + sa.Column('nuage_managed_subnet', sa.Boolean(), nullable=True)) + op.create_unique_constraint( + name=CONSTRAINT_NAME_NR, + source='nuage_net_partition_router_mapping', + local_cols=['nuage_router_id']) + op.create_unique_constraint( + name=CONSTRAINT_NAME_NS, + source='nuage_subnet_l2dom_mapping', + local_cols=['nuage_subnet_id']) + + +def downgrade(): + op.drop_column('nuage_net_partition_router_mapping', 'nuage_rtr_rt') + op.drop_column('nuage_net_partition_router_mapping', 'nuage_rtr_rd') + op.drop_column('nuage_net_partitions', 'isolated_zone') + op.drop_column('nuage_net_partitions', 'shared_zone') + op.drop_column('nuage_subnet_l2dom_mapping', 'nuage_managed_subnet') + op.drop_constraint(CONSTRAINT_NAME_NS, + 'nuage_subnet_l2dom_mapping', + type_='unique') + op.drop_constraint(CONSTRAINT_NAME_NR, + 'nuage_net_partition_router_mapping', + type_='unique') diff --git a/neutron/db/migration/alembic_migrations/versions/HEAD b/neutron/db/migration/alembic_migrations/versions/HEAD index fa44d95428c..906e0b60c57 100644 --- a/neutron/db/migration/alembic_migrations/versions/HEAD +++ b/neutron/db/migration/alembic_migrations/versions/HEAD @@ -1 +1 @@ -2b801560a332 +57dd745253a6 diff --git a/neutron/plugins/nuage/nuage_models.py b/neutron/plugins/nuage/nuage_models.py index 59c773951ff..15e89e7236f 100644 --- a/neutron/plugins/nuage/nuage_models.py +++ b/neutron/plugins/nuage/nuage_models.py @@ -25,6 +25,8 @@ class NetPartition(model_base.BASEV2, models_v2.HasId): name = sa.Column(sa.String(64)) l3dom_tmplt_id = sa.Column(sa.String(36)) l2dom_tmplt_id = sa.Column(sa.String(36)) + isolated_zone = sa.Column(sa.String(64)) + shared_zone = sa.Column(sa.String(64)) class NetPartitionRouter(model_base.BASEV2): @@ -36,7 +38,9 @@ class NetPartitionRouter(model_base.BASEV2): router_id = sa.Column(sa.String(36), sa.ForeignKey('routers.id', ondelete="CASCADE"), primary_key=True) - nuage_router_id = sa.Column(sa.String(36)) + nuage_router_id = sa.Column(sa.String(36), unique=True) + nuage_rtr_rt = sa.Column(sa.String(36)) + nuage_rtr_rd = sa.Column(sa.String(36)) class ProviderNetBinding(model_base.BASEV2): @@ -64,7 +68,8 @@ class SubnetL2Domain(model_base.BASEV2): net_partition_id = sa.Column(sa.String(36), sa.ForeignKey('nuage_net_partitions.id', ondelete="CASCADE")) - nuage_subnet_id = sa.Column(sa.String(36)) + nuage_subnet_id = sa.Column(sa.String(36), unique=True) nuage_l2dom_tmplt_id = sa.Column(sa.String(36)) nuage_user_id = sa.Column(sa.String(36)) nuage_group_id = sa.Column(sa.String(36)) + nuage_managed_subnet = sa.Column(sa.Boolean())