summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-05-03 18:04:47 +0000
committerGerrit Code Review <review@openstack.org>2012-05-03 18:04:48 +0000
commit8fc533699d8ae02da951e0443853159bed80199f (patch)
tree6a9e26061a4a99639ec863b18ac1a6837a77fe0f
parent4697cac310867f700e3fa7a938d169d0561cb952 (diff)
parentc5a9c7550299cde8d9c4a53f5959baa721ef7e53 (diff)
downloadnova-8fc533699d8ae02da951e0443853159bed80199f.tar.gz
nova-8fc533699d8ae02da951e0443853159bed80199f.tar.xz
nova-8fc533699d8ae02da951e0443853159bed80199f.zip
Merge "Ensure that the dom0 we're connected to is the right one"
-rw-r--r--nova/virt/xenapi/connection.py7
-rw-r--r--nova/virt/xenapi/vm_utils.py14
2 files changed, 21 insertions, 0 deletions
diff --git a/nova/virt/xenapi/connection.py b/nova/virt/xenapi/connection.py
index c02f3581d..5ba7a4d54 100644
--- a/nova/virt/xenapi/connection.py
+++ b/nova/virt/xenapi/connection.py
@@ -90,6 +90,10 @@ xenapi_opts = [
default=5.0,
help='The interval used for polling of coalescing vhds. '
'Used only if connection_type=xenapi.'),
+ cfg.BoolOpt('xenapi_check_host',
+ default=True,
+ help='Ensure compute service is running on host XenAPI '
+ 'connects to.'),
cfg.IntOpt('xenapi_vhd_coalesce_max_attempts',
default=5,
help='Max number of times to poll for VHD to coalesce. '
@@ -166,6 +170,9 @@ class XenAPIConnection(driver.ComputeDriver):
return self._host_state
def init_host(self, host):
+ if FLAGS.xenapi_check_host:
+ vm_utils.ensure_correct_host(self._session)
+
try:
vm_utils.cleanup_attached_vdis(self._session)
except Exception:
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 540a144c8..83dc7180a 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1819,3 +1819,17 @@ def _prepare_injectables(inst, networks_info):
searchList=[{'interfaces': interfaces_info,
'use_ipv6': FLAGS.use_ipv6}]))
return key, net, metadata
+
+
+def ensure_correct_host(session):
+ """Ensure we're connected to the host we're running on. This is the
+ required configuration for anything that uses vdi_attached_here."""
+ this_vm_uuid = get_this_vm_uuid()
+
+ try:
+ session.call_xenapi('VM.get_by_uuid', this_vm_uuid)
+ except session.XenAPI.Failure as exc:
+ if exc.details[0] != 'UUID_INVALID':
+ raise
+ raise Exception(_('This domU must be running on the host '
+ 'specified by xenapi_connection_url'))