From 886ba0856b1dc2baede5e1ee65cf7488320bfe71 Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Fri, 4 Oct 2013 09:13:44 +0800 Subject: [PATCH] Remove deprecated libvirt VIF driver code Libvirt vif specific driver classes have been replaced by a generic driver LibvirtGenericVIFDriver and are deprecated in Havana, so we can remove them safely. DocImpact Change-Id: Icecb3c9aa4282c511364107d87f8aba517a5ae14 Closes-Bug: 1235036 --- nova/tests/virt/libvirt/test_libvirt_vif.py | 29 ---- nova/virt/libvirt/vif.py | 146 -------------------- 2 files changed, 175 deletions(-) diff --git a/nova/tests/virt/libvirt/test_libvirt_vif.py b/nova/tests/virt/libvirt/test_libvirt_vif.py index a43e4a89ec..f277705196 100644 --- a/nova/tests/virt/libvirt/test_libvirt_vif.py +++ b/nova/tests/virt/libvirt/test_libvirt_vif.py @@ -375,26 +375,12 @@ class LibvirtVifTestCase(test.TestCase): self._assertTypeAndMacEquals(node, "bridge", "source", "bridge", self.vif_bridge, br_want, 1) - def test_bridge_driver(self): - d = vif.LibvirtBridgeDriver(self._get_conn()) - self._check_bridge_driver(d, - self.vif_bridge, - self.vif_bridge['network']['bridge']) - def test_generic_driver_bridge(self): d = vif.LibvirtGenericVIFDriver(self._get_conn()) self._check_bridge_driver(d, self.vif_bridge, self.vif_bridge['network']['bridge']) - def test_neutron_bridge_driver(self): - d = vif.NeutronLinuxBridgeVIFDriver(self._get_conn()) - br_want = 'brq' + self.vif_bridge_neutron['network']['id'] - br_want = br_want[:network_model.NIC_NAME_LEN] - self._check_bridge_driver(d, - self.vif_bridge_neutron, - br_want) - def _check_ivs_ethernet_driver(self, d, vif, dev_prefix): self.flags(firewall_driver="nova.virt.firewall.NoopFirewallDriver") xml = self._get_instance_xml(d, vif) @@ -449,13 +435,6 @@ class LibvirtVifTestCase(test.TestCase): self.assertTrue(iface_id_found) - def test_ovs_virtualport_driver(self): - d = vif.LibvirtOpenVswitchVirtualPortDriver(self._get_conn(ver=9011)) - want_iface_id = 'vif-xxx-yyy-zzz' - self._check_ovs_virtualport_driver(d, - self.vif_ovs_legacy, - want_iface_id) - def test_generic_ovs_virtualport_driver(self): d = vif.LibvirtGenericVIFDriver(self._get_conn(ver=9011)) want_iface_id = self.vif_ovs['ovs_interfaceid'] @@ -477,14 +456,6 @@ class LibvirtVifTestCase(test.TestCase): self._assertTypeAndMacEquals(node, "bridge", "source", "bridge", vif, br_want, 1) - def test_quantum_hybrid_driver(self): - br_want = "qbr" + self.vif_ovs['id'] - br_want = br_want[:network_model.NIC_NAME_LEN] - d = vif.LibvirtHybridOVSBridgeDriver(self._get_conn()) - self._check_neutron_hybrid_driver(d, - self.vif_ovs_legacy, - br_want) - def test_generic_hybrid_driver(self): d = vif.LibvirtGenericVIFDriver(self._get_conn()) br_want = "qbr" + self.vif_ovs['id'] diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index 1bb8f62ce9..70e72543ac 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -725,149 +725,3 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): else: raise exception.NovaException( _("Unexpected vif_type=%s") % vif_type) - - -class LibvirtBridgeDriver(LibvirtGenericVIFDriver): - """Retained in Grizzly for compatibility with Neutron - drivers which do not yet report 'vif_type' port binding. - Will be deprecated in Havana, and removed in Ixxxx. - """ - - def get_config(self, instance, vif, image_meta, inst_type): - LOG.deprecated(_("The LibvirtBridgeDriver VIF driver is now " - "deprecated and will be removed in the next release. " - "Please use the LibvirtGenericVIFDriver VIF driver, " - "together with a network plugin that reports the " - "'vif_type' attribute")) - return self.get_config_bridge(instance, vif, image_meta, - inst_type) - - def plug(self, instance, vif): - self.plug_bridge(instance, vif) - - def unplug(self, instance, vif): - self.unplug_bridge(instance, vif) - - -class LibvirtOpenVswitchDriver(LibvirtGenericVIFDriver): - """Retained in Grizzly for compatibility with Neutron - drivers which do not yet report 'vif_type' port binding. - Will be deprecated in Havana, and removed in Ixxxx. - """ - - def get_bridge_name(self, vif): - return vif['network']['bridge'] or CONF.libvirt_ovs_bridge - - def get_ovs_interfaceid(self, vif): - return vif.get('ovs_interfaceid') or vif['id'] - - def get_config(self, instance, vif, image_meta, inst_type): - LOG.deprecated(_("The LibvirtOpenVswitchDriver VIF driver is now " - "deprecated and will be removed in the next release. " - "Please use the LibvirtGenericVIFDriver VIF driver, " - "together with a network plugin that reports the " - "'vif_type' attribute")) - return self.get_config_ovs_ethernet(instance, - vif, - image_meta, inst_type) - - def plug(self, instance, vif): - self.plug_ovs_ethernet(instance, vif) - - def unplug(self, instance, vif): - self.unplug_ovs_ethernet(instance, vif) - - -class LibvirtHybridOVSBridgeDriver(LibvirtGenericVIFDriver): - """Retained in Grizzly for compatibility with Neutron - drivers which do not yet report 'vif_type' port binding. - Will be deprecated in Havana, and removed in Ixxxx. - """ - - def get_bridge_name(self, vif): - return vif['network']['bridge'] or CONF.libvirt_ovs_bridge - - def get_ovs_interfaceid(self, vif): - return vif.get('ovs_interfaceid') or vif['id'] - - def get_config(self, instance, vif, image_meta, inst_type): - LOG.deprecated(_("The LibvirtHybridOVSBridgeDriver VIF driver is now " - "deprecated and will be removed in the next release. " - "Please use the LibvirtGenericVIFDriver VIF driver, " - "together with a network plugin that reports the " - "'vif_type' attribute")) - return self.get_config_ovs_hybrid(instance, - vif, - image_meta, - inst_type) - - def plug(self, instance, vif): - return self.plug_ovs_hybrid(instance, vif) - - def unplug(self, instance, vif): - return self.unplug_ovs_hybrid(instance, vif) - - -class LibvirtOpenVswitchVirtualPortDriver(LibvirtGenericVIFDriver): - """Retained in Grizzly for compatibility with Neutron - drivers which do not yet report 'vif_type' port binding. - Will be deprecated in Havana, and removed in Ixxxx. - """ - - def get_bridge_name(self, vif): - return vif['network']['bridge'] or CONF.libvirt_ovs_bridge - - def get_ovs_interfaceid(self, vif): - return vif.get('ovs_interfaceid') or vif['id'] - - def get_config(self, instance, vif, image_meta, inst_type): - LOG.deprecated(_("The LibvirtOpenVswitchVirtualPortDriver VIF driver " - "is now deprecated and will be removed in the next " - "release. Please use the LibvirtGenericVIFDriver VIF " - "driver, together with a network plugin that reports " - "the 'vif_type' attribute")) - return self.get_config_ovs_bridge(instance, - vif, - image_meta, - inst_type) - - def plug(self, instance, vif): - return self.plug_ovs_bridge(instance, vif) - - def unplug(self, instance, vif): - return self.unplug_ovs_bridge(instance, vif) - - -class NeutronLinuxBridgeVIFDriver(LibvirtGenericVIFDriver): - """Retained in Grizzly for compatibility with Neutron - drivers which do not yet report 'vif_type' port binding. - Will be deprecated in Havana, and removed in Ixxxx. - """ - - def get_bridge_name(self, vif): - network = vif['network'] - def_bridge = ("brq" + network['id'])[:network_model.NIC_NAME_LEN] - return vif['network'].get('bridge') or def_bridge - - def get_config(self, instance, vif, image_meta, inst_type): - LOG.deprecated(_("The NeutronLinuxBridgeVIFDriver VIF driver is now " - "deprecated and will be removed in the next release. " - "Please use the LibvirtGenericVIFDriver VIF driver, " - "together with a network plugin that reports the " - "'vif_type' attribute")) - # In order for libvirt to make use of the bridge name then it has - # to ensure that the bridge exists - network = vif['network'] - if network and not network.get_meta('should_create_bridge', False): - vif['network']['meta']['should_create_bridge'] = True - return self.get_config_bridge(instance, vif, image_meta, - inst_type) - - def plug(self, instance, vif): - self.plug_bridge(instance, vif) - - def unplug(self, instance, vif): - self.unplug_bridge(instance, vif) - -# For compatibility with existing Nova deployments -QuantumLinuxBridgeVIFDriver = NeutronLinuxBridgeVIFDriver