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=f85de393c469d1e649a1c1e5ee1b683246442351;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 --- diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index c57bfe71d..e5a4d3728 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -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 diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index 82f04ae6c..cc51029fd 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -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):