diff options
author | Dan Prince <dan.prince@rackspace.com> | 2011-08-04 10:41:42 -0400 |
---|---|---|
committer | Dan Prince <dan.prince@rackspace.com> | 2011-08-04 10:41:42 -0400 |
commit | 5e1d63cf3b16f78f02e9c2642f60a43402a933a9 (patch) | |
tree | fd18afc3f239bdeff729cbdb08ce8db809da099b /plugins | |
parent | 9da88eac8fe728f506633f86ec6e75cf0212795b (diff) | |
download | nova-5e1d63cf3b16f78f02e9c2642f60a43402a933a9.tar.gz nova-5e1d63cf3b16f78f02e9c2642f60a43402a933a9.tar.xz nova-5e1d63cf3b16f78f02e9c2642f60a43402a933a9.zip |
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.
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 19 |
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) |