aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb
diff options
context:
space:
mode:
authorselias <samelias@cisco.com>2016-11-25 10:50:29 +0100
committerPeter Mikus <pmikus@cisco.com>2016-12-01 07:26:51 +0000
commit4f70ebf481d496f91d2b1ec27361c9898b19c451 (patch)
tree4d24f1218c2123c9cabeeb35622c7434a3f7ee26 /resources/libraries/python/honeycomb
parentd7e03f0eeeb599bd40b123123753ac41800bd3f5 (diff)
CSIT-481: HC Test: Port mirroring (SPAN)
- add port mirroring test suite - add relevant keywords Change-Id: I4ff398dd2ab4323e2a53af2812bf07cbb7043252 Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb')
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwInterfaces.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
index 3271413d1c..01a2eba0ad 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
@@ -1576,3 +1576,55 @@ class InterfaceKeywords(object):
return True
raise HoneycombError("Interface index {0} not present in list"
" of disabled interfaces.".format(interface))
+
+ @staticmethod
+ def configure_interface_span(node, dst_interface, *src_interfaces):
+ """Configure SPAN port mirroring on the specified interfaces. If no
+ source interface is provided, SPAN will be disabled.
+
+ :param node: Honeycomb node.
+ :param dst_interface: Interface to mirror packets to.
+ :param src_interfaces: List of interfaces to mirror packets from.
+ :type node: dict
+ :type dst_interface: str
+ :type src_interfaces: list of str
+ :returns: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If SPAN could not be configured.
+ """
+
+ interface = dst_interface.replace("/", "%2F")
+ path = "/interface/" + interface + "/span"
+
+ if not src_interfaces:
+ status_code, _ = HcUtil.delete_honeycomb_data(
+ node, "config_vpp_interfaces", path)
+
+ data = {
+ "span": {
+ "mirrored-interfaces": {
+ "mirrored-interface": src_interfaces
+ }
+ }
+ }
+
+ status_code, _ = HcUtil.put_honeycomb_data(
+ node, "config_vpp_interfaces", data, path)
+
+ if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED):
+ raise HoneycombError(
+ "Configuring SPAN failed. Status code:{0}".format(status_code))
+
+ @staticmethod
+ def add_interface_local0_to_topology(node):
+ """Use Topology methods to add interface "local0" to working topology,
+ if not already present.
+
+ :param node: DUT node.
+ :type node: dict
+ """
+
+ if Topology.get_interface_by_sw_index(node, 0) is None:
+ local0_key = Topology.add_new_port(node, "localzero")
+ Topology.update_interface_sw_if_index(node, local0_key, 0)
+ Topology.update_interface_name(node, local0_key, "local0")