From ddf48f2fef344784b9e1918d2f2ee6feef9d4c04 Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Sep 21 2016 08:26:24 +0000 Subject: 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 --- diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 6ef39ab..64901b5 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