Merge "NSX: Fix foreign key constraint delete provider network"

This commit is contained in:
Jenkins 2014-12-01 19:20:51 +00:00 committed by Gerrit Code Review
commit 529cca4548
3 changed files with 11 additions and 1 deletions

View File

@ -41,6 +41,11 @@ def get_network_bindings_by_vlanid_and_physical_net(session, vlan_id,
all()) all())
def delete_network_bindings(session, network_id):
return (session.query(models.TzNetworkBinding).
filter_by(network_id=network_id).delete())
def add_network_binding(session, network_id, binding_type, phy_uuid, vlan_id): def add_network_binding(session, network_id, binding_type, phy_uuid, vlan_id):
with session.begin(subtransactions=True): with session.begin(subtransactions=True):
binding = models.TzNetworkBinding(network_id, binding_type, binding = models.TzNetworkBinding(network_id, binding_type,

View File

@ -1006,6 +1006,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.session, self.cluster, id) context.session, self.cluster, id)
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
self._process_l3_delete(context, id) self._process_l3_delete(context, id)
nsx_db.delete_network_bindings(context.session, id)
super(NsxPluginV2, self).delete_network(context, id) super(NsxPluginV2, self).delete_network(context, id)
# Do not go to NSX for external networks # Do not go to NSX for external networks

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
import webob.exc
from neutron.extensions import multiprovidernet as mpnet from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import providernet as pnet from neutron.extensions import providernet as pnet
@ -23,7 +24,7 @@ from neutron.tests.unit.vmware import test_nsx_plugin
class TestProvidernet(test_nsx_plugin.NsxPluginV2TestCase): class TestProvidernet(test_nsx_plugin.NsxPluginV2TestCase):
def test_create_provider_network_default_physical_net(self): def test_create_delete_provider_network_default_physical_net(self):
data = {'network': {'name': 'net1', data = {'network': {'name': 'net1',
'admin_state_up': True, 'admin_state_up': True,
'tenant_id': 'admin', 'tenant_id': 'admin',
@ -33,6 +34,9 @@ class TestProvidernet(test_nsx_plugin.NsxPluginV2TestCase):
net = self.deserialize(self.fmt, network_req.get_response(self.api)) net = self.deserialize(self.fmt, network_req.get_response(self.api))
self.assertEqual(net['network'][pnet.NETWORK_TYPE], 'vlan') self.assertEqual(net['network'][pnet.NETWORK_TYPE], 'vlan')
self.assertEqual(net['network'][pnet.SEGMENTATION_ID], 411) self.assertEqual(net['network'][pnet.SEGMENTATION_ID], 411)
req = self.new_delete_request('networks', net['network']['id'])
res = req.get_response(self.api)
self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code)
def test_create_provider_network(self): def test_create_provider_network(self):
data = {'network': {'name': 'net1', data = {'network': {'name': 'net1',