Stop ovn networking failing on mtu

The type check needed to be more specific. There are some subclasses
that don't create the devices we were trying to set the mtu on.

Change-Id: Icc628a2dbde137d320fb78ad45b2ee0f7b5775fa
Closes-Bug: #1624383
This commit is contained in:
John Garbutt 2016-09-16 14:51:10 +01:00 committed by Matt Riedemann
parent d4b35152c0
commit fc0e281743
2 changed files with 23 additions and 4 deletions

View File

@ -1626,13 +1626,32 @@ class LibvirtVifTestCase(test.NoDBTestCase):
def test_plug_ovs_vif_mtu(self, mock_plug,
mock_convert_vif, mock_convert_inst,
mock_set_mtu):
# Hack port profile to say ovs, just like ovn
os_vif_bridge = copy.deepcopy(self.os_vif_bridge)
os_vif_bridge.port_profile = self.os_vif_ovs_prof
mock_convert_vif.return_value = os_vif_bridge
mock_convert_inst.return_value = self.os_vif_inst_info
d = vif.LibvirtGenericVIFDriver()
d.plug(self.instance, self.vif_bridge)
self.assertEqual(3, mock_set_mtu.call_count)
mock_set_mtu.assert_any_call("br0", 9000)
mock_set_mtu.assert_any_call("qvbdc065497-3c", 9000)
mock_set_mtu.assert_any_call("qvodc065497-3c", 9000)
@mock.patch('nova.network.linux_net._set_device_mtu')
@mock.patch("nova.network.os_vif_util.nova_to_osvif_instance")
@mock.patch("nova.network.os_vif_util.nova_to_osvif_vif")
@mock.patch.object(os_vif, "plug")
def test_plug_ovs_vif_no_mtu_venv(self, mock_plug,
mock_convert_vif, mock_convert_inst,
mock_set_mtu):
mock_convert_vif.return_value = self.os_vif_ovs
mock_convert_inst.return_value = self.os_vif_inst_info
d = vif.LibvirtGenericVIFDriver()
d.plug(self.instance, self.vif_ovs)
self.assertEqual(1, mock_set_mtu.call_count)
mock_set_mtu.assert_any_call("br0", 1000)
mock_set_mtu.assert_any_call("qvbdc065497-3c", 1000)
mock_set_mtu.assert_any_call("qvodc065497-3c", 1000)
self.assertEqual(3, mock_set_mtu.call_count)

View File

@ -788,7 +788,7 @@ class LibvirtGenericVIFDriver(object):
if mtu is not None:
linux_net._set_device_mtu(network["bridge"], mtu)
if (isinstance(vif, os_vif.objects.vif.VIFBridge) and
if (type(vif) == os_vif.objects.vif.VIFBridge and
hasattr(vif, "port_profile") and
isinstance(vif.port_profile,
os_vif.objects.vif.VIFPortProfileOpenVSwitch)):