diff options
author | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-06-29 10:56:59 -0400 |
---|---|---|
committer | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-07-02 16:45:06 -0400 |
commit | 3b3e325ee59505d75f1142181c2ee25b440b3c63 (patch) | |
tree | 780d22d052e259a240774e39c6e8b504eddf0145 | |
parent | 2038e933bd8bde659e31b4a78e2211a585e3dcec (diff) | |
download | nova-3b3e325ee59505d75f1142181c2ee25b440b3c63.tar.gz nova-3b3e325ee59505d75f1142181c2ee25b440b3c63.tar.xz nova-3b3e325ee59505d75f1142181c2ee25b440b3c63.zip |
use import_object_ns for compute_driver loading
Part of bp:virt-driver-cleanup
Convert to using import_object_ns which allows us
to import specific virt drivers as 'libvirt.LibvirtDriver'
instead of 'nova.virt.libvirt.libvirtDriver'.
Update testing to ensure this works with both short
names and long names (which need not be in the nova.virt
namespace).
Change-Id: I5eee3389c7719d5f361532b0eddaa249233283a5
-rw-r--r-- | nova/compute/manager.py | 2 | ||||
-rw-r--r-- | nova/tests/test_virt_drivers.py | 6 | ||||
-rw-r--r-- | nova/virt/connection.py | 13 |
3 files changed, 13 insertions, 8 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 3cdf35266..98552d641 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -239,7 +239,7 @@ class ComputeManager(manager.SchedulerDependentManager): try: self.driver = utils.check_isinstance( - importutils.import_object(compute_driver), + importutils.import_object_ns('nova.virt', compute_driver), driver.ComputeDriver) except ImportError as e: LOG.error(_("Unable to load the virtualization driver: %s") % (e)) diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 6443c6721..91845dce7 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -117,9 +117,13 @@ class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase): final class""" # if your driver supports being tested in a fake way, it can go here + # + # both long form and short form drivers are supported new_drivers = { 'nova.virt.fake.FakeDriver': 'FakeDriver', - 'nova.virt.libvirt.LibvirtDriver': 'LibvirtDriver' + 'nova.virt.libvirt.LibvirtDriver': 'LibvirtDriver', + 'fake.FakeDriver': 'FakeDriver', + 'libvirt.LibvirtDriver': 'LibvirtDriver' } # NOTE(sdague): remove after Folsom release when connection_type diff --git a/nova/virt/connection.py b/nova/virt/connection.py index 079675da3..e47079b80 100644 --- a/nova/virt/connection.py +++ b/nova/virt/connection.py @@ -33,11 +33,11 @@ LOG = logging.getLogger(__name__) FLAGS = flags.FLAGS known_drivers = { - 'baremetal': 'nova.virt.baremetal.proxy.ProxyConnection', - 'fake': 'nova.virt.fake.FakeDriver', - 'libvirt': 'nova.virt.libvirt.LibvirtDriver', - 'vmwareapi': 'nova.virt.vmwareapi_conn.VMWareESXDriver', - 'xenapi': 'nova.virt.xenapi.connection.XenAPIDriver' + 'baremetal': 'baremetal.proxy.ProxyConnection', + 'fake': 'fake.FakeDriver', + 'libvirt': 'libvirt.LibvirtDriver', + 'vmwareapi': 'vmwareapi_conn.VMWareESXDriver', + 'xenapi': 'xenapi.connection.XenAPIDriver' } @@ -75,7 +75,8 @@ def get_connection(read_only=False): if driver_name is None: raise exception.VirtDriverNotFound(name=FLAGS.connection_type) - conn = importutils.import_object(driver_name, read_only=read_only) + conn = importutils.import_object_ns('nova.virt', driver_name, + read_only=read_only) if conn is None: LOG.error(_('Failed to open connection to underlying virt platform')) |