- data = list() if interface is None else dict()
- for item in papi_vxlan_dump:
- if interface is None:
- data.append(process_vxlan_dump(item[cmd_reply]))
- elif item[cmd_reply]['sw_if_index'] == sw_if_index:
- data = process_vxlan_dump(item[cmd_reply])
- break
-
- logger.debug('VXLAN data:\n{vxlan_data}'.format(vxlan_data=data))
- return data
-
- @staticmethod
- def vhost_user_dump(node):
- """Get vhost-user data for the given node.
-
- TODO: Move to VhostUser.py
-
- :param node: VPP node to get interface data from.
- :type node: dict
- :returns: List of dictionaries with all vhost-user interfaces.
- :rtype: list
- """
- cmd = 'sw_interface_vhost_user_dump'
- cmd_reply = 'sw_interface_vhost_user_details'
- err_msg = 'Failed to get vhost-user dump on host {host}'.format(
- host=node['host'])
- with PapiExecutor(node) as papi_exec:
- papi_resp = papi_exec.add(cmd).get_dump(err_msg)
-
- papi_vxlan_dump = papi_resp.reply[0]['api_reply']
-
- def process_vhost_dump(vhost_dump):
- """Process vhost dump.
-
- :param vhost_dump: Vhost interface dump.
- :type vhost_dump: dict
- :returns: Processed vhost interface dump.
- :rtype: dict
- """
- vhost_dump['interface_name'] = \
- vhost_dump['interface_name'].rstrip('\x00')
- vhost_dump['sock_filename'] = \
- vhost_dump['sock_filename'].rstrip('\x00')
- return vhost_dump
-
- data = list()
- for item in papi_vxlan_dump:
- data.append(process_vhost_dump(item[cmd_reply]))
-
- logger.debug('Vhost-user data:\n{vhost_data}'.format(vhost_data=data))
- return data
-
- @staticmethod
- def tap_dump(node, name=None):
- """Get all TAP interface data from the given node, or data about
- a specific TAP interface.
-
- TODO: Move to Tap.py
-
- :param node: VPP node to get data from.
- :param name: Optional name of a specific TAP interface.
- :type node: dict
- :type name: str
- :returns: Dictionary of information about a specific TAP interface, or
- a List of dictionaries containing all TAP data for the given node.
- :rtype: dict or list
- """
- cmd = 'sw_interface_tap_v2_dump'
- cmd_reply = 'sw_interface_tap_v2_details'
- err_msg = 'Failed to get TAP dump on host {host}'.format(
- host=node['host'])
- with PapiExecutor(node) as papi_exec:
- papi_resp = papi_exec.add(cmd).get_dump(err_msg)