aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/VPPUtil.py
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-03-18 13:30:11 +0100
committerJan Gelety <jgelety@cisco.com>2019-05-31 08:00:11 +0000
commitfe1975eb1ac994df1bd759deda7154bb7dd9d7a7 (patch)
tree694e0f5920cac8f71e4ffbff9f9223c1a217cba6 /resources/libraries/python/VPPUtil.py
parent245ea1de4f111c159a50bc309f53db3f520453ed (diff)
CSIT-1468: InterfaceUtil migration from VAT to PAPI
Change-Id: I0062710d58996be767a852dc00545fedd60a5c72 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/VPPUtil.py')
-rw-r--r--resources/libraries/python/VPPUtil.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py
index 5b7728412e..6268e369be 100644
--- a/resources/libraries/python/VPPUtil.py
+++ b/resources/libraries/python/VPPUtil.py
@@ -13,6 +13,8 @@
"""VPP util library."""
+import binascii
+
from robot.api import logger
from resources.libraries.python.Constants import Constants
@@ -191,14 +193,29 @@ class VPPUtil(object):
:param node: Node to run command on.
:type node: dict
"""
- vat = VatExecutor()
- vat.execute_script("show_interface.vat", node, json_out=False)
- try:
- vat.script_should_have_passed()
- except AssertionError:
- raise RuntimeError('Failed to get VPP interfaces on host: {name}'.
- format(name=node['host']))
+ cmd = 'sw_interface_dump'
+ cmd_reply = 'sw_interface_details'
+ args = dict(name_filter_valid=0, name_filter='')
+ err_msg = 'Failed to get interface dump on host {host}'.format(
+ host=node['host'])
+ with PapiExecutor(node) as papi_exec:
+ papi_resp = papi_exec.add(cmd, **args).execute_should_pass(err_msg)
+
+ papi_if_dump = papi_resp.reply[0]['api_reply']
+
+ if_data = list()
+ for item in papi_if_dump:
+ data = item[cmd_reply]
+ data['interface_name'] = data['interface_name'].rstrip('\x00')
+ data['tag'] = data['tag'].rstrip('\x00')
+ data['l2_address'] = str(':'.join(binascii.hexlify(
+ data['l2_address'])[i:i + 2] for i in range(0, 12, 2)).
+ decode('ascii'))
+ if_data.append(data)
+ # TODO: return only base data
+ logger.trace('Interface data of host {host}:\n{if_data}'.format(
+ host=node['host'], if_data=if_data))
@staticmethod
def vpp_show_crypto_device_mapping(node):