summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceCloudStack.py
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-02-23 09:22:50 +0000
committerDaniel Watkins <daniel.watkins@canonical.com>2015-02-23 09:22:50 +0000
commitef84bd214a1d5e0b922c0dd38096f694f8ff406e (patch)
treeb4e0a083cfac9fcb42a887712a8a71aa3147e426 /cloudinit/sources/DataSourceCloudStack.py
parentf8d9ebbe3743bcada75bc1a980b49f493e2da2f1 (diff)
downloadvyos-cloud-init-ef84bd214a1d5e0b922c0dd38096f694f8ff406e.tar.gz
vyos-cloud-init-ef84bd214a1d5e0b922c0dd38096f694f8ff406e.zip
Always close the password server connection, even on failure.
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):