Fix dhcp_router_id DB integration error

dhcp_router_id column is useless in nsxv_vdr_dhcp_bindings and would
lead to DB integration error. So the patch removes this column.

Change-Id: I882c46e07f588d0106503075bc2de3116256cd73
This commit is contained in:
linb 2015-09-25 14:45:19 +08:00 committed by Abhishek Raut
parent 0ca3017c80
commit b189f2719c
5 changed files with 39 additions and 9 deletions

View File

@ -1,2 +1,2 @@
279b70ac3ae8
393bf843b96
3c88bdea3054

View File

@ -0,0 +1,34 @@
# Copyright 2015 VMware, 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
# 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.
"""nsxv_vdr_dhcp_binding.py
Revision ID: 3c88bdea3054
Revises: 393bf843b96
Create Date: 2015-09-23 14:59:15.102609
"""
# revision identifiers, used by Alembic.
revision = '3c88bdea3054'
down_revision = '393bf843b96'
from alembic import op
def upgrade():
op.drop_constraint('unique_nsxv_vdr_dhcp_bindings0dhcp_router_id',
'nsxv_vdr_dhcp_bindings', 'unique')
op.drop_column('nsxv_vdr_dhcp_bindings', 'dhcp_router_id')

View File

@ -507,10 +507,9 @@ def get_spoofguard_policy_id(session, network_id):
network_id)
def add_vdr_dhcp_binding(session, vdr_router_id, dhcp_router_id, dhcp_edge_id):
def add_vdr_dhcp_binding(session, vdr_router_id, dhcp_edge_id):
with session.begin(subtransactions=True):
binding = nsxv_models.NsxvVdrDhcpBinding(vdr_router_id=vdr_router_id,
dhcp_router_id=dhcp_router_id,
dhcp_edge_id=dhcp_edge_id)
session.add(binding)
return binding

View File

@ -247,13 +247,10 @@ class NsxvVdrDhcpBinding(model_base.BASEV2):
__tablename__ = 'nsxv_vdr_dhcp_bindings'
vdr_router_id = sa.Column(sa.String(36), primary_key=True)
dhcp_router_id = sa.Column(sa.String(36), nullable=False)
dhcp_edge_id = sa.Column(sa.String(36), nullable=False)
__table_args__ = (
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'))
name='unique_nsxv_vdr_dhcp_bindings0dhcp_edge_id'),
model_base.BASEV2.__table_args__)

View File

@ -987,7 +987,7 @@ class EdgeManager(object):
[RP_FILTER_PROPERTY_OFF_TEMPLATE % ('all', '0')])
nsxv_db.add_vdr_dhcp_binding(context.session, vdr_router_id,
str(resource_id), dhcp_edge_id)
dhcp_edge_id)
address_groups = self.plugin._create_network_dhcp_address_group(
context, network_id)