diff options
| author | Ken Pepple <ken.pepple@gmail.com> | 2011-08-20 15:30:59 -0700 |
|---|---|---|
| committer | Ken Pepple <ken.pepple@gmail.com> | 2011-08-20 15:30:59 -0700 |
| commit | 43e2ca531f0fdea5173b7f237627fc3543caf13b (patch) | |
| tree | bc6f39dc87572fc9767e6ae35c5adf0cd56875f6 | |
| parent | 7924fb7899b02d3cb7420c916e035094d5c90194 (diff) | |
lp:828610
| -rw-r--r-- | nova/ipv6/account_identifier.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_ipv6.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/nova/ipv6/account_identifier.py b/nova/ipv6/account_identifier.py index 258678f0a..02b653925 100644 --- a/nova/ipv6/account_identifier.py +++ b/nova/ipv6/account_identifier.py @@ -34,7 +34,7 @@ def to_global(prefix, mac, project_id): mac_addr = netaddr.IPAddress(int_addr) maskIP = netaddr.IPNetwork(prefix).ip return (project_hash ^ static_num ^ mac_addr | maskIP).format() - except TypeError: + except netaddr.AddrFormatError: raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac) diff --git a/nova/tests/test_ipv6.py b/nova/tests/test_ipv6.py index d123df6f1..6afc7e3f9 100644 --- a/nova/tests/test_ipv6.py +++ b/nova/tests/test_ipv6.py @@ -55,3 +55,8 @@ class IPv6AccountIdentiferTestCase(test.TestCase): def test_to_mac(self): mac = ipv6.to_mac('2001:db8::a94a:8fe5:ff33:4455') self.assertEquals(mac, '02:16:3e:33:44:55') + + def test_to_global_with_bad_mac(self): + bad_mac = '02:16:3e:33:44:5X' + self.assertRaises(TypeError, ipv6.to_global, + '2001:db8::', bad_mac, 'test') |
