diff options
author | selias <samelias@cisco.com> | 2017-05-11 18:02:03 +0200 |
---|---|---|
committer | selias <samelias@cisco.com> | 2017-05-17 11:26:08 +0200 |
commit | fa14d9f454a7248a71135375bfb0758cdb532ca7 (patch) | |
tree | a5c297ffc7988e2ce64398eb483c711a0697246c /resources/libraries/python/honeycomb/HcAPIKwInterfaces.py | |
parent | df228e1794d4a5a1c3028e1e214731b5f0450b99 (diff) |
CSIT-576 HC Test: Improve SPAN test coverage
- add test for multiple destination interfaces using one source interface
- duplicate all existing cases using a sub-interface as the destination
Change-Id: Ifabf78bca258247a19624b2b2a0474d21d1229d3
Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb/HcAPIKwInterfaces.py')
-rw-r--r-- | resources/libraries/python/honeycomb/HcAPIKwInterfaces.py | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py index dc248589f9..e78696cd15 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py +++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py @@ -1162,6 +1162,9 @@ class InterfaceKeywords(object): :rtype: bytearray """ + super_interface = Topology.convert_interface_reference( + node, super_interface, "name") + intf_state = {"up": "true", "down": "false"} @@ -1706,7 +1709,7 @@ class InterfaceKeywords(object): :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 dst_interface: str or int :type src_interfaces: list of dict :returns: Content of response. :rtype: bytearray @@ -1742,6 +1745,58 @@ class InterfaceKeywords(object): "Configuring SPAN failed. Status code:{0}".format(status_code)) @staticmethod + def configure_sub_interface_span(node, super_interface, dst_interface_index, + src_interfaces=None): + """Configure SPAN port mirroring on the specified sub-interface. If no + source interface is provided, SPAN will be disabled. + + Note: Does not support source sub-interfaces, only destination. + + :param node: Honeycomb node. + :param super_interface: Name, link name or sw_if_index + of the destination interface's super-interface. + :param dst_interface_index: Index of sub-interface to mirror packets to. + :param src_interfaces: List of interfaces to mirror packets from. + :type node: dict + :type super_interface: str or int + :type dst_interface_index: int + :type src_interfaces: list of dict + :returns: Content of response. + :rtype: bytearray + :raises HoneycombError: If SPAN could not be configured. + """ + + super_interface = Topology.convert_interface_reference( + node, super_interface, "name") + super_interface = super_interface.replace("/", "%2F") + + path = "/interface/{0}/vpp-vlan:sub-interfaces/sub-interface/{1}/span"\ + .format(super_interface, dst_interface_index) + + if not src_interfaces: + status_code, _ = HcUtil.delete_honeycomb_data( + node, "config_vpp_interfaces", path) + else: + for src_interface in src_interfaces: + src_interface["iface-ref"] = Topology. \ + convert_interface_reference( + node, src_interface["iface-ref"], "name") + 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. |