- if ip_format not in ('ip4', 'ip6'):
- raise ValueError("Ip not in correct format!")
- sw_if_index = Topology.get_interface_sw_index(node, interface)
- with VatTerminal(node) as vat:
- vat.vat_terminal_exec_cmd_from_template('cop_whitelist.vat',
- sw_if_index=sw_if_index,
- ip=ip_format,
- fib_id=fib_id)
+ if ip_version not in ('ip4', 'ip6'):
+ raise ValueError('IP version is not in correct format')
+
+ cmd = 'cop_whitelist_enable_disable'
+ err_msg = 'Failed to add COP whitelist on interface {ifc} on host' \
+ ' {host}'.format(ifc=interface, host=node['host'])
+ args = dict(
+ sw_if_index=Topology.get_interface_sw_index(node, interface),
+ fib_id=int(fib_id),
+ ip4=True if ip_version == 'ip4' else False,
+ ip6=True if ip_version == 'ip6' else False,
+ default_cop=default_cop
+ )
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)