aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python/honeycomb/HcAPIKwInterfaces.py')
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwInterfaces.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
index 19ce8f26c8..d57f93913f 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
@@ -1512,6 +1512,69 @@ class InterfaceKeywords(object):
return resp
@staticmethod
+ def enable_policer_on_interface(node, interface, table_name):
+ """Enable Policer on the given interface.
+
+ :param node: Honeycomb node.
+ :param interface: The interface where policer will be enabled.
+ :param table_name: Name of the classify table.
+ :type node: dict
+ :type interface: str
+ :type table_name: str
+ :returns: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If the configuration of interface is not
+ successful.
+ """
+ interface = Topology.convert_interface_reference(
+ node, interface, "name")
+ interface = interface.replace("/", "%2F")
+
+ data = {
+ "interface-policer:policer": {
+ "ip4-table": table_name
+ }
+ }
+
+ path = "/interface/" + interface + "/interface-policer:policer"
+ status_code, resp = HcUtil.\
+ put_honeycomb_data(node, "config_vpp_interfaces", data, path,
+ data_representation=DataRepresentation.JSON)
+ if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED):
+ raise HoneycombError(
+ "The configuration of interface '{0}' was not successful. "
+ "Status code: {1}.".format(interface, status_code))
+ return resp
+
+ @staticmethod
+ def disable_policer_on_interface(node, interface):
+ """Disable Policer on the given interface.
+
+ :param node: Honeycomb node.
+ :param interface: The interface where policer will be disabled.
+ :param table_name: Name of the classify table.
+ :type node: dict
+ :type interface: str
+ :type table_name: str
+ :returns: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If the configuration of interface is not
+ successful.
+ """
+ interface = Topology.convert_interface_reference(
+ node, interface, "name")
+ interface = interface.replace("/", "%2F")
+
+ path = "/interface/" + interface + "/interface-policer:policer"
+ status_code, resp = HcUtil.\
+ delete_honeycomb_data(node, "config_vpp_interfaces", path)
+ if status_code != HTTPCodes.OK:
+ raise HoneycombError(
+ "The configuration of interface '{0}' was not successful. "
+ "Status code: {1}.".format(interface, status_code))
+ return resp
+
+ @staticmethod
def disable_acl_on_interface(node, interface):
"""Disable ACL on the given interface.