summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-12 18:16:06 +0000
committerGerrit Code Review <review@openstack.org>2012-11-12 18:16:06 +0000
commit6a63baadae2cb1c99b0e6e107dab9a0f454621fc (patch)
tree847ebfab1c20f641a784efbfee996f157c6b09ae
parent411ee404f50462facafbfb38beaed61147a60e0d (diff)
parentda1b387d36cda0297da097f1389bd382559d6fa5 (diff)
Merge "Avoid unnecessary system_metadata db lookup"
-rw-r--r--nova/virt/xenapi/vm_utils.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index d0f59f56f..f6d28ca54 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -38,7 +38,6 @@ from nova import block_device
from nova.compute import instance_types
from nova.compute import power_state
from nova import config
-from nova import db
from nova import exception
from nova import flags
from nova.image import glance
@@ -181,6 +180,13 @@ class ImageType(object):
}.get(image_type_id)
+def _system_metadata_to_dict(system_metadata):
+ result = {}
+ for item in system_metadata:
+ result[item['key']] = item['value']
+ return result
+
+
def create_vm(session, instance, name_label, kernel, ramdisk,
use_pv_kernel=False):
"""Create a VM record. Returns new VM reference.
@@ -922,9 +928,7 @@ def _create_image(context, session, instance, name_label, image_id,
elif cache_images == 'all':
cache = True
elif cache_images == 'some':
- # FIXME(sirp): This should be eager loaded like instance metadata
- sys_meta = db.instance_system_metadata_get(context,
- instance['uuid'])
+ sys_meta = _system_metadata_to_dict(instance['system_metadata'])
try:
cache = utils.bool_from_str(sys_meta['image_cache_in_nova'])
except KeyError:
@@ -1017,9 +1021,7 @@ def _image_uses_bittorrent(context, instance):
if xenapi_torrent_images == 'all':
bittorrent = True
elif xenapi_torrent_images == 'some':
- # FIXME(sirp): This should be eager loaded like instance metadata
- sys_meta = db.instance_system_metadata_get(context,
- instance['uuid'])
+ sys_meta = _system_metadata_to_dict(instance['system_metadata'])
try:
bittorrent = utils.bool_from_str(sys_meta['image_bittorrent'])
except KeyError: