From 51546e79f366d14f25bb5a933a3ab0ad033e7a3d Mon Sep 17 00:00:00 2001 From: Jian Wen Date: Wed, 12 Dec 2012 22:14:18 +0800 Subject: libvirt: Make vif_driver.plug() returns None The return value of vif_driver.plug() was used only when nova wrote the libvirt.xml file on initial boot of the instance. Make it returns None, and add get_config() to get the configurations if needed. If LibvirtBridgeDriver is used when the nova-comptue inits, we call vif_driver.plug() without get the VIF configurations. By doing this plug doesn't raise if the instance has not yet got a fixed-ip. Fixes bug 1076309. Change-Id: I0fafb3d98e3139bce0ef2cee04cab428a0621696 --- nova/tests/fake_network.py | 5 ++++- nova/tests/test_libvirt_vif.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 1b96f95dd..4a04986ec 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -54,7 +54,7 @@ class FakeVIFDriver(object): def setattr(self, key, val): self.__setattr__(key, val) - def plug(self, instance, vif): + def get_config(self, instance, network, mapping): conf = libvirt_config.LibvirtConfigGuestInterface() for attr, val in conf.__dict__.iteritems(): @@ -63,6 +63,9 @@ class FakeVIFDriver(object): return conf + def plug(self, instance, vif): + pass + class FakeModel(dict): """Represent a model from the db""" diff --git a/nova/tests/test_libvirt_vif.py b/nova/tests/test_libvirt_vif.py index bd51bf01a..5cd2ea83c 100644 --- a/nova/tests/test_libvirt_vif.py +++ b/nova/tests/test_libvirt_vif.py @@ -74,7 +74,7 @@ class LibvirtVifTestCase(test.TestCase): conf.memory = 100 * 1024 conf.vcpus = 4 - nic = driver.plug(self.instance, (self.net, self.mapping)) + nic = driver.get_config(self.instance, self.net, self.mapping) conf.add_device(nic) return conf.to_xml() -- cgit