diff options
| author | Joel Moore joelbm24@gmail.com <> | 2010-08-03 11:02:58 -0700 |
|---|---|---|
| committer | Joel Moore joelbm24@gmail.com <> | 2010-08-03 11:02:58 -0700 |
| commit | 8d70245cc78075356ec1ebabc4810df8b07428f6 (patch) | |
| tree | c0998d9c5ab0da118f222898ca2e142f74a4e21e | |
| parent | 75c8ccaadedd59b8b7671c3802b8bcfd6368a998 (diff) | |
| download | nova-8d70245cc78075356ec1ebabc4810df8b07428f6.tar.gz nova-8d70245cc78075356ec1ebabc4810df8b07428f6.tar.xz nova-8d70245cc78075356ec1ebabc4810df8b07428f6.zip | |
Get IP doesn't fail of you not connected to the intetnet
------------- This line and the following will be ignored --------------
modified:
nova/utils.py
unknown:
CA/cacert.pem
CA/index.txt
CA/openssl.cnf
CA/serial
CA/private/cakey.pem
bin/nova@
| -rw-r--r-- | nova/utils.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/nova/utils.py b/nova/utils.py index 0016b656e..da6efd39a 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: |
