netaddr<=0.7.10 raises ValueError instead of AddrFormatError
This patch is based on Aarons work for the Bug#1308675. It ensures that ValueError is also caught in addition to AddrFormatError as in netaddr>=0.7.11 AddrFormatError is raised and in netaddr<=0.7.10 ValueError is raised. Change-Id: I71cfe82e57290552fb22637ad929747a6fa22460 Closes-bug: #1308675
This commit is contained in:
parent
87c44799e1
commit
3c6aea98d9
@ -30,7 +30,7 @@ def get_ipv6_addr_by_EUI64(prefix, mac):
|
||||
eui64 = int(netaddr.EUI(mac).eui64())
|
||||
prefix = netaddr.IPNetwork(prefix)
|
||||
return netaddr.IPAddress(prefix.first + eui64 ^ (1 << 57))
|
||||
except netaddr.AddrFormatError:
|
||||
except (ValueError, netaddr.AddrFormatError):
|
||||
raise TypeError(_('Bad prefix or mac format for generating IPv6 '
|
||||
'address by EUI-64: %(prefix)s, %(mac)s:')
|
||||
% {'prefix': prefix, 'mac': mac})
|
||||
|
@ -321,7 +321,7 @@ class Client(object):
|
||||
ip = netaddr.IPNetwork(subnet['cidr'])
|
||||
netmask = str(ip.netmask)
|
||||
network_address = str(ip.network)
|
||||
except netaddr.AddrFormatError:
|
||||
except (ValueError, netaddr.AddrFormatError):
|
||||
msg = _("Invalid input for CIDR")
|
||||
raise n_exc.InvalidInput(error_message=msg)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user