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
This commit is contained in:
ronak 2015-02-25 14:55:18 -08:00
parent 56967bd950
commit 2387f23f12
3 changed files with 75 additions and 3 deletions

View File

@ -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')

View File

@ -1 +1 @@
2b801560a332
57dd745253a6

View File

@ -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())