- data = list()
- if sw_if_index:
- is_ipv6 = 1 if ip_version == 'ipv6' else 0
-
- cmd = 'ip_address_dump'
- cmd_reply = 'ip_address_details'
- args = dict(sw_if_index=sw_if_index,
- is_ipv6=is_ipv6)
- err_msg = 'Failed to get L2FIB 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)
-
- for item in papi_resp.reply[0]['api_reply']:
- item[cmd_reply]['ip'] = item[cmd_reply]['prefix'].split('/')[0]
- item[cmd_reply]['prefix_length'] = int(
- item[cmd_reply]['prefix'].split('/')[1])
- item[cmd_reply]['is_ipv6'] = is_ipv6
- item[cmd_reply]['netmask'] = \
- str(IPv6Network(unicode('::/{pl}'.format(
- pl=item[cmd_reply]['prefix_length']))).netmask) \
- if is_ipv6 \
- else str(IPv4Network(unicode('0.0.0.0/{pl}'.format(
- pl=item[cmd_reply]['prefix_length']))).netmask)
- data.append(item[cmd_reply])
-
- return data
+ if not sw_if_index:
+ return list()
+
+ is_ipv6 = 1 if ip_version == 'ipv6' else 0
+
+ cmd = 'ip_address_dump'
+ args = dict(sw_if_index=sw_if_index,
+ is_ipv6=is_ipv6)
+ err_msg = 'Failed to get L2FIB dump on host {host}'.format(
+ host=node['host'])
+
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd, **args).get_details(err_msg)
+
+ # TODO: CSIT currently looks only whether the list is empty.
+ # Add proper value processing if values become important.
+
+ return details