summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Pepple <ken.pepple@gmail.com>2011-08-21 17:52:14 -0700
committerKen Pepple <ken.pepple@gmail.com>2011-08-21 17:52:14 -0700
commit0fdbea56baaef08575b98e8a553ceac9876e4962 (patch)
tree3621d209ac688bf5b30554e5262711092a9a0290
parentbad921b5efa7b11a91d1df32b3d17fdb95852589 (diff)
downloadnova-0fdbea56baaef08575b98e8a553ceac9876e4962.tar.gz
nova-0fdbea56baaef08575b98e8a553ceac9876e4962.tar.xz
nova-0fdbea56baaef08575b98e8a553ceac9876e4962.zip
added exception catch and test for bad prefix
-rw-r--r--nova/ipv6/rfc2462.py2
-rw-r--r--nova/tests/test_ipv6.py7
2 files changed, 9 insertions, 0 deletions
diff --git a/nova/ipv6/rfc2462.py b/nova/ipv6/rfc2462.py
index 351df742e..acf42d201 100644
--- a/nova/ipv6/rfc2462.py
+++ b/nova/ipv6/rfc2462.py
@@ -32,6 +32,8 @@ def to_global(prefix, mac, project_id):
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 891d52358..6e72b7330 100644
--- a/nova/tests/test_ipv6.py
+++ b/nova/tests/test_ipv6.py
@@ -45,6 +45,13 @@ class IPv6RFC2462TestCase(test.TestCase):
self.assertRaises(TypeError, ipv6.to_global,
'2001:db8::', bad_mac, 'test')
+ def test_to_global_with_bad_prefix(self):
+ bad_prefix = '82'
+ self.assertRaises(TypeError, ipv6.to_global,
+ bad_prefix,
+ '2001:db8::216:3eff:fe33:4455',
+ 'test')
+
class IPv6AccountIdentiferTestCase(test.TestCase):
"""Unit tests for IPv6 account_identifier backend operations."""