From dbbbbf4ecb2c7b03ebb30fa11e077d35b2186cbb Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Thu, 7 Feb 2013 21:39:31 -0800
Subject: [PATCH] Enable tox use of site-packages for libvirt.

Enable the use of site-packages in tox which will allow the use of the
system install of libvirt while testing.

Hardcode the libvirt host UUID for tests that check this UUID when
system libvirt is being used. Without this hardcoding eight tests
would fail when using the system libvirt install.

Partially fixes bug #1113181

Change-Id: I59c5fbd45639962c0963298203c39759b6ca2d11
---
 nova/tests/test_libvirt.py | 7 +++++++
 tox.ini                    | 1 +
 2 files changed, 8 insertions(+)

diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index fa691c2e1dc8..e56a50ffb254 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -291,6 +291,13 @@ class LibvirtConnTestCase(test.TestCase):
         self.useFixture(fixtures.MonkeyPatch(
             'nova.virt.libvirt.driver.libvirt_utils',
             fake_libvirt_utils))
+        # Force libvirt to return a host UUID that matches the serial in
+        # nova.tests.fakelibvirt. This is necessary because the host UUID
+        # returned by libvirt becomes the serial whose value is checked for in
+        # test_xml_and_uri_* below.
+        self.useFixture(fixtures.MonkeyPatch(
+            'nova.virt.libvirt.driver.LibvirtDriver.get_host_uuid',
+            lambda _: 'cef19ce0-0ca2-11df-855d-b19fbce37686'))
         self.useFixture(fixtures.MonkeyPatch(
             'nova.virt.libvirt.imagebackend.libvirt_utils',
             fake_libvirt_utils))
diff --git a/tox.ini b/tox.ini
index 4849eff4e15a..ca135209bb55 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,6 +2,7 @@
 envlist = py26,py27,pep8
 
 [testenv]
+sitepackages = True
 setenv = VIRTUAL_ENV={envdir}
          LANG=en_US.UTF-8
          LANGUAGE=en_US:en