From 6bfb1959184d6e262e63c25e9b1ef7d1fdf63a8e Mon Sep 17 00:00:00 2001 From: Jan Gutter Date: Thu, 31 May 2018 13:10:50 +0200 Subject: [PATCH] Use vif.vif_name in _set_config_VIFGeneric During IVS os-vif migration, _set_config_VIFGeneric was added: https://review.openstack.org/#/c/534371/ It appears that some legacy plugging code still slipped through, since the preferred method to pass the VIF name (i.e. device name) is via the os-vif object. Crucially, this is not a Nova VIF object, so it has different fields. * This change makes _set_config_VIFGeneric behave the way other os-vif methods do, by taking the name from the os-vif object. * This change adds back some VIF unit tests that would have caught this. Closes-Bug: #1783551 Change-Id: I468a9e78c948209cc2fde795ffffa0e99906fbef Signed-off-by: Jan Gutter --- nova/tests/unit/virt/libvirt/test_vif.py | 33 ++++++++++++++++++++++++ nova/virt/libvirt/vif.py | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py index 6469809957..444058df9d 100644 --- a/nova/tests/unit/virt/libvirt/test_vif.py +++ b/nova/tests/unit/virt/libvirt/test_vif.py @@ -97,6 +97,13 @@ class LibvirtVifTestCase(test.NoDBTestCase): bridge_interface=None, vlan=99, mtu=1000) + network_ivs = network_model.Network(id=uuids.network, + bridge='br0', + label=None, + subnets=[subnet_bridge_4, subnet_bridge_6], + bridge_interface=None, + vlan=99) + vif_agilio_ovs = network_model.VIF(id=uuids.vif, address='ca:fe:de:ad:be:ef', network=network_ovs, @@ -158,6 +165,13 @@ class LibvirtVifTestCase(test.NoDBTestCase): devname=None, ovs_interfaceid=None) + vif_ivs = network_model.VIF(id=uuids.vif, + address='ca:fe:de:ad:be:ef', + network=network_ivs, + type=network_model.VIF_TYPE_IVS, + devname='tap-xxx-yyy-zzz', + ovs_interfaceid=uuids.ovs) + vif_none = network_model.VIF(id=uuids.vif, address='ca:fe:de:ad:be:ef', network=network_bridge, @@ -1041,6 +1055,14 @@ class LibvirtVifTestCase(test.NoDBTestCase): self._assertTypeAndMacEquals(node, "bridge", "source", "bridge", vif, br_want, 1) + def test_ivs_hybrid_driver(self): + d = vif.LibvirtGenericVIFDriver() + br_want = "qbr" + self.vif_ivs['id'] + br_want = br_want[:network_model.NIC_NAME_LEN] + self._check_neutron_hybrid_driver(d, + self.vif_ivs, + br_want) + def test_generic_hybrid_driver(self): d = vif.LibvirtGenericVIFDriver() br_want = "qbr" + self.vif_ovs['id'] @@ -1367,6 +1389,17 @@ class LibvirtVifTestCase(test.NoDBTestCase): self._assertMacEquals(node, self.vif_agilio_ovs_forwarder) self._assertModel(xml, network_model.VIF_MODEL_VIRTIO) + def test_ivs_ethernet_driver(self): + self.flags(firewall_driver="nova.virt.firewall.NoopFirewallDriver") + d = vif.LibvirtGenericVIFDriver() + xml = self._get_instance_xml(d, self.vif_ivs) + node = self._get_node(xml) + dev_want = self.vif_ivs['devname'] + self._assertTypeAndMacEquals(node, "ethernet", "target", "dev", + self.vif_ivs, dev_want) + script = node.find("script") + self.assertIsNone(script) + @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") diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index efd9309426..7ad35d05c2 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -460,7 +460,7 @@ class LibvirtGenericVIFDriver(object): return conf def _set_config_VIFGeneric(self, instance, vif, conf, host): - dev = self.get_vif_devname(vif) + dev = vif.vif_name designer.set_vif_host_backend_ethernet_config(conf, dev, host) def _set_config_VIFBridge(self, instance, vif, conf, host=None):