+ @staticmethod
+ def ipsec_proto_esp():
+ """Return IPSec protocol ESP.
+
+ :returns: IPsecProto enum ESP object.
+ :rtype: IPsecProto
+ """
+ return int(IPsecProto.ESP)
+
+ @staticmethod
+ def ipsec_proto_ah():
+ """Return IPSec protocol AH.
+
+ :returns: IPsecProto enum AH object.
+ :rtype: IPsecProto
+ """
+ return int(IPsecProto.SEC_AH)
+
+ @staticmethod
+ def vpp_ipsec_select_backend(node, protocol, index=1):
+ """Select IPsec backend.
+
+ :param node: VPP node to select IPsec backend on.
+ :param protocol: IPsec protocol.
+ :param index: Backend index.
+ :type node: dict
+ :type protocol: IPsecProto
+ :type index: int
+ :raises RuntimeError: If failed to select IPsec backend or if no API
+ reply received.
+ """
+
+ cmd = 'ipsec_select_backend'
+ cmd_reply = 'ipsec_select_backend_reply'
+ err_msg = 'Failed to select IPsec backend on host {host}'.format(
+ host=node['host'])
+ args = dict(protocol=protocol, index=index)
+ with PapiExecutor(node) as papi_exec:
+ papi_resp = papi_exec.add(cmd, **args).execute_should_pass(err_msg)
+ data = papi_resp.reply[0]['api_reply'][cmd_reply]
+ if data['retval'] != 0:
+ raise RuntimeError('Failed to select IPsec backend on host {host}'.
+ format(host=node['host']))
+
+ @staticmethod
+ def vpp_ipsec_backend_dump(node):
+ """Dump IPsec backends.
+
+ :param node: VPP node to dump IPsec backend on.
+ :type node: dict
+ """
+
+ err_msg = 'Failed to dump IPsec backends on host {host}'.format(
+ host=node['host'])
+ with PapiExecutor(node) as papi_exec:
+ papi_resp = papi_exec.add('ipsec_backend_dump').execute_should_pass(
+ err_msg, process_reply=False)
+ # After API change there is returned VPP internal enum object
+ # representing VPP IPSEC protocol instead of integer representation
+ # so JSON fails to decode it - we need to check if it is Python API
+ # bug or we need to adapt vpp_papi_provider to correctly encode
+ # such object into JSON
+ # logger.trace('IPsec backend dump\n{dump}'.
+ # format(dump=papi_resp.reply))
+ logger.trace('IPsec backend dump\n{dump}'.format(dump=papi_resp.stdout))
+