summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2012-03-07 15:53:30 -0500
committerMark Washenberger <mark.washenberger@rackspace.com>2012-03-08 14:02:49 -0500
commite6b70b5c37070579c916cc5a1ea511ff9934851b (patch)
treec8ee19dc66e36720d869bef5b965b9429df9aec1 /plugins
parent30a9ae2f923cf89f6b0acaa30d441170d1d5539c (diff)
downloadnova-e6b70b5c37070579c916cc5a1ea511ff9934851b.tar.gz
nova-e6b70b5c37070579c916cc5a1ea511ff9934851b.tar.xz
nova-e6b70b5c37070579c916cc5a1ea511ff9934851b.zip
Increase logging for xenapi plugin glance uploads
Without this change, the glance plugin is pretty quiet about image uploads. But it can definitely be helpful to debugging to have information such as which glance server is handling the upload, how much data was sent, and more information about the glance server response if it was something other than 200 OK. Change-Id: I0269478ad1061fc2021ef4b5d9c3c1dea9b2f6cb
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/glance12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index e7998bb8e..95fe54524 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -354,6 +354,8 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
Create a tarball of the image and then stream that into Glance
using chunked-transfer-encoded HTTP.
"""
+ url = 'http://%s:%s/v1/images/%s' % (glance_host, glance_port, image_id)
+ logging.info("Writing image data to %s" % url)
conn = httplib.HTTPConnection(glance_host, glance_port)
# NOTE(sirp): httplib under python2.4 won't accept a file-like object
@@ -395,17 +397,25 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
tar_cmd = "tar -zc --directory=%(staging_path)s ." % locals()
tar_proc = _make_subprocess(tar_cmd, stdout=True, stderr=True)
+ length = 0
chunk = tar_proc.stdout.read(CHUNK_SIZE)
while chunk:
+ length += len(chunk)
conn.send("%x\r\n%s\r\n" % (len(chunk), chunk))
chunk = tar_proc.stdout.read(CHUNK_SIZE)
conn.send("0\r\n\r\n")
+ logging.info("Wrote %s bytes to %s" % (length, url))
_finish_subprocess(tar_proc, tar_cmd)
resp = conn.getresponse()
if resp.status != httplib.OK:
- raise Exception("Unexpected response from Glance %i" % resp.status)
+ logging.error("Unexpected response while writing image data to %s: "
+ "Response Status: %i, Response body: %s"
+ % (url, resp.status, resp.read()))
+ raise Exception("Unexpected response [%i] while uploading image [%s] "
+ "to glance host [%s:%s]"
+ % (resp.status, image_id, glance_host, glance_port))
conn.close()