X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVPPUtil.py;h=6268e369be45b601cc389ff27f3aa561b8170669;hp=5b7728412e2fad4119419286e1f100228a4960bc;hb=fe1975eb1ac994df1bd759deda7154bb7dd9d7a7;hpb=245ea1de4f111c159a50bc309f53db3f520453ed 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):