summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-08-08 15:31:29 +0000
committerEd Leafe <ed@leafe.com>2011-08-08 15:31:29 +0000
commit966b7218a0fc96222e0ef0a22526f1bf3e7f2a9c (patch)
tree66204136d513a12546f4d3fa1a687e520d1834f2 /plugins
parent3f7c71fd38a67e6983de0bb268e5c65abc5753f4 (diff)
parentec57e2a27ebfc8eba84d82f5372408e3d85a9272 (diff)
downloadnova-966b7218a0fc96222e0ef0a22526f1bf3e7f2a9c.tar.gz
nova-966b7218a0fc96222e0ef0a22526f1bf3e7f2a9c.tar.xz
nova-966b7218a0fc96222e0ef0a22526f1bf3e7f2a9c.zip
Merged trunk
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/glance22
1 files changed, 20 insertions, 2 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index 86e837849..a06312890 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -248,6 +248,22 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type,
using chunked-transfer-encoded HTTP.
"""
conn = httplib.HTTPConnection(glance_host, glance_port)
+
+ # NOTE(dprince): We need to resend any existing Glance meta/property
+ # headers so they are preserved in Glance. We obtain them here with a
+ # HEAD request.
+ conn.request('HEAD', '/v1/images/%s' % image_id)
+ resp = conn.getresponse()
+ if resp.status != httplib.OK:
+ raise Exception("Unexpected response from Glance %i" % resp.status)
+ headers = {}
+ for header, value in resp.getheaders():
+ if header.lower().startswith("x-image-meta-property-"):
+ headers[header.lower()] = value
+
+ # Toss body so connection state-machine is ready for next request/response
+ resp.read()
+
# NOTE(sirp): httplib under python2.4 won't accept a file-like object
# to request
conn.putrequest('PUT', '/v1/images/%s' % image_id)
@@ -260,7 +276,7 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type,
# 2. We're currently uploading a vanilla tarball. In order to be OVF/OVA
# compliant, we'll need to embed a minimal OVF manifest as the first
# file.
- headers = {
+ ovf_headers = {
'content-type': 'application/octet-stream',
'transfer-encoding': 'chunked',
'x-image-meta-is-public': 'True',
@@ -271,7 +287,9 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type,
# If we have an auth_token, set an x-auth-token header
if auth_token:
- headers['x-auth-token'] = auth_token
+ ovf_headers['x-auth-token'] = auth_token
+
+ headers.update(ovf_headers)
for header, value in headers.iteritems():
conn.putheader(header, value)