aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/InterfaceUtil.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2016-06-06 11:01:03 +0200
committerTibor Frank <tifrank@cisco.com>2016-06-08 08:11:29 +0000
commite8c787b699661f00e8358cc711bb20b8993dc87a (patch)
tree244d86b3844fdf8a559be5fc4969065b7a3bc22c /resources/libraries/python/InterfaceUtil.py
parent3744273d8f1540fe45312b5c3a4e2e6f8b21a81f (diff)
Add Tests for Honeycomb VxLAN GPE support
JIRA: CSIT-131 - add tests for Honeycomb VxLAN GPE support - add keywords needed for tests Change-Id: I460ecd30835bb95140958b20946b1d41ac6d9abc Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/InterfaceUtil.py')
-rw-r--r--resources/libraries/python/InterfaceUtil.py50
1 files changed, 50 insertions, 0 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]