summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwan Mellor <ewan.mellor@citrix.com>2010-12-29 02:24:08 +0000
committerTarmac <>2010-12-29 02:24:08 +0000
commit71be236ef4a1fd956f7462ff236ff53d93fef2dc (patch)
treef54907e49a47442084a3109001a051817d3a875e
parentb7b2760cd7cf74fde8ff48bbfefe64c53c3d149c (diff)
parent380b28f89481c52dbcda0b54fd7409b6bc72bb56 (diff)
downloadnova-71be236ef4a1fd956f7462ff236ff53d93fef2dc.tar.gz
nova-71be236ef4a1fd956f7462ff236ff53d93fef2dc.tar.xz
nova-71be236ef4a1fd956f7462ff236ff53d93fef2dc.zip
Bug #694880: nova-compute now depends upon Cheetah even when not using libvirt
Only import Cheetah when needed, as we do already with libvirt and libxml2. This ensures that users of other virt backends don't need Cheetah to run nova-compute. Resubmitted with pep8 violations fixed.
-rw-r--r--nova/tests/test_virt.py1
-rw-r--r--nova/virt/libvirt_conn.py14
2 files changed, 13 insertions, 2 deletions
diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py
index 1c155abe4..4aa489d08 100644
--- a/nova/tests/test_virt.py
+++ b/nova/tests/test_virt.py
@@ -33,6 +33,7 @@ flags.DECLARE('instances_path', 'nova.compute.manager')
class LibvirtConnTestCase(test.TestCase):
def setUp(self):
super(LibvirtConnTestCase, self).setUp()
+ libvirt_conn._late_load_cheetah()
self.flags(fake_call=True)
self.manager = manager.AuthManager()
self.user = self.manager.create_user('fake', 'fake', 'fake',
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 65cf65098..f6a218fa4 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -58,10 +58,9 @@ from nova.compute import instance_types
from nova.compute import power_state
from nova.virt import images
-from Cheetah.Template import Template
-
libvirt = None
libxml2 = None
+Template = None
FLAGS = flags.FLAGS
@@ -88,15 +87,26 @@ flags.DEFINE_bool('allow_project_net_traffic',
def get_connection(read_only):
# These are loaded late so that there's no need to install these
# libraries when not using libvirt.
+ # Cheetah is separate because the unit tests want to load Cheetah,
+ # but not libvirt.
global libvirt
global libxml2
if libvirt is None:
libvirt = __import__('libvirt')
if libxml2 is None:
libxml2 = __import__('libxml2')
+ _late_load_cheetah()
return LibvirtConnection(read_only)
+def _late_load_cheetah():
+ global Template
+ if Template is None:
+ t = __import__('Cheetah.Template', globals(), locals(), ['Template'],
+ -1)
+ Template = t.Template
+
+
def _get_net_and_mask(cidr):
net = IPy.IP(cidr)
return str(net.net()), str(net.netmask())