Show error message for invalid IPs in client install

Re-raise the thrown exception to get an error message
instead of a traceback during ipa-client-install with
invalid IP address.

https://fedorahosted.org/freeipa/ticket/6340

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Tomas Krizek 2016-09-20 12:10:09 +02:00 committed by Martin Babinsky
parent 8f8e3d008f
commit ddf48f2fef

View File

@ -133,8 +133,11 @@ class CheckedIPAddress(UnsafeIPAddress):
"""
def __init__(self, addr, match_local=False, parse_netmask=True,
allow_loopback=False, allow_multicast=False):
try:
super(CheckedIPAddress, self).__init__(addr)
except netaddr.core.AddrFormatError as e:
raise ValueError(e)
if isinstance(addr, CheckedIPAddress):
self.prefixlen = addr.prefixlen
return