Fix no IP on interface error

Finding an IPv4 address to advertise fails and crashes if the
interface exists but has no valid IPs.  This can be fixed by
adding KeyError to the exceptions caught.

Change-Id: I60204427ec5201696d02c5c26f4b43a00d794413
Closes-Bug: #1342448
This commit is contained in:
Ellen Hui 2014-07-16 00:28:22 +00:00
parent edcf7b11b6
commit 5e1aa0a8f8

@ -175,7 +175,7 @@ class GenericHardwareManager(HardwareManager):
try:
addrs = netifaces.ifaddresses(interface_id)
return addrs[netifaces.AF_INET][0]['addr']
except (ValueError, IndexError):
except (ValueError, IndexError, KeyError):
# No default IPv4 address found
return None