]> 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>
Tue, 21 Apr 2015 05:35:23 +0000 (22:35 -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

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

index c57bfe71d62de5cd0109e70f59f08a6df92b9ac6..e5a4d3728651327dce77ff6805b90dbd92950fec 100644 (file)
@@ -602,7 +602,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 82f04ae6cbacdc7f092c1aa4e93cb14f431c7eab..cc51029fdfa2ab558094e60f9d4f6797870515c8 100644 (file)
@@ -312,6 +312,28 @@ class TestExternalNetwork(Ml2PluginV2TestCase):
         self.assertNotIn(mpnet.SEGMENTS, network['network'])
 
 
+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):
     def test_delete_subnet_race_with_dhcp_port_creation(self):