From bdb43a1ad227246d1ccdd032ae481aaa3c3d3864 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 22 Jan 2013 11:32:28 +0000 Subject: [PATCH] Merge LibvirtBridgeDriver class into LibvirtGenericVIFDriver This introduces the LibvirtGenericVIFDriver class which uses the 'vif_type' mapping field to determine what type of host network configuration is required. The LibvirtBridgeDriver class functionality is merged into LibvirtGenericVIFDriver. For backwards compatibility with the Folsom release, the existing LibvirtBridgeDriver class is made to inherit from LibvirtGenericVIFDriver and directly call the bridge specific setup APIs. This eases migration to the new VIF impl during the Grizzly deployment lifecycle, with an expectation that the LibvirtBridgeDriver stub will be deleted in the Hxxxxx release. DocImpact Blueprint: libvirt-vif-driver Change-Id: I948158b5ee0a97f666bb4d21020b552d3475b6d3 Signed-off-by: Daniel P. Berrange --- nova/tests/test_libvirt_vif.py | 41 ++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/nova/tests/test_libvirt_vif.py b/nova/tests/test_libvirt_vif.py index 3861d7df..7ce81cc0 100644 --- a/nova/tests/test_libvirt_vif.py +++ b/nova/tests/test_libvirt_vif.py @@ -16,6 +16,8 @@ from lxml import etree +from nova import exception +from nova.network import model as network_model from nova.openstack.common import cfg from nova import test from nova import utils @@ -48,7 +50,8 @@ class LibvirtVifTestCase(test.TestCase): 'ips': [{'ip': '101.168.1.9'}], 'dhcp_server': '191.168.1.1', 'vif_uuid': 'vif-xxx-yyy-zzz', - 'vif_devname': 'tap-xxx-yyy-zzz' + 'vif_devname': 'tap-xxx-yyy-zzz', + 'vif_type': network_model.VIF_TYPE_BRIDGE, } net_ovs = { @@ -75,6 +78,15 @@ class LibvirtVifTestCase(test.TestCase): 'ovs_interfaceid': 'aaa-bbb-ccc', } + mapping_none = { + 'mac': 'ca:fe:de:ad:be:ef', + 'gateway_v6': net_bridge['gateway_v6'], + 'ips': [{'ip': '101.168.1.9'}], + 'dhcp_server': '191.168.1.1', + 'vif_uuid': 'vif-xxx-yyy-zzz', + 'vif_devname': 'tap-xxx-yyy-zzz', + } + instance = { 'name': 'instance-name', 'uuid': 'instance-uuid' @@ -149,7 +161,7 @@ class LibvirtVifTestCase(test.TestCase): self.flags(libvirt_use_virtio_for_bridges=False, libvirt_type='kvm') - d = vif.LibvirtBridgeDriver() + d = vif.LibvirtGenericVIFDriver() xml = self._get_instance_xml(d, self.net_bridge, self.mapping_bridge) @@ -168,7 +180,7 @@ class LibvirtVifTestCase(test.TestCase): self.flags(libvirt_use_virtio_for_bridges=True, libvirt_type='kvm') - d = vif.LibvirtBridgeDriver() + d = vif.LibvirtGenericVIFDriver() xml = self._get_instance_xml(d, self.net_bridge, self.mapping_bridge) @@ -187,7 +199,7 @@ class LibvirtVifTestCase(test.TestCase): self.flags(libvirt_use_virtio_for_bridges=True, libvirt_type='qemu') - d = vif.LibvirtBridgeDriver() + d = vif.LibvirtGenericVIFDriver() xml = self._get_instance_xml(d, self.net_bridge, self.mapping_bridge) @@ -206,7 +218,7 @@ class LibvirtVifTestCase(test.TestCase): self.flags(libvirt_use_virtio_for_bridges=True, libvirt_type='xen') - d = vif.LibvirtBridgeDriver() + d = vif.LibvirtGenericVIFDriver() xml = self._get_instance_xml(d, self.net_bridge, self.mapping_bridge) @@ -221,8 +233,15 @@ class LibvirtVifTestCase(test.TestCase): ret = node.findall("driver") self.assertEqual(len(ret), 0) - def test_bridge_driver(self): - d = vif.LibvirtBridgeDriver() + def test_generic_driver_none(self): + d = vif.LibvirtGenericVIFDriver() + self.assertRaises(exception.NovaException, + self._get_instance_xml, + d, + self.net_bridge, + self.mapping_none) + + def _check_bridge_driver(self, d): xml = self._get_instance_xml(d, self.net_bridge, self.mapping_bridge) @@ -237,6 +256,14 @@ class LibvirtVifTestCase(test.TestCase): mac = node.find("mac").get("address") self.assertEqual(mac, self.mapping_bridge['mac']) + def test_bridge_driver(self): + d = vif.LibvirtBridgeDriver() + self._check_bridge_driver(d) + + def test_generic_driver_bridge(self): + d = vif.LibvirtGenericVIFDriver() + self._check_bridge_driver(d) + def test_ovs_ethernet_driver(self): d = vif.LibvirtOpenVswitchDriver() xml = self._get_instance_xml(d,