1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.l
14 """Variables for MAP-e feature tests."""
16 from resources.libraries.python.Map import Map
17 from random import sample, randint
18 from itertools import product
21 def get_variables(count):
22 """Generate variables with random generated MAP-E configuration sets and
25 domain_set = [IPv4_prefix, IPv6_prefix, IPv6_source, 16, 0, 0]
26 ip_set = [IPv4_dst_address, IPv6_dst_address, dst_port, IPv6_src_address]
28 :param count: Generate "count" map domain configuration parameters.
30 :return: Variable dictionary with domain_sets and ip_sets.
36 ip_product = [x for x in list(product(xrange(2, 224), xrange(0, 256)))
39 for n1, n2 in sample(ip_product, count):
40 v4_pfx = '{}.{}.0.0/16'.format(n1, n2)
41 v6_pfx = '2001:{:x}{:x}::/48'.format(n1, n2)
42 ipv6_br = '2001:ffff::1'
46 port = randint(1025, 65500)
47 ipv4_addr = '{}.{}.20.30'.format(n1, n2)
48 ipv6_addr = Map.compute_ipv6_map_destination_address(
49 v4_pfx, v6_pfx, 16, 0, 0, ipv4_addr, port)
50 domain_sets.append(domain_set)
51 ip_sets.append([ipv4_addr, ipv6_addr, port, ipv6_br])
54 "domain_sets": domain_sets,