示例#1
0
 def test_get_shortened_ipv6(self):
     self.assertEqual(
         "abcd:ef01:2345:6789:abcd:ef01:c0a8:fefe",
         utils.get_shortened_ipv6("abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"),
     )
     self.assertEqual("::1", utils.get_shortened_ipv6("0000:0000:0000:0000:0000:0000:0000:0001"))
     self.assertEqual(
         "caca::caca:0:babe:201:102", utils.get_shortened_ipv6("caca:0000:0000:caca:0000:babe:0201:0102")
     )
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6, "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6, "failure")
示例#2
0
 def test_get_shortened_ipv6(self):
     self.assertEqual("abcd:ef01:2345:6789:abcd:ef01:c0a8:fefe",
                      utils.get_shortened_ipv6(
                         "abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"))
     self.assertEqual("::1", utils.get_shortened_ipv6(
                                 "0000:0000:0000:0000:0000:0000:0000:0001"))
     self.assertEqual("caca::caca:0:babe:201:102",
                      utils.get_shortened_ipv6(
                                 "caca:0000:0000:caca:0000:babe:0201:0102"))
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "failure")
示例#3
0
文件: types.py 项目: stackhpc/nova
 def process_bind_param(self, value, dialect):
     """Process/Formats the value before insert it into the db."""
     if dialect.name == 'postgresql':
         return value
     # NOTE(maurosr): The purpose here is to convert ipv6 to the shortened
     # form, not validate it.
     if netutils.is_valid_ipv6(value):
         return utils.get_shortened_ipv6(value)
     return value
示例#4
0
文件: types.py 项目: Juniper/nova
 def process_bind_param(self, value, dialect):
     """Process/Formats the value before insert it into the db."""
     if dialect.name == 'postgresql':
         return value
     # NOTE(maurosr): The purpose here is to convert ipv6 to the shortened
     # form, not validate it.
     elif netutils.is_valid_ipv6(value):
         return utils.get_shortened_ipv6(value)
     return value