From 7305ace9f37719f47d55743c0dece7089c063b12 Mon Sep 17 00:00:00 2001 From: sridhargaddam Date: Fri, 18 Apr 2014 21:01:48 +0530 Subject: [PATCH] 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 --- neutron/common/ipv6_utils.py | 2 +- neutron/plugins/cisco/n1kv/n1kv_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/neutron/common/ipv6_utils.py b/neutron/common/ipv6_utils.py index 6e57bfcfe..fbe61e49b 100644 --- a/neutron/common/ipv6_utils.py +++ b/neutron/common/ipv6_utils.py @@ -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}) diff --git a/neutron/plugins/cisco/n1kv/n1kv_client.py b/neutron/plugins/cisco/n1kv/n1kv_client.py index 662199df3..6164d9638 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_client.py +++ b/neutron/plugins/cisco/n1kv/n1kv_client.py @@ -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: