HC Test: Update sNAT tests due to API changes
[csit.git] / resources / test_data / honeycomb / nat.py
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:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
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.
13
14 """Test variables for NAT test suite."""
15
16 from resources.libraries.python.topology import Topology
17
18
19 def get_variables(node, interface):
20     """Create and return a dictionary of test variables.
21
22     :param node: Honeycomb node.
23     :param interface: Name, link name or sw_if_index of an interface.
24     :type node: dict
25     :type interface: str or int
26
27     :returns: Dictionary of test variables - settings for Honeycomb's
28     NAT node and expected operational data.
29     :rtype: dict
30     """
31     sw_if_index = Topology.convert_interface_reference(
32         node, interface, "sw_if_index")
33
34     variables = {
35         "nat_empty": {
36             'nat-instances': {
37                 'nat-instance': [{
38                     'id': 0}]
39             }
40         },
41         "entry1": {
42             "mapping-entry": [{
43                 "index": 1,
44                 "type": "static",
45                 "internal-src-address": "192.168.0.1",
46                 "external-src-address": "192.168.1.1"
47             }]
48         },
49         "entry2": {
50             "mapping-entry": [{
51                 "index": 2,
52                 "type": "static",
53                 "internal-src-address": "192.168.0.2",
54                 "external-src-address": "192.168.1.2"
55             }]
56         },
57         "entry1_2_oper": {
58             "mapping-entry": [
59                 {
60                     "index": 1,
61                     "type": "static",
62                     "internal-src-address": "192.168.0.1",
63                     "external-src-address": "192.168.1.1"
64                 },
65                 {
66                     "index": 2,
67                     "type": "static",
68                     "internal-src-address": "192.168.0.2",
69                     "external-src-address": "192.168.1.2"
70                 }
71             ]
72         },
73         "entry1_vat": [{
74             "local_address": "192.168.0.1",
75             "remote_address": "192.168.1.1",
76             "vrf": "0"
77         }],
78         "entry1_2_vat": [
79             {
80                 "local_address": "192.168.0.1",
81                 "remote_address": "192.168.1.1",
82                 "vrf": "0",
83                 "protocol": "17"
84             }, {
85                 "local_address": "192.168.0.2",
86                 "remote_address": "192.168.1.2",
87                 "vrf": "0",
88                 "protocol": "17"
89             }
90         ],
91         "nat_interface_vat_in": [
92             {"sw_if_index": str(sw_if_index),
93              "direction": "in"}
94         ],
95         "nat_interface_vat_out": [
96             {"sw_if_index": str(sw_if_index),
97              "direction": "out"}
98         ]
99     }
100
101     return variables