1 # Copyright (c) 2017 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.
14 """Test data for Honeycomb routing test."""
16 from resources.libraries.python.topology import Topology
19 def get_variables(node, ip_version, out_interface):
21 out_interface = Topology.convert_interface_reference(
22 node, out_interface, "name")
24 ip_version = ip_version.lower()
27 # base network settings
29 "dut_to_tg_if1_ip": "16.0.0.1",
30 "dut_to_tg_if2_ip": "16.0.1.1",
33 "dst_net": "16.0.2.0",
35 "next_hop": "16.0.1.2",
36 "next_hop1": "16.0.1.3",
37 "next_hop2": "16.0.1.4",
38 "next_hop_mac1": "00:11:22:33:44:55",
39 "next_hop_mac2": "11:22:33:44:55:66"
43 "dut_to_tg_if1_ip": "10::1",
44 "dut_to_tg_if2_ip": "11::1",
52 "next_hop_mac1": "00:11:22:33:44:55",
53 "next_hop_mac2": "11:22:33:44:55:66"
56 if ip_version == "ipv4":
57 variables.update(ipv4_base)
58 elif ip_version == "ipv6":
59 variables.update(ipv6_base)
61 raise ValueError("IP version must be either IPv4 or IPv6.")
63 # route configuration used in tests
66 "description": "single hop ipv4",
68 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
70 "next-hop-address": ipv4_base["next_hop"],
71 "outgoing-interface": out_interface
73 "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
76 "description": "multi hop ipv4",
78 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
84 "next-hop-address": ipv4_base["next_hop1"],
85 "outgoing-interface": out_interface,
90 "next-hop-address": ipv4_base["next_hop2"],
91 "outgoing-interface": out_interface,
99 "description": "blackhole ipv4",
100 "destination-prefix":
101 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
103 "special-next-hop-enum": "blackhole"
107 "description": "single hop ipv6",
108 "destination-prefix":
109 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
111 "next-hop-address": ipv6_base["next_hop"],
112 "outgoing-interface": out_interface
114 "vpp-ipv6-unicast-routing:vpp-ipv6-route": {}
117 "description": "multi hop ipv6",
118 "destination-prefix":
119 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
125 "next-hop-address": ipv6_base["next_hop1"],
126 "outgoing-interface": out_interface,
131 "next-hop-address": ipv6_base["next_hop2"],
132 "outgoing-interface": out_interface,
140 "description": "blackhole ipv6",
141 "destination-prefix":
142 "{0}/{1}".format(ipv6_base["dst_net"], ipv6_base["prefix_len"]),
144 "special-next-hop-enum": "blackhole"
149 # expected route operational data
152 "destination-prefix":
153 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
155 "next-hop-address": ipv4_base["next_hop"],
156 "outgoing-interface": out_interface
160 "destination-prefix":
161 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
167 "next-hop-address": ipv4_base["next_hop2"],
168 "outgoing-interface": out_interface,
169 "vpp-ipv4-unicast-routing:weight": 1
173 "next-hop-address": ipv4_base["next_hop1"],
174 "outgoing-interface": out_interface,
175 "vpp-ipv4-unicast-routing:weight": 1
182 "destination-prefix":
183 "{0}/{1}".format(ipv4_base["dst_net"], ipv4_base["prefix_len"]),
185 "special-next-hop-enum": "blackhole"
189 "destination-prefix":
190 "{0}/{1}".format(ipv6_base["dst_net"],
191 ipv6_base["prefix_len"]),
193 "next-hop-address": ipv6_base["next_hop"],
194 "outgoing-interface": out_interface
198 "destination-prefix":
199 "{0}/{1}".format(ipv6_base["dst_net"],
200 ipv6_base["prefix_len"]),
206 "next-hop-address": ipv6_base["next_hop2"],
207 "outgoing-interface": out_interface,
208 "vpp-ipv6-unicast-routing:weight": 1
212 "next-hop-address": ipv6_base["next_hop1"],
213 "outgoing-interface": out_interface,
214 "vpp-ipv6-unicast-routing:weight": 1
221 "destination-prefix":
222 "{0}/{1}".format(ipv6_base["dst_net"],
223 ipv6_base["prefix_len"]),
225 "special-next-hop-enum": "blackhole"
230 for item in tables_oper.values():
231 if "next-hop-list" in item.keys():
232 item["next-hop-list"]["next-hop"].sort()
234 variables.update(tables_cfg)
235 variables.update(tables_oper)