FIX: Pylint reduce
[csit.git] / resources / libraries / python / TestConfig.py
index 9f83fbb..c1b7b1b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -19,6 +19,7 @@ from robot.api import logger
 from resources.libraries.python.Constants import Constants
 from resources.libraries.python.InterfaceUtil import InterfaceUtil, \
     InterfaceStatusFlags
+from resources.libraries.python.IPAddress import IPAddress
 from resources.libraries.python.IPUtil import IPUtil
 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
 from resources.libraries.python.topology import Topology
@@ -157,8 +158,7 @@ class TestConfig:
         )
         cmd2 = u"vxlan_add_del_tunnel"
         args2 = dict(
-            is_add=1,
-            is_ipv6=0,
+            is_add=True,
             instance=Constants.BITWISE_NON_ZERO,
             src_address=None,
             dst_address=None,
@@ -189,8 +189,12 @@ class TestConfig:
                 args1[u"prefix"] = IPUtil.create_prefix_object(
                     src_ip, 128 if src_ip_start.version == 6 else 32
                 )
-                args2[u"src_address"] = getattr(src_ip, u"packed")
-                args2[u"dst_address"] = getattr(dst_ip, u"packed")
+                args2[u"src_address"] = IPAddress.create_ip_address_object(
+                    src_ip
+                )
+                args2[u"dst_address"] = IPAddress.create_ip_address_object(
+                    dst_ip
+                )
                 args2[u"vni"] = int(vni_start) + i
                 args3[u"vlan_id"] = i + 1
                 history = bool(not 1 < i < vxlan_count - 1)
@@ -215,6 +219,7 @@ class TestConfig:
         :type vxlan_count: int
         :type node_vlan_if: str
         """
+        if_data = InterfaceUtil.vpp_get_interface_data(node)
         if vxlan_count > 10:
             commands = list()
             for i in range(0, vxlan_count):
@@ -226,7 +231,7 @@ class TestConfig:
                 vlan_subif_name = \
                     f"{Topology.get_interface_name(node, node_vlan_if)}.{i + 1}"
                 vlan_idx = None
-                for data in InterfaceUtil.vpp_get_interface_data(node):
+                for data in if_data:
                     if_name = data[u"interface_name"]
                     if not founds[u"vxlan"] and if_name == vxlan_subif_name:
                         vxlan_subif_idx = data[u"sw_if_index"]
@@ -279,7 +284,7 @@ class TestConfig:
                 vlan_subif_name = \
                     f"{Topology.get_interface_name(node, node_vlan_if)}.{i+1}"
                 vlan_idx = None
-                for data in InterfaceUtil.vpp_get_interface_data(node):
+                for data in if_data:
                     if not founds[u"vxlan"] \
                             and data[u"interface_name"] == vxlan_subif_name:
                         vxlan_subif_idx = data[u"sw_if_index"]
@@ -340,19 +345,21 @@ class TestConfig:
         dst_ip_start = ip_address(dst_ip_start)
 
         if vxlan_count > 1:
-            sw_idx_vxlan = Topology.get_interface_sw_index(node, node_vxlan_if)
+            idx_vxlan_if = Topology.get_interface_sw_index(node, node_vxlan_if)
             commands = list()
             for i in range(0, vxlan_count):
                 dst_ip = dst_ip_start + i * ip_step
                 commands.append(
-                    f"ip_neighbor_add_del sw_if_index {sw_idx_vxlan} "
-                    f"dst {dst_ip} "
-                    f"mac {Topology.get_interface_mac(op_node, op_node_if)}\n"
+                    f"exec ip neighbor "
+                    f"{Topology.get_interface_name(node, node_vxlan_if)} "
+                    f"{dst_ip} "
+                    f"{Topology.get_interface_mac(op_node, op_node_if)} static "
+                    f"\n"
                 )
                 commands.append(
                     f"ip_route_add_del "
                     f"{dst_ip}/{128 if dst_ip.version == 6 else 32} count 1 "
-                    f"via {dst_ip} sw_if_index {sw_idx_vxlan}\n"
+                    f"via {dst_ip} sw_if_index {idx_vxlan_if}\n"
                 )
                 sw_idx_vxlan = Topology.get_interface_sw_index(
                     node, f"vxlan_tunnel{i + 1}"
@@ -420,9 +427,9 @@ class TestConfig:
                 args1[u"neighbor"][u"ip_address"] = \
                     str(dst_ip_start + i * ip_step)
                 args2[u"route"][u"prefix"][u"address"][u"un"] = \
-                    IPUtil.union_addr(dst_ip_start + i * ip_step)
+                    IPAddress.union_addr(dst_ip_start + i * ip_step)
                 args2[u"route"][u"paths"][0][u"nh"][u"address"] = \
-                    IPUtil.union_addr(dst_ip_start + i * ip_step)
+                    IPAddress.union_addr(dst_ip_start + i * ip_step)
                 args3[u"rx_sw_if_index"] = Topology.get_interface_sw_index(
                     node, f"vxlan_tunnel{i+1}"
                 )