summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceCloudStack.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/DataSourceCloudStack.py')
-rw-r--r--cloudinit/sources/DataSourceCloudStack.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/cloudinit/sources/DataSourceCloudStack.py b/cloudinit/sources/DataSourceCloudStack.py
index 0c3c51c0..996076b1 100644
--- a/cloudinit/sources/DataSourceCloudStack.py
+++ b/cloudinit/sources/DataSourceCloudStack.py
@@ -66,10 +66,12 @@ class CloudStackPasswordServerClient(object):
# Because we're reading off the socket directly, we can't re-use the
# connection.
conn = http_client.HTTPConnection(self.virtual_router_address, 8080)
- conn.request('GET', '', headers={'DomU_Request': domu_request})
- conn.sock.settimeout(30)
- output = conn.sock.recv(1024).decode('utf-8').strip()
- conn.close()
+ try:
+ conn.request('GET', '', headers={'DomU_Request': domu_request})
+ conn.sock.settimeout(30)
+ output = conn.sock.recv(1024).decode('utf-8').strip()
+ finally:
+ conn.close()
return output
def get_password(self):