summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorArmando Migliaccio <armando.migliaccio@citrix.com>2010-12-07 18:57:44 +0000
committerArmando Migliaccio <armando.migliaccio@citrix.com>2010-12-07 18:57:44 +0000
commitd7ca22cce7df319efc57a2e8224016817c92bbdb (patch)
tree773a7254c441e448281172916c3d93e6497f3148 /nova/virt
parent09ebc4c33ff52c352cdab54fea41d1b116a446f4 (diff)
downloadnova-d7ca22cce7df319efc57a2e8224016817c92bbdb.tar.gz
nova-d7ca22cce7df319efc57a2e8224016817c92bbdb.tar.xz
nova-d7ca22cce7df319efc57a2e8224016817c92bbdb.zip
importing XenAPI module loaded late
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/vm_utils.py9
-rw-r--r--nova/virt/xenapi/vmops.py6
-rw-r--r--nova/virt/xenapi_conn.py8
3 files changed, 18 insertions, 5 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 407acda6e..99d484ca2 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -20,15 +20,14 @@ their attributes like VDIs, VIFs, as well as their lookup functions.
"""
import logging
-import XenAPI
from twisted.internet import defer
from nova import utils
from nova.auth.manager import AuthManager
from nova.compute import instance_types
-from nova.virt import images
from nova.compute import power_state
+from nova.virt import images
XENAPI_POWER_STATE = {
'Halted': power_state.SHUTDOWN,
@@ -37,13 +36,17 @@ XENAPI_POWER_STATE = {
'Suspended': power_state.SHUTDOWN, # FIXME
'Crashed': power_state.CRASHED}
+XenAPI = None
+
class VMHelper():
"""
The class that wraps the helper methods together.
"""
def __init__(self):
- return
+ global XenAPI
+ if XenAPI is None:
+ XenAPI = __import__('XenAPI')
@classmethod
@defer.inlineCallbacks
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 3696782b3..d36cdaea5 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -19,7 +19,6 @@ Management class for VM-related functions (spawn, reboot, etc).
"""
import logging
-import XenAPI
from twisted.internet import defer
@@ -29,12 +28,17 @@ from nova.auth.manager import AuthManager
from nova.virt.xenapi.network_utils import NetworkHelper
from nova.virt.xenapi.vm_utils import VMHelper
+XenAPI = None
+
class VMOps(object):
"""
Management class for VM-related tasks
"""
def __init__(self, session):
+ global XenAPI
+ if XenAPI is None:
+ XenAPI = __import__('XenAPI')
self._session = session
def list_instances(self):
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index a2eac4dc2..26b30bf92 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -49,7 +49,6 @@ reactor thread if the VM.get_by_name_label or VM.get_record calls block.
import logging
import xmlrpclib
-import XenAPI
from twisted.internet import defer
from twisted.internet import reactor
@@ -78,10 +77,17 @@ flags.DEFINE_float('xenapi_task_poll_interval',
'(Async.VM.start, etc). Used only if '
'connection_type=xenapi.')
+XenAPI = None
+
def get_connection(_):
"""Note that XenAPI doesn't have a read-only connection mode, so
the read_only parameter is ignored."""
+ # This is loaded late so that there's no need to install this
+ # library when not using XenAPI.
+ global XenAPI
+ if XenAPI is None:
+ XenAPI = __import__('XenAPI')
url = FLAGS.xenapi_connection_url
username = FLAGS.xenapi_connection_username
password = FLAGS.xenapi_connection_password