summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-12-05 09:57:51 +0000
committerGerrit Code Review <review@openstack.org>2014-12-05 09:57:51 +0000
commit8e5905636f6f550d7b912922ad1c23d9de0d0c4f (patch)
treea9201a26b5a10f45bc94d7cde2b9644a44e80125
parent11a588787c2e558ac2364a76b6dba49d894f3a58 (diff)
parentedfc2c75fb681be4a9907f4ace49448f06cd4eab (diff)
downloadoslo-utils-8e5905636f6f550d7b912922ad1c23d9de0d0c4f.tar.gz
Merge "Improve error reporting in _get_my_ipv4_address()"
-rw-r--r--oslo/utils/netutils.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/oslo/utils/netutils.py b/oslo/utils/netutils.py
index ecb8d7d..d054c66 100644
--- a/oslo/utils/netutils.py
+++ b/oslo/utils/netutils.py
@@ -139,9 +139,19 @@ def _get_my_ipv4_address():
gtw = netifaces.gateways()
try:
interface = gtw['default'][netifaces.AF_INET][1]
+ except (KeyError, IndexError):
+ LOG.info(_LI('Could not determine default network interface, '
+ 'using 127.0.0.1 for IPv4 address'))
+ try:
return netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
- except Exception:
- LOG.info(_LI("Couldn't get IPv4"))
+ except (KeyError, IndexError):
+ LOG.info(_LI('Could not determine IPv4 address for interface %s, '
+ 'using 127.0.0.1'),
+ interface)
+ except Exception as e:
+ LOG.info(_LI('Could not determine IPv4 address for '
+ 'interface %(interface)s: %(error)s'),
+ {'interface': interface, 'error': e})
return LOCALHOST