xenapi: glance plugin should close connections
Current the xenapi glance plugin does not close
httplib connections when exceptions are raised.
Note this code is run under python 2.4 so with
is not available.
Fixes bug 1197846
Change-Id: I5cfb067320e7506109c301532a95fe83aa4fd0f9
This commit is contained in:

committed by
Gerrit Code Review

parent
b9503b57e2
commit
d871738859
@@ -132,9 +132,13 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
|
||||
conn = httplib.HTTPSConnection(glance_host, glance_port)
|
||||
else:
|
||||
conn = httplib.HTTPConnection(glance_host, glance_port)
|
||||
except Exception, error:
|
||||
raise RetryableError(error)
|
||||
|
||||
# NOTE(sirp): httplib under python2.4 won't accept a file-like object
|
||||
# to request
|
||||
try:
|
||||
try:
|
||||
# NOTE(sirp): httplib under python2.4 won't accept
|
||||
# a file-like object to request
|
||||
conn.putrequest('PUT', '/v1/images/%s' % image_id)
|
||||
except Exception, error:
|
||||
raise RetryableError(error)
|
||||
@@ -144,9 +148,9 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
|
||||
# 1. OVF as a container format is misnamed. We really should be using
|
||||
# OVA since that is the name for the container format; OVF is the
|
||||
# standard applied to the manifest file contained within.
|
||||
# 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.
|
||||
# 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.
|
||||
|
||||
# NOTE(dprince): In order to preserve existing Glance properties
|
||||
# we set X-Glance-Registry-Purge-Props on this request.
|
||||
@@ -201,7 +205,7 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
% (resp.status, image_id, glance_host, glance_port))
|
||||
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user