+ cmd = 'sw_interface_bond_dump'
+ cmd_reply = 'sw_interface_bond_details'
+ err_msg = 'Failed to get bond interface dump on host {host}'.format(
+ host=node['host'])
+
+ data = ('Bond data on node {host}:\n'.format(host=node['host']))
+ with PapiExecutor(node) as papi_exec:
+ papi_resp = papi_exec.add(cmd).get_dump(err_msg)
+
+ papi_dump = papi_resp.reply[0]['api_reply']
+ for item in papi_dump:
+ data += ('{b}\n'.format(b=item[cmd_reply]['interface_name'].
+ rstrip('\x00')))
+ data += (' mode: {m}\n'.
+ format(m=LinkBondMode(item[cmd_reply]['mode']).name.
+ lower()))
+ data += (' load balance: {lb}\n'.
+ format(lb=LinkBondLoadBalance(item[cmd_reply]['lb']).name.
+ lower()))
+ data += (' number of active slaves: {n}\n'.
+ format(n=item[cmd_reply]['active_slaves']))
+ if details:
+ slave_data = InterfaceUtil.vpp_bond_slave_dump(
+ node, Topology.get_interface_by_sw_index(
+ node, item[cmd_reply]['sw_if_index']))
+ for slave in slave_data:
+ if not slave['is_passive']:
+ data += (' {s}\n'.format(s=slave['interface_name']))
+ data += (' number of slaves: {n}\n'.
+ format(n=item[cmd_reply]['slaves']))
+ if details:
+ for slave in slave_data:
+ data += (' {s}\n'.format(s=slave['interface_name']))
+ data += (' interface id: {i}\n'.
+ format(i=item[cmd_reply]['id']))
+ data += (' sw_if_index: {i}\n'.
+ format(i=item[cmd_reply]['sw_if_index']))
+ logger.info(data)
+
+ @staticmethod
+ def vpp_bond_slave_dump(node, interface):
+ """Get bond interface slave(s) data on VPP node.
+
+ :param node: DUT node from topology.
+ :param interface: Physical interface key from topology file.
+ :type node: dict
+ :type interface: str
+ :returns: Bond slave interface data.
+ :rtype: dict
+ """
+ cmd = 'sw_interface_slave_dump'
+ cmd_reply = 'sw_interface_slave_details'
+ args = dict(sw_if_index=Topology.get_interface_sw_index(
+ node, interface))
+ err_msg = 'Failed to get slave dump on host {host}'.format(
+ host=node['host'])
+
+ with PapiExecutor(node) as papi_exec:
+ papi_resp = papi_exec.add(cmd, **args).get_dump(err_msg)
+
+ papi_dump = papi_resp.reply[0]['api_reply']
+
+ def process_slave_dump(slave_dump):
+ """Process slave dump.
+
+ :param slave_dump: Slave interface dump.
+ :type slave_dump: dict
+ :returns: Processed slave interface dump.
+ :rtype: dict
+ """
+ slave_dump['interface_name'] = slave_dump['interface_name'].\
+ rstrip('\x00')
+ return slave_dump
+
+ data = list()
+ for item in papi_dump:
+ data.append(process_slave_dump(item[cmd_reply]))
+
+ logger.debug('Slave data:\n{slave_data}'.format(slave_data=data))
+ return data