Override MTU for os_vif attachments
os-vif does not current respect the neutron provided mtu, it just uses the configuration inside os-vif. This is a big regression from mitaka and liberty. Long term, this is something os-vif will be able to do by correctly parsing and acting on the network info. For now we just set the mtu for a second time once os-vif has done what it wants to do. Closes-Bug: #1623876 Change-Id: Id4ca38fa1bb84f8cdb5edcd9ccb7acd8c8e9b60c
This commit is contained in:
parent
6228068b1b
commit
77f546623b
|
@ -12,6 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import os
|
||||
|
||||
import fixtures
|
||||
|
@ -1598,3 +1599,40 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
|||
<filterref
|
||||
filter="nova-instance-instance-00000001-22522562e2aa"/>
|
||||
</interface>""", cfg.to_xml())
|
||||
|
||||
@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(self, mock_plug,
|
||||
mock_convert_vif, mock_convert_inst,
|
||||
mock_set_mtu):
|
||||
mock_convert_vif.return_value = self.os_vif_bridge
|
||||
mock_convert_inst.return_value = self.os_vif_inst_info
|
||||
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
# Hack the network mtu in the vif_bridge object - make sure to copy it
|
||||
# so we don't change state on a global object during a test run.
|
||||
vif_bridge = copy.deepcopy(self.vif_bridge)
|
||||
vif_bridge['network']._set_meta({'mtu': None})
|
||||
d.plug(self.instance, vif_bridge)
|
||||
|
||||
self.assertFalse(mock_set_mtu.called)
|
||||
|
||||
@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_mtu(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)
|
||||
|
||||
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)
|
||||
|
|
|
@ -772,7 +772,7 @@ class LibvirtGenericVIFDriver(object):
|
|||
except processutils.ProcessExecutionError:
|
||||
LOG.exception(_LE("Failed while plugging vif"), instance=instance)
|
||||
|
||||
def _plug_os_vif(self, instance, vif):
|
||||
def _plug_os_vif(self, instance, vif, raw_vif):
|
||||
instance_info = os_vif_util.nova_to_osvif_instance(instance)
|
||||
|
||||
try:
|
||||
|
@ -782,6 +782,22 @@ class LibvirtGenericVIFDriver(object):
|
|||
% {'ex': ex})
|
||||
raise exception.NovaException(msg)
|
||||
|
||||
# TODO(johngarbutt) remove this hack once 1623876 is fixed in os-vif
|
||||
network = raw_vif.get('network')
|
||||
mtu = network.get_meta('mtu') if network else None
|
||||
if mtu is not None:
|
||||
linux_net._set_device_mtu(network["bridge"], mtu)
|
||||
|
||||
if (isinstance(vif, os_vif.objects.vif.VIFBridge) and
|
||||
hasattr(vif, "port_profile") and
|
||||
isinstance(vif.port_profile,
|
||||
os_vif.objects.vif.VIFPortProfileOpenVSwitch)):
|
||||
veths = [
|
||||
("qvb%s" % vif.id)[:network_model.NIC_NAME_LEN],
|
||||
("qvo%s" % vif.id)[:network_model.NIC_NAME_LEN]]
|
||||
for veth in veths:
|
||||
linux_net._set_device_mtu(veth, mtu)
|
||||
|
||||
def plug(self, instance, vif):
|
||||
vif_type = vif['type']
|
||||
|
||||
|
@ -798,7 +814,7 @@ class LibvirtGenericVIFDriver(object):
|
|||
# Try os-vif codepath first
|
||||
vif_obj = os_vif_util.nova_to_osvif_vif(vif)
|
||||
if vif_obj is not None:
|
||||
self._plug_os_vif(instance, vif_obj)
|
||||
self._plug_os_vif(instance, vif_obj, vif)
|
||||
return
|
||||
|
||||
# Legacy non-os-vif codepath
|
||||
|
|
Loading…
Reference in New Issue