diff options
author | pmikus <pmikus@cisco.com> | 2021-10-15 13:19:21 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2021-10-18 05:53:33 +0000 |
commit | 7c6da6cb2e0492d900b5094de5aec5c70138d743 (patch) | |
tree | 314c5d2ecc3bdd6a9e55e0e33f2b0023aece0b41 /resources | |
parent | 8a63e3fdc89ab761c61f29222510e1565ecfb5b3 (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
(cherry picked from commit 240170fea22817e969141f8868b744fdafe54de6)
Diffstat (limited to 'resources')
-rw-r--r-- | resources/libraries/python/FlowUtil.py | 30 |
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( |