fix(flow): Move import back to functions 14/34114/2
authorpmikus <pmikus@cisco.com>
Fri, 15 Oct 2021 13:19:21 +0000 (13:19 +0000)
committerPeter Mikus <pmikus@cisco.com>
Mon, 18 Oct 2021 05:53:19 +0000 (05:53 +0000)
+ This makes a problem. It would be better to have ENUMS
  in code as everywhere else

Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: I90f8e7c0177cb6a76eef5d4444f0ec22f57236c4

resources/libraries/python/FlowUtil.py

index 1dcb7e0..3eb3b99 100644 (file)
@@ -19,8 +19,6 @@ from resources.libraries.python.topology import Topology
 from resources.libraries.python.ssh import exec_cmd_no_error
 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
 
-from vpp_papi import VppEnum
-
 class FlowUtil:
     """Utilities for flow configuration."""
 
@@ -50,6 +48,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip4_n_tuple"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP4_N_TUPLE
 
@@ -99,6 +99,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip6_n_tuple"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP6_N_TUPLE
 
@@ -145,6 +147,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip4"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP4
 
@@ -187,6 +191,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip6"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP6
 
@@ -231,6 +237,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip4_gtpu"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP4_GTPU
         flow_proto = VppEnum.vl_api_ip_proto_t.IP_API_PROTO_UDP
@@ -265,6 +273,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         if proto == u"ESP":
             flow = u"ip4_ipsec_esp"
             flow_proto = VppEnum.vl_api_ip_proto_t.IP_API_PROTO_ESP
@@ -302,6 +312,8 @@ class FlowUtil:
         :returns: flow_index.
         :rtype: int
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip4_l2tpv3oip"
         flow_proto = 115    # IP_API_PROTO_L2TP
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP4_L2TPV3OIP
@@ -335,6 +347,8 @@ class FlowUtil:
         :type value: int
         :returns: flow_index.
         """
+        from vpp_papi import VppEnum
+
         flow = u"ip4_vxlan"
         flow_type = VppEnum.vl_api_flow_type_t.FLOW_TYPE_IP4_VXLAN
         flow_proto = VppEnum.vl_api_ip_proto_t.IP_API_PROTO_UDP
@@ -373,6 +387,8 @@ class FlowUtil:
         :rtype: int
         :raises ValueError: If action type is not supported.
         """
+        from vpp_papi import VppEnum
+
         cmd = u"flow_add"
 
         if action == u"redirect-to-queue":
@@ -421,6 +437,8 @@ class FlowUtil:
         :type flow_index: int
         :returns: Nothing.
         """
+        from vpp_papi import VppEnum
+
         cmd = u"flow_enable"
         sw_if_index = Topology.get_interface_sw_index(node, interface)
         args = dict(
@@ -445,6 +463,8 @@ class FlowUtil:
         :type flow_index: int
         :returns: Nothing.
         """
+        from vpp_papi import VppEnum
+
         cmd = u"flow_disable"
         sw_if_index = Topology.get_interface_sw_index(node, interface)
         args = dict(
@@ -467,6 +487,8 @@ class FlowUtil:
         :type flow_index: int
         :returns: Nothing.
         """
+        from vpp_papi import VppEnum
+
         cmd = u"flow_del"
         args = dict(
             flow_index=int(flow_index)
@@ -486,6 +508,8 @@ class FlowUtil:
         :returns: flow entry.
         :rtype: str
         """
+        from vpp_papi import VppEnum
+
         cmd = u"vppctl show flow entry"
 
         err_msg = u"Failed to show flow on host {node[u'host']}"
@@ -521,6 +545,8 @@ class FlowUtil:
         :raises RuntimeError: If the verification of flow action fails.
         :raises ValueError: If action type is not supported.
         """
+        from vpp_papi import VppEnum
+
         err_msg = f"Failed to show trace on host {node[u'host']}"
         cmd = u"vppctl show trace"
         stdout, _ = exec_cmd_no_error(