Example #1
0
def get_list_of_random_networks(num=10):
    for i in range(5):
        res = [tools.get_random_ip_network() for i in range(num)]
        # make sure there are no duplicates
        if len(set(res)) == num:
            return res
    raise Exception('Failed to generate unique networks')
Example #2
0
 def setUp(self):
     super(IPNetworkFieldTest, self).setUp()
     self.field = common_types.IPNetworkField()
     addrs = [
         tools.get_random_ip_network(version=ip_version)
         for ip_version in constants.IP_ALLOWED_VERSIONS
     ]
     self.coerce_good_values = [(addr, addr) for addr in addrs]
     self.coerce_bad_values = [
         'ypp', 'g3:vvv',
         # the field type is strict and does not allow to pass strings, even
         # if they represent a valid IP network
         '10.0.0.0/24',
     ]
     self.to_primitive_values = self.coerce_good_values
     self.from_primitive_values = self.coerce_good_values
Example #3
0
def get_list_of_random_networks(num=10):
    return [tools.get_random_ip_network() for i in range(num)]