From ddf48f2fef344784b9e1918d2f2ee6feef9d4c04 Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Tue, 20 Sep 2016 12:10:09 +0200 Subject: [PATCH] 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 --- ipapython/ipautil.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 6ef39ab12..64901b524 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -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) - super(CheckedIPAddress, self).__init__(addr) if isinstance(addr, CheckedIPAddress): self.prefixlen = addr.prefixlen return