aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/InterfaceUtil.py50
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwInterfaces.py42
2 files changed, 91 insertions, 1 deletions
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index 35077d8268..a84d595767 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -686,3 +686,53 @@ class InterfaceUtil(object):
sw_if_index=sw_if_index,
ip_version=ip_version,
table_index=table_index)
+
+ @staticmethod
+ def get_sw_if_index(node, interface_name):
+ """Get sw_if_index for the given interface from actual interface dump.
+
+ :param node: VPP node to get interface data from.
+ :param interface_name: Name of the specific interface.
+ :type node: dict
+ :type interface_name: str
+ :return: sw_if_index of the given interface.
+ :rtype: str
+ """
+
+ with VatTerminal(node) as vat:
+ if_data = vat.vat_terminal_exec_cmd_from_template(
+ "interface_dump.vat")
+ for interface in if_data[0]:
+ if interface["interface_name"] == interface_name:
+ return interface["sw_if_index"]
+
+ return None
+
+ @staticmethod
+ def vxlan_gpe_dump(node, interface_name=None):
+ """Get VxLAN GPE data for the given interface.
+
+ :param node: VPP node to get interface data from.
+ :param interface_name: Name of the specific interface. If None,
+ information about all VxLAN GPE interfaces is returned.
+ :type node: dict
+ :type interface_name: str
+ :return: Dictionary containing data for the given VxLAN GPE interface or
+ if interface=None, the list of dictionaries with all VxLAN GPE
+ interfaces.
+ :rtype: dict or list
+ """
+
+ with VatTerminal(node) as vat:
+ vxlan_gpe_data = vat.vat_terminal_exec_cmd_from_template(
+ "vxlan_gpe_dump.vat")
+
+ if interface_name:
+ sw_if_index = InterfaceUtil.get_sw_if_index(node, interface_name)
+ if sw_if_index:
+ for vxlan_gpe in vxlan_gpe_data[0]:
+ if vxlan_gpe["sw_if_index"] == sw_if_index:
+ return vxlan_gpe
+ return {}
+
+ return vxlan_gpe_data[0]
diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
index e8cbc78bea..92b5830847 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py
@@ -35,7 +35,7 @@ class InterfaceKeywords(object):
"""
INTF_PARAMS = ("name", "description", "type", "enabled",
- "link-up-down-trap-enable", "v3po:l2")
+ "link-up-down-trap-enable", "v3po:l2", "v3po:vxlan-gpe")
IPV4_PARAMS = ("enabled", "forwarding", "mtu")
IPV6_PARAMS = ("enabled", "forwarding", "mtu", "dup-addr-detect-transmits")
IPV6_AUTOCONF_PARAMS = ("create-global-addresses",
@@ -63,6 +63,12 @@ class InterfaceKeywords(object):
"match-any-inner-id",
"exact-match",
"default-subif")
+ VXLAN_GPE_PARAMS = ("local",
+ "remote",
+ "vni",
+ "next-protocol",
+ "encap-vrf-id",
+ "decap-vrf-id")
def __init__(self):
pass
@@ -1073,3 +1079,37 @@ class InterfaceKeywords(object):
if name not in names1 and name not in ignore:
raise HoneycombError("Interface {0} not present in list {1}"
.format(name, list1))
+
+ @staticmethod
+ def create_vxlan_gpe_interface(node, interface, **kwargs):
+ """Create a new VxLAN GPE interface.
+
+ :param node: Honeycomb node.
+ :param interface: The name of interface to be created.
+ :param kwargs: Parameters and their values. The accepted parameters are
+ defined in InterfaceKeywords.VXLAN_GPE_PARAMS.
+ :type node: dict
+ :type interface: str
+ :type kwargs: dict
+ :return: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If a parameter in kwargs is not valid.
+ """
+
+ new_vxlan_gpe = {
+ "name": interface,
+ "type": "v3po:vxlan-gpe-tunnel",
+ "v3po:vxlan-gpe": {}
+ }
+ for param, value in kwargs.items():
+ if param in InterfaceKeywords.INTF_PARAMS:
+ new_vxlan_gpe[param] = value
+ elif param in InterfaceKeywords.VXLAN_GPE_PARAMS:
+ new_vxlan_gpe["v3po:vxlan-gpe"][param] = value
+ else:
+ raise HoneycombError("The parameter {0} is invalid.".
+ format(param))
+ path = ("interfaces", "interface")
+ vxlan_gpe_structure = [new_vxlan_gpe, ]
+ return InterfaceKeywords._set_interface_properties(
+ node, interface, path, vxlan_gpe_structure)