aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-10-15 13:19:21 +0000
committerPeter Mikus <pmikus@cisco.com>2021-10-18 05:53:19 +0000
commit240170fea22817e969141f8868b744fdafe54de6 (patch)
tree2ae5458f6c4755d341f99f701a0f1f50cb50be83 /resources
parenta1a4322fe9e64a1b1f9e1ac219f8a9941a647b7d (diff)
fix(flow): Move import back to functions
+ 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
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/FlowUtil.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/resources/libraries/python/FlowUtil.py b/resources/libraries/python/FlowUtil.py
index 1dcb7e0fae..3eb3b99519 100644
--- a/resources/libraries/python/FlowUtil.py
+++ b/resources/libraries/python/FlowUtil.py
@@ -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(