From: Salvatore Orlando Date: Tue, 11 Mar 2014 23:16:10 +0000 (-0700) Subject: NSX: Allow multiple references to same gw device X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2014300886215452e5753529c68712d075cba57d;p=openstack-build%2Fneutron-build.git NSX: Allow multiple references to same gw device This patch amends a data model in order to allow user to specify the same gateway device multiple times in a network gateway specification. The corresponding migration is also being amended with this patch. This approach has been preferred to developing another migration since the migration being amended is still the most recent one for the NSX plugin. Change-Id: I4d24837d8d65fc45b838f3b616c9ec8a73a50d9c Closes-Bug: 1262790 --- diff --git a/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py b/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py index 1e5ecc5ba..2eabc150a 100644 --- a/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py +++ b/neutron/db/migration/alembic_migrations/versions/19180cf98af6_nsx_gw_devices.py @@ -51,7 +51,7 @@ def upgrade(active_plugins=None, options=None): sa.Column('interface_name', sa.String(length=64), nullable=True), sa.ForeignKeyConstraint(['network_gateway_id'], ['networkgateways.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), + sa.PrimaryKeyConstraint('id', 'network_gateway_id', 'interface_name'), mysql_engine='InnoDB') # Copy data from networkgatewaydevices into networkgatewaydevicereference op.execute("INSERT INTO networkgatewaydevicereferences SELECT " diff --git a/neutron/plugins/vmware/dbexts/networkgw_db.py b/neutron/plugins/vmware/dbexts/networkgw_db.py index 5609a0867..6a1c3c21b 100644 --- a/neutron/plugins/vmware/dbexts/networkgw_db.py +++ b/neutron/plugins/vmware/dbexts/networkgw_db.py @@ -121,8 +121,9 @@ class NetworkGatewayDeviceReference(model_base.BASEV2): id = sa.Column(sa.String(36), primary_key=True) network_gateway_id = sa.Column(sa.String(36), sa.ForeignKey('networkgateways.id', - ondelete='CASCADE')) - interface_name = sa.Column(sa.String(64)) + ondelete='CASCADE'), + primary_key=True) + interface_name = sa.Column(sa.String(64), primary_key=True) class NetworkGatewayDevice(model_base.BASEV2, models_v2.HasId,