- 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)
+ cmd = u"sw_interface_dump"
+ args = dict(
+ name_filter_valid=False,
+ name_filter=u""
+ )
+ err_msg = f"Failed to get interface dump on host {node[u'host']}"
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd, **args).get_details(err_msg)
+
+ for if_dump in details:
+ if_dump[u"l2_address"] = str(if_dump[u"l2_address"])
+ if_dump[u"b_dmac"] = str(if_dump[u"b_dmac"])
+ if_dump[u"b_smac"] = str(if_dump[u"b_smac"])
+ if_dump[u"flags"] = if_dump[u"flags"].value
+ if_dump[u"type"] = if_dump[u"type"].value
+ if_dump[u"link_duplex"] = if_dump[u"link_duplex"].value
+ if_dump[u"sub_if_flags"] = if_dump[u"sub_if_flags"].value \
+ if hasattr(if_dump[u"sub_if_flags"], u"value") \
+ else int(if_dump[u"sub_if_flags"])