summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 0b23de7cd..63db080f1 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -119,11 +119,15 @@ def get_my_ip():
'''
if getattr(FLAGS, 'fake_tests', None):
return '127.0.0.1'
- csock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- csock.connect(('www.google.com', 80))
- (addr, port) = csock.getsockname()
- csock.close()
- return addr
+ try:
+ csock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ csock.connect(('www.google.com', 80))
+ (addr, port) = csock.getsockname()
+ csock.close()
+ return addr
+ except socket.gaierror as ex:
+ logging.warn("Couldn't get IP, using 127.0.0.1 %s", ex)
+ return "127.0.0.1"
def isotime(at=None):
if not at: