Install dependencies prior test execution.
[csit.git] / resources / libraries / python / CrossConnectSetup.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 """Library to set up cross-connect in topology."""
15
16 from resources.libraries.python.VatExecutor import VatExecutor
17 from resources.libraries.python.topology import Topology
18
19 __all__ = ['CrossConnectSetup']
20
21 class CrossConnectSetup(object):
22     """Crossconnect setup in topology."""
23
24     def __init__(self):
25         pass
26
27     @staticmethod
28     def vpp_setup_bidirectional_cross_connect(node, interface1, interface2):
29         """Create crossconnect between 2 interfaces on vpp node.
30
31         :param node: Node to add bidirectional crossconnect
32         :param interface1: first interface
33         :param interface2: second interface
34         :type node: dict
35         :type interface1: str
36         :type interface2: str
37         """
38         sw_iface1 = Topology().get_interface_sw_index(node, interface1)
39         sw_iface2 = Topology().get_interface_sw_index(node, interface2)
40         VatExecutor.cmd_from_template(node, "l2_xconnect.vat",
41                                       interface1=sw_iface1,
42                                       interface2=sw_iface2)
43         VatExecutor.cmd_from_template(node, "l2_xconnect.vat",
44                                       interface1=sw_iface2,
45                                       interface2=sw_iface1)