summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-01 00:28:59 +0000
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-01 00:28:59 +0000
commit4e4711ccfc7ce3c3df704a8635dccd506d6e7f01 (patch)
tree3aaae6f23473505c4e12f22dedb9e048d9308fef /nova/virt
parent026c83551fa2e07f7f20d6b163f7da93e331b084 (diff)
Units tests fixed partially.
Still need to address checking data injected into xenstore need to convert string into dict or similar. Also todo PEP8 fixes
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/fake.py9
-rw-r--r--nova/virt/xenapi/vm_utils.py3
-rw-r--r--nova/virt/xenapi/vmops.py7
-rw-r--r--nova/virt/xenapi_conn.py2
4 files changed, 19 insertions, 2 deletions
diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py
index 08e2a03f7..664cfbd79 100644
--- a/nova/virt/xenapi/fake.py
+++ b/nova/virt/xenapi/fake.py
@@ -153,7 +153,14 @@ def VM_get_xenstore_data(vm_ref):
return _db_content['VM'][vm_ref].get('xenstore_data', '')
+def VM_remove_from_xenstore_data(vm_ref, key):
+ db_ref = _db_content['VM'][vm_ref]
+ if not 'xenstore_data' in db_ref:
+ return
+ db_ref['xenstore_data'][key] = None
+
def VM_add_to_xenstore_data(vm_ref, key, value):
+ LOG.debug("ADDING TO XENSTORE DATA %s %s",key,value)
db_ref = _db_content['VM'][vm_ref]
if not 'xenstore_data' in db_ref:
db_ref['xenstore_data'] = {}
@@ -503,7 +510,9 @@ class SessionBase(object):
def _get_by_field(self, recs, k, v, return_singleton):
result = []
+ LOG.debug("_get_by_field!!!! - %d", return_singleton)
for ref, rec in recs.iteritems():
+ LOG.debug("k:%s,rec[k]:%s,v:%s",k,rec.get(k),v)
if rec.get(k) == v:
result.append(ref)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 0434f745d..a01bab8de 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -409,8 +409,10 @@ class VMHelper(HelperBase):
@classmethod
def lookup(cls, session, i):
"""Look the instance i up, and returns it if available"""
+ LOG.debug("Entering lookup for instance:%s",str(i))
vms = session.get_xenapi().VM.get_by_name_label(i)
n = len(vms)
+ LOG.debug("n:%d",n)
if n == 0:
return None
elif n > 1:
@@ -480,7 +482,6 @@ class VMHelper(HelperBase):
else:
try:
# This try block ensures that the umount occurs
-
xe_guest_agent_filename = os.path.join(
tmpdir, FLAGS.xenapi_agent_path)
if os.path.isfile(xe_guest_agent_filename):
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index cc84b7032..c137d4931 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -117,6 +117,7 @@ class VMOps(object):
VMHelper.preconfigure_instance(self._session, instance, vdi_ref)
# inject_network_info and create vifs
+ LOG.debug("About to run inject_network_info")
networks = self.inject_network_info(instance)
self.create_vifs(instance, networks)
@@ -186,6 +187,7 @@ class VMOps(object):
# Must be the instance name
instance_name = instance_or_vm
except (AttributeError, KeyError):
+ #
# Note the the KeyError will only happen with fakes.py
# Not a string; must be an ID or a vm instance
if isinstance(instance_or_vm, (int, long)):
@@ -201,8 +203,12 @@ class VMOps(object):
instance_name = instance_or_vm
else:
instance_name = instance_or_vm.name
+ #fake xenapi does not use OpaqueRef as a prefix
+ #when running tests we will always end up here
vm = VMHelper.lookup(self._session, instance_name)
if vm is None:
+ if FLAGS.xenapi_connection_url == 'test_url':
+ return instance_or_vm
raise exception.NotFound(
_('Instance not present %s') % instance_name)
return vm
@@ -496,6 +502,7 @@ class VMOps(object):
'ips': [ip_dict(ip) for ip in network_IPs]}
self.write_to_param_xenstore(vm_opaque_ref, {location: mapping})
try:
+ logging.debug("About to run write_to_xenstore")
self.write_to_xenstore(vm_opaque_ref, location,
mapping['location'])
except KeyError:
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index b9e87c2ce..9f8b6af02 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -106,7 +106,7 @@ flags.DEFINE_bool('xenapi_inject_image',
' data into the disk image should be made.'
' Used only if connection_type=xenapi.')
flags.DEFINE_string('xenapi_agent_path',
- '/usr/sbin/xe-update-networking',
+ 'usr/sbin/xe-update-networking',
'Specifies the path in which the xenapi guest agent'
' should be located. If the agent is present,'
' network configuration if not injected into the image'