- 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 (u"ip4", u"ip6"):
+ raise ValueError(u"IP version is not in correct format")
+
+ cmd = u"cop_whitelist_enable_disable"
+ err_msg = f"Failed to add COP whitelist on interface {interface} " \
+ f"on host {node[u'host']}"
+ args = dict(
+ sw_if_index=Topology.get_interface_sw_index(node, interface),
+ fib_id=int(fib_id),
+ ip4=bool(ip_version == u"ip4"),
+ ip6=bool(ip_version == u"ip6"),
+ default_cop=default_cop
+ )
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)