summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwan Mellor <ewan.mellor@citrix.com>2010-08-02 08:31:19 +0100
committerEwan Mellor <ewan.mellor@citrix.com>2010-08-02 08:31:19 +0100
commit40b2bbcfe6274aca9fd4361c56b2b042ba22e3c2 (patch)
tree0d40435fd484f9aea2f51dd296aa656a05f0e9ad
parente588b82a991107720137d21d89f0fb24f55fdf50 (diff)
downloadnova-40b2bbcfe6274aca9fd4361c56b2b042ba22e3c2.tar.gz
nova-40b2bbcfe6274aca9fd4361c56b2b042ba22e3c2.tar.xz
nova-40b2bbcfe6274aca9fd4361c56b2b042ba22e3c2.zip
Turn the private _image_url(path) into a public image_url(image). This will
be used by virt.xenapi to instruct xapi as to which images to download. As part of this, the value returned became a complete URL, with http:// on the front. This caused the URL parsing to be adjusted.
-rw-r--r--nova/virt/images.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py
index 92210e242..698536324 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -23,6 +23,7 @@ Handling of VM disk images.
import os.path
import time
+import urlparse
from nova import flags
from nova import process
@@ -42,7 +43,7 @@ def fetch(image, path, user):
return f(image, path, user)
def _fetch_s3_image(image, path, user):
- url = _image_url('%s/image' % image)
+ url = image_url(image)
# This should probably move somewhere else, like e.g. a download_as
# method on User objects and at the same time get rewritten to use
@@ -50,8 +51,8 @@ def _fetch_s3_image(image, path, user):
headers = {}
headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
- uri = '/' + url.partition('/')[2]
- auth = signer.Signer(user.secret.encode()).s3_authorization(headers, 'GET', uri)
+ (_, _, url_path, _, _, _) = urlparse.urlparse(url)
+ auth = signer.Signer(user.secret.encode()).s3_authorization(headers, 'GET', url_path)
headers['Authorization'] = 'AWS %s:%s' % (user.access, auth)
cmd = ['/usr/bin/curl', '--silent', url]
@@ -68,5 +69,6 @@ def _fetch_local_image(image, path, _):
def _image_path(path):
return os.path.join(FLAGS.images_path, path)
-def _image_url(path):
- return "%s:%s/_images/%s" % (FLAGS.s3_host, FLAGS.s3_port, path)
+def image_url(image):
+ return "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port,
+ image)