- if sw_if_index:
- 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 PapiExecutor(node) as papi_exec:
- details = papi_exec.add(cmd, **args).get_details(err_msg)
-
- for item in details:
- item['ip'] = item['prefix'].split('/')[0]
- item['prefix_length'] = int(item['prefix'].split('/')[1])
- item['is_ipv6'] = is_ipv6
- item['netmask'] = \
- str(IPv6Network(unicode('::/{pl}'.format(
- pl=item['prefix_length']))).netmask) \
- if is_ipv6 \
- else str(IPv4Network(unicode('0.0.0.0/{pl}'.format(
- pl=item['prefix_length']))).netmask)
+ 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.