summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Pepple <ken.pepple@gmail.com>2011-08-20 14:55:41 -0700
committerKen Pepple <ken.pepple@gmail.com>2011-08-20 14:55:41 -0700
commitf4cd3a72fa2a3630ccab2c0224777c3eff05380e (patch)
treedd5c4d1d7a136d6590930d50723adac6847fca30
parent7924fb7899b02d3cb7420c916e035094d5c90194 (diff)
downloadnova-f4cd3a72fa2a3630ccab2c0224777c3eff05380e.tar.gz
nova-f4cd3a72fa2a3630ccab2c0224777c3eff05380e.tar.xz
nova-f4cd3a72fa2a3630ccab2c0224777c3eff05380e.zip
added rainy day test for ipv6 tests. fixed ipv6.to_global to trap correct exception.
-rw-r--r--nova/ipv6/rfc2462.py2
-rw-r--r--nova/tests/test_ipv6.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/nova/ipv6/rfc2462.py b/nova/ipv6/rfc2462.py
index 0074efe98..351df742e 100644
--- a/nova/ipv6/rfc2462.py
+++ b/nova/ipv6/rfc2462.py
@@ -30,7 +30,7 @@ def to_global(prefix, mac, project_id):
maskIP = netaddr.IPNetwork(prefix).ip
return (mac64_addr ^ netaddr.IPAddress('::0200:0:0:0') | 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..12d64f776 100644
--- a/nova/tests/test_ipv6.py
+++ b/nova/tests/test_ipv6.py
@@ -23,6 +23,7 @@ from nova import test
LOG = logging.getLogger('nova.tests.test_ipv6')
import sys
+import netaddr
class IPv6RFC2462TestCase(test.TestCase):
@@ -40,6 +41,11 @@ class IPv6RFC2462TestCase(test.TestCase):
mac = ipv6.to_mac('2001:db8::216:3eff:fe33:4455')
self.assertEquals(mac, '00:16:3e:33:44:55')
+ def test_to_global_with_bad_mac(self):
+ bad_mac = '02:16:3e:33:44:5Z'
+ self.assertRaises(TypeError, ipv6.to_global,
+ '2001:db8::', bad_mac, 'test')
+
class IPv6AccountIdentiferTestCase(test.TestCase):
"""Unit tests for IPv6 account_identifier backend operations."""