- def process_tap_dump(tap_dump):
- """Process tap dump.
-
- :param tap_dump: Tap interface dump.
- :type tap_dump: dict
- :returns: Processed tap interface dump.
- :rtype: dict
- """
- tap_dump['dev_name'] = tap_dump['dev_name'].rstrip('\x00')
- tap_dump['host_if_name'] = tap_dump['host_if_name'].rstrip('\x00')
- tap_dump['host_namespace'] = \
- tap_dump['host_namespace'].rstrip('\x00')
- tap_dump['host_mac_addr'] = \
- L2Util.bin_to_mac(tap_dump['host_mac_addr'])
- tap_dump['host_ip4_addr'] = \
- inet_ntop(AF_INET, tap_dump['host_ip4_addr'])
- tap_dump['host_ip6_addr'] = \
- inet_ntop(AF_INET6, tap_dump['host_ip6_addr'])
- return tap_dump
-
- data = list() if name is None else dict()
- for tap_dump in details:
- if name is None:
- data.append(process_tap_dump(tap_dump))
- elif tap_dump.get('dev_name').rstrip('\x00') == name:
- data = process_tap_dump(tap_dump)
- break