From 326cfda8cc50f5db083e9df381d3109e0302605d Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Sun, 21 Aug 2011 17:55:54 -0700 Subject: added exception catch for bad prefix and matching test --- nova/ipv6/account_identifier.py | 2 ++ nova/tests/test_ipv6.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/nova/ipv6/account_identifier.py b/nova/ipv6/account_identifier.py index 02b653925..4ca7b5983 100644 --- a/nova/ipv6/account_identifier.py +++ b/nova/ipv6/account_identifier.py @@ -36,6 +36,8 @@ def to_global(prefix, mac, project_id): return (project_hash ^ static_num ^ mac_addr | maskIP).format() except netaddr.AddrFormatError: raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac) + except TypeError: + raise TypeError(_('Bad prefix for to_global_ipv6: %s') % prefix) def to_mac(ipv6_address): diff --git a/nova/tests/test_ipv6.py b/nova/tests/test_ipv6.py index 6afc7e3f9..f9c2517a7 100644 --- a/nova/tests/test_ipv6.py +++ b/nova/tests/test_ipv6.py @@ -60,3 +60,10 @@ class IPv6AccountIdentiferTestCase(test.TestCase): bad_mac = '02:16:3e:33:44:5X' self.assertRaises(TypeError, ipv6.to_global, '2001:db8::', bad_mac, 'test') + + def test_to_global_with_bad_prefix(self): + bad_prefix = '78' + self.assertRaises(TypeError, ipv6.to_global, + bad_prefix, + '2001:db8::a94a:8fe5:ff33:4455', + 'test') -- cgit