From 2a16ae2f8479e469e413dfd036bac805163f3ac2 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 3 Nov 2010 15:05:10 +0100 Subject: Change socket type in nova.utils.get_my_ip() to SOCK_DGRAM. This way, we don't actually have to set up a connection. Also, change the destination host to an IP (chose one of Google's DNS's at random) rather than a hostname, so we avoid doing a DNS lookup. --- nova/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/utils.py b/nova/utils.py index bc495a691..e7892a212 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -154,8 +154,8 @@ def get_my_ip(): if getattr(FLAGS, 'fake_tests', None): return '127.0.0.1' try: - csock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - csock.connect(('www.google.com', 80)) + csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + csock.connect(('8.8.8.8', 80)) (addr, port) = csock.getsockname() csock.close() return addr -- cgit