aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/FlowUtil.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python/FlowUtil.py')
-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(