]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix ml2 & nec plugins for allowedaddresspairs tests
authorJon Grimm <jgrimm@linux.vnet.ibm.com>
Thu, 28 Nov 2013 00:34:45 +0000 (18:34 -0600)
committerJon Grimm <jgrimm@linux.vnet.ibm.com>
Wed, 12 Mar 2014 15:41:43 +0000 (10:41 -0500)
Enabling the allowedaddresspairs tests uncovered that update_port()
was not returning the expected updated port info (still contained
original info).

Change-Id: I88f252e1348d272edd114fbee69e2309d3740213
Closes-bug: #1255150

neutron/plugins/ml2/plugin.py
neutron/plugins/nec/nec_plugin.py
neutron/tests/unit/ml2/test_ml2_plugin.py
neutron/tests/unit/nec/test_nec_plugin.py

index c7bca04e2a463c565f43884e1c079277412a9b2b..8240e09f6db4b22c8e9d78758e77ff09016ef10c 100644 (file)
@@ -654,12 +654,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
             original_port = self._make_port_dict(port_db)
             updated_port = super(Ml2Plugin, self).update_port(context, id,
                                                               port)
-            if self.is_address_pairs_attribute_updated(original_port, port):
-                self._delete_allowed_address_pairs(context, id)
-                self._process_create_allowed_address_pairs(
-                    context, updated_port,
-                    port['port'][addr_pair.ADDRESS_PAIRS])
-                need_port_update_notify = True
+            if addr_pair.ADDRESS_PAIRS in port['port']:
+                need_port_update_notify |= (
+                    self.update_address_pairs_on_port(context, id, port,
+                                                      original_port,
+                                                      updated_port))
             elif changed_fixed_ips:
                 self._check_fixed_ips_and_address_pairs_no_overlap(
                     context, updated_port)
index 1311a5a32f3b0e46579a3fb86de1a2c5c1bfdf0b..917f1e106daeaeaa55fe1bf761f0d3fe0cd90cb3 100644 (file)
@@ -597,12 +597,11 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             new_port = super(NECPluginV2, self).update_port(context, id, port)
             portinfo_changed = self._process_portbindings_update(
                 context, port['port'], new_port)
-            if self.is_address_pairs_attribute_updated(old_port, port):
-                self._delete_allowed_address_pairs(context, id)
-                self._process_create_allowed_address_pairs(
-                    context, new_port,
-                    port['port'][addr_pair.ADDRESS_PAIRS])
-                need_port_update_notify = True
+            if addr_pair.ADDRESS_PAIRS in port['port']:
+                need_port_update_notify |= (
+                    self.update_address_pairs_on_port(context, id, port,
+                                                      old_port,
+                                                      new_port))
             elif changed_fixed_ips:
                 self._check_fixed_ips_and_address_pairs_no_overlap(
                     context, new_port)
index caeeb7a93bee04b867aa8e5ca2f13843d474693c..f014d1688c98d073baa3cf77a77d67d7c843911d 100644 (file)
@@ -28,6 +28,7 @@ from neutron.plugins.ml2 import config
 from neutron.plugins.ml2 import plugin as ml2_plugin
 from neutron.tests.unit import _test_extension_portbindings as test_bindings
 from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit import test_extension_allowedaddresspairs as test_pair
 from neutron.tests.unit import test_extension_extradhcpopts as test_dhcpopts
 from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
 
@@ -315,6 +316,13 @@ class TestMultiSegmentNetworks(Ml2PluginV2TestCase):
         self.assertIsNone(network[pnet.SEGMENTATION_ID])
 
 
+class TestMl2AllowedAddressPairs(Ml2PluginV2TestCase,
+                                 test_pair.TestAllowedAddressPairs):
+    def setUp(self, plugin=None):
+        super(test_pair.TestAllowedAddressPairs, self).setUp(
+            plugin=PLUGIN_NAME)
+
+
 class DHCPOptsTestCase(test_dhcpopts.TestExtraDhcpOpt):
 
     def setUp(self, plugin=None):
index 78a0a7911ce3546662aefa58f6a4184e8084a200..5dad2a44e8057c618b3f5a1223d537301b62312f 100644 (file)
@@ -31,6 +31,7 @@ from neutron.plugins.nec.db import api as ndb
 from neutron.plugins.nec import nec_plugin
 from neutron.tests.unit.nec import fake_ofc_manager
 from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit import test_extension_allowedaddresspairs as test_pair
 
 
 PLUGIN_NAME = 'neutron.plugins.nec.nec_plugin.NECPluginV2'
@@ -903,3 +904,8 @@ class TestNecPluginOfcManager(NecPluginV2TestCase):
     def test_delete_port_for_noofcmap_ofc_port(self):
         self._test_delete_port_for_disappeared_ofc_port(
             nexc.OFCMappingNotFound(resource='port', neutron_id='port1'))
+
+
+class TestNecAllowedAddressPairs(NecPluginV2TestCase,
+                                 test_pair.TestAllowedAddressPairs):
+    pass