]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Only update MTU in update code for MTU
authorKevin Benton <blak111@gmail.com>
Tue, 21 Apr 2015 05:26:22 +0000 (22:26 -0700)
committerKevin Benton <blak111@gmail.com>
Thu, 23 Apr 2015 04:53:39 +0000 (21:53 -0700)
The ML2 create_network_db was re-passing in the entire network
with extensions like vlan_transparency present that was causing
issues in the base update function it was calling.

This corrects the behavior by having it only update the MTU, which
is the only thing it was intending to update in the first place.

Change-Id: I723c5c138e0830de98f6024c7635ec65065e9346
Closes-Bug: #1446784
(cherry picked from commit f85de393c469d1e649a1c1e5ee1b683246442351)

neutron/plugins/ml2/plugin.py
neutron/tests/unit/plugins/ml2/test_plugin.py

index 3f734d9e315cef368c65ef20378cfd1ae17b80d2..a1caff03576ce49b95f30be48745c08860cd91a6 100644 (file)
@@ -598,7 +598,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
 
             if net_data.get(api.MTU, 0) > 0:
                 res = super(Ml2Plugin, self).update_network(context,
-                    result['id'], network)
+                    result['id'], {'network': {api.MTU: net_data[api.MTU]}})
                 result[api.MTU] = res.get(api.MTU, 0)
 
         return result, mech_context
index e9cd744064de93451143493120e153a45db200aa..96817683af64b2556313ab9f48397176aa7891be 100644 (file)
@@ -266,6 +266,28 @@ class TestMl2NetworksV2(test_plugin.TestNetworksV2,
             self.assertEqual(db_api.MAX_RETRIES + 1, f.call_count)
 
 
+class TestMl2NetworksWithVlanTransparencyAndMTU(TestMl2NetworksV2):
+    def setUp(self, plugin=None):
+        config.cfg.CONF.set_override('path_mtu', 1000, group='ml2')
+        config.cfg.CONF.set_override('segment_mtu', 1000, group='ml2')
+        config.cfg.CONF.set_override('advertise_mtu', True)
+        config.cfg.CONF.set_override('vlan_transparent', True)
+        super(TestMl2NetworksWithVlanTransparencyAndMTU, self).setUp(plugin)
+
+    def test_create_network_vlan_transparent_and_mtu(self):
+        data = {'network': {'name': 'net1',
+                            mpnet.SEGMENTS:
+                            [{pnet.NETWORK_TYPE: 'vlan',
+                              pnet.PHYSICAL_NETWORK: 'physnet1'}],
+                            'tenant_id': 'tenant_one'}}
+        network_req = self.new_create_request('networks', data)
+        res = network_req.get_response(self.api)
+        self.assertEqual(201, res.status_int)
+        network = self.deserialize(self.fmt, res)['network']
+        self.assertEqual(network['mtu'], 1000)
+        self.assertIn('vlan_transparent', network)
+
+
 class TestMl2SubnetsV2(test_plugin.TestSubnetsV2,
                        Ml2PluginV2TestCase):
     pass