From: Kevin Benton Date: Tue, 21 Apr 2015 05:26:22 +0000 (-0700) Subject: Only update MTU in update code for MTU X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=cbfb3e487d97998ec49d7faa751bc26202da7d0e;p=openstack-build%2Fneutron-build.git Only update MTU in update code for MTU 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) --- diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 3f734d9e3..a1caff035 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -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 diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index e9cd74406..96817683a 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -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