summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorSean Dague <sdague@linux.vnet.ibm.com>2012-06-01 17:19:54 -0400
committerSean Dague <sdague@linux.vnet.ibm.com>2012-06-11 11:16:18 -0400
commitb1dc846170e67ce63ef78d9ef86fe287cb97c9a1 (patch)
treebf506eddd19189c79a3d9a3a49893bb1ec1f3e17 /nova/virt
parent9072639e9440cd1b0a0c75904a13cb6a5111a0f4 (diff)
add unit tests for new virt driver loader
Continues work on bp:virt-driver-cleanup Add unit tests to test the loading of the new and old style loaders Fix libvirt driver to make read_only optional on the constructor Fix fake driver to correctly have the kwarg be read_only Add VirtDriverNotFound exception to make get_connection failures more explicit Factor out fake backend replacement (currently just libvirt) to a seperate super class Remove touching FLAGS and use self.flags instead Change-Id: I089d0dd9c97f87478b922f4c3e26c45891eaf6cc
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/connection.py4
-rw-r--r--nova/virt/fake.py2
-rw-r--r--nova/virt/libvirt/connection.py2
3 files changed, 4 insertions, 4 deletions
diff --git a/nova/virt/connection.py b/nova/virt/connection.py
index 8bf1ed5f5..a62cb6cc6 100644
--- a/nova/virt/connection.py
+++ b/nova/virt/connection.py
@@ -21,6 +21,7 @@
import sys
+from nova import exception
from nova import flags
from nova import log as logging
from nova.openstack.common import importutils
@@ -72,8 +73,7 @@ def get_connection(read_only=False):
driver_name = known_drivers.get(FLAGS.connection_type)
if driver_name is None:
- raise Exception('Unknown virt connection type "%s"' %
- FLAGS.connection_type)
+ raise exception.VirtDriverNotFound(name=FLAGS.connection_type)
conn = importutils.import_object(driver_name, read_only=read_only)
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 0e7a4c1e3..f13f71a8d 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -46,7 +46,7 @@ class FakeInstance(object):
class FakeDriver(driver.ComputeDriver):
"""Fake hypervisor driver"""
- def __init__(self, readonly=False):
+ def __init__(self, read_only=False):
self.instances = {}
self.host_status = {
'host_name-description': 'Fake Host',
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 24e08cc12..fe117159b 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -233,7 +233,7 @@ def _get_eph_disk(ephemeral):
class LibvirtDriver(driver.ComputeDriver):
- def __init__(self, read_only):
+ def __init__(self, read_only=False):
super(LibvirtDriver, self).__init__()
global libvirt