summaryrefslogtreecommitdiffstats
path: root/nova/virt/xenapi/vm_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/virt/xenapi/vm_utils.py')
-rw-r--r--nova/virt/xenapi/vm_utils.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index ff6f7f266..6e9f09184 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1017,7 +1017,7 @@ def _create_image(context, session, instance, name_label, image_id,
elif cache_images == 'all':
cache = True
elif cache_images == 'some':
- sys_meta = utils.metadata_to_dict(instance['system_metadata'])
+ sys_meta = utils.instance_sys_meta(instance)
try:
cache = strutils.bool_from_string(sys_meta['image_cache_in_nova'])
except KeyError:
@@ -1112,7 +1112,7 @@ def _image_uses_bittorrent(context, instance):
if xenapi_torrent_images == 'all':
bittorrent = True
elif xenapi_torrent_images == 'some':
- sys_meta = utils.metadata_to_dict(instance['system_metadata'])
+ sys_meta = utils.instance_sys_meta(instance)
try:
bittorrent = strutils.bool_from_string(
sys_meta['image_bittorrent'])
@@ -1142,7 +1142,7 @@ def _fetch_vhd_image(context, session, instance, image_id):
if _image_uses_bittorrent(context, instance):
plugin_name = 'bittorrent'
callback = None
- _add_bittorrent_params(params)
+ _add_bittorrent_params(image_id, params)
else:
plugin_name = 'glance'
callback = _generate_glance_callback(context)
@@ -1180,20 +1180,18 @@ def _generate_glance_callback(context):
return pick_glance
-def _add_bittorrent_params(params):
- params['torrent_base_url'] = CONF.xenapi_torrent_base_url
- params['torrent_seed_duration'] = CONF.xenapi_torrent_seed_duration
- params['torrent_seed_chance'] = CONF.xenapi_torrent_seed_chance
- params['torrent_max_last_accessed'] =\
- CONF.xenapi_torrent_max_last_accessed
- params['torrent_listen_port_start'] =\
- CONF.xenapi_torrent_listen_port_start
- params['torrent_listen_port_end'] =\
- CONF.xenapi_torrent_listen_port_end
- params['torrent_download_stall_cutoff'] =\
- CONF.xenapi_torrent_download_stall_cutoff
- params['torrent_max_seeder_processes_per_host'] =\
- CONF.xenapi_torrent_max_seeder_processes_per_host
+def _add_bittorrent_params(image_id, params):
+ params['torrent_url'] = urlparse.urljoin(CONF.xenapi_torrent_base_url,
+ "%s.torrent" % image_id)
+ params['torrent_seed_duration'] = CONF.xenapi_torrent_seed_duration
+ params['torrent_seed_chance'] = CONF.xenapi_torrent_seed_chance
+ params['torrent_max_last_accessed'] = CONF.xenapi_torrent_max_last_accessed
+ params['torrent_listen_port_start'] = CONF.xenapi_torrent_listen_port_start
+ params['torrent_listen_port_end'] = CONF.xenapi_torrent_listen_port_end
+ params['torrent_download_stall_cutoff'] = \
+ CONF.xenapi_torrent_download_stall_cutoff
+ params['torrent_max_seeder_processes_per_host'] = \
+ CONF.xenapi_torrent_max_seeder_processes_per_host
def _get_vdi_chain_size(session, vdi_uuid):