summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dan.prince@rackspace.com>2011-08-04 20:57:49 +0000
committerTarmac <>2011-08-04 20:57:49 +0000
commita546f5e488e6486bdf21678fb829ccc567d6e4aa (patch)
treea15114e0bd907f8e675194194429d164c0bca16b
parent848b10a7fbc1da9d1d6615e56f3aa212f366ca3d (diff)
parent5e1d63cf3b16f78f02e9c2642f60a43402a933a9 (diff)
Updates to the XenServer glance plugin so that it obtains the set of
existing headers and sends them along with the request to PUT a snapshotted image into glance.
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/glance19
1 files changed, 17 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..17a5dbbfb 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -248,6 +248,19 @@ 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
+
# 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 +273,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 +284,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)