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 f85de393c4)
This commit is contained in:
Kevin Benton 2015-04-20 22:26:22 -07:00
parent a0d8963286
commit cbfb3e487d
2 changed files with 23 additions and 1 deletions

View File

@ -598,7 +598,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if net_data.get(api.MTU, 0) > 0: if net_data.get(api.MTU, 0) > 0:
res = super(Ml2Plugin, self).update_network(context, 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) result[api.MTU] = res.get(api.MTU, 0)
return result, mech_context return result, mech_context

View File

@ -266,6 +266,28 @@ class TestMl2NetworksV2(test_plugin.TestNetworksV2,
self.assertEqual(db_api.MAX_RETRIES + 1, f.call_count) 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, class TestMl2SubnetsV2(test_plugin.TestSubnetsV2,
Ml2PluginV2TestCase): Ml2PluginV2TestCase):
pass pass