summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-27 14:26:08 +0000
committerGerrit Code Review <review@openstack.org>2013-06-27 14:26:08 +0000
commit2d5e53c9df16139cafee4f9c8111e0ec9b162ff0 (patch)
tree067847912ea0f2033e00b2d4e74deecf4ffe7f98
parentbf77ba39e5b181590d8e67b7f8446f04b0df3506 (diff)
parenteb52c017a182892e6a62ce5b2ddc30f027311341 (diff)
downloadnova-2d5e53c9df16139cafee4f9c8111e0ec9b162ff0.tar.gz
nova-2d5e53c9df16139cafee4f9c8111e0ec9b162ff0.tar.xz
nova-2d5e53c9df16139cafee4f9c8111e0ec9b162ff0.zip
Merge "xenapi: Make BitTorrent url more flexible"
-rw-r--r--nova/tests/virt/xenapi/test_vm_utils.py4
-rw-r--r--nova/virt/xenapi/vm_utils.py28
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/bittorrent7
3 files changed, 18 insertions, 21 deletions
diff --git a/nova/tests/virt/xenapi/test_vm_utils.py b/nova/tests/virt/xenapi/test_vm_utils.py
index 68caab651..6884ab5a8 100644
--- a/nova/tests/virt/xenapi/test_vm_utils.py
+++ b/nova/tests/virt/xenapi/test_vm_utils.py
@@ -266,7 +266,7 @@ class FetchVhdImageTestCase(test.TestCase):
self._apply_stubouts()
self._common_params_setup(True)
- vm_utils._add_bittorrent_params(self.params)
+ vm_utils._add_bittorrent_params(self.image_id, self.params)
vm_utils._fetch_using_dom0_plugin_with_retry(self.context,
self.session, self.image_id, "bittorrent", self.params,
@@ -289,7 +289,7 @@ class FetchVhdImageTestCase(test.TestCase):
self._common_params_setup(True)
self.mox.StubOutWithMock(self.session, 'call_xenapi')
- vm_utils._add_bittorrent_params(self.params)
+ vm_utils._add_bittorrent_params(self.image_id, self.params)
vm_utils._fetch_using_dom0_plugin_with_retry(self.context,
self.session, self.image_id, "bittorrent", self.params,
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index ac8c9c58b..6e9f09184 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -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):
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/bittorrent b/plugins/xenserver/xenapi/etc/xapi.d/plugins/bittorrent
index 8ae93698d..70c62ec23 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/bittorrent
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/bittorrent
@@ -49,12 +49,11 @@ def _make_torrent_cache():
return torrent_cache_path
-def _fetch_torrent_file(torrent_cache_path, image_id, torrent_base_url):
+def _fetch_torrent_file(torrent_cache_path, image_id, torrent_url):
torrent_path = os.path.join(
torrent_cache_path, image_id + '.torrent')
if not os.path.exists(torrent_path):
- torrent_url = torrent_base_url + "/%s.torrent" % image_id
logging.info("Downloading %s" % torrent_url)
# Write contents to temporary path to ensure we don't have partially
@@ -250,7 +249,7 @@ def _make_seed_cache():
return seed_cache_path
-def download_vhd(session, image_id, torrent_base_url, torrent_seed_duration,
+def download_vhd(session, image_id, torrent_url, torrent_seed_duration,
torrent_seed_chance, torrent_max_last_accessed,
torrent_listen_port_start, torrent_listen_port_end,
torrent_download_stall_cutoff, uuid_stack, sr_path,
@@ -266,7 +265,7 @@ def download_vhd(session, image_id, torrent_base_url, torrent_seed_duration,
_reap_old_torrent_files(torrent_cache_path, torrent_max_last_accessed)
torrent_path = _fetch_torrent_file(
- torrent_cache_path, image_id, torrent_base_url)
+ torrent_cache_path, image_id, torrent_url)
staging_path = utils.make_staging_area(sr_path)
try: