+ @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.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
+ """
+ # TODO: move composition of api data to separate method
+ api_data = list()
+ api = dict(api_name='ipsec_select_backend')
+ api_args = dict(protocol=protocol)
+ api_args['index'] = index
+ api['api_args'] = api_args
+ api_data.append(api)
+
+ api_reply = None
+ with PapiExecutor(node) as papi_executor:
+ papi_executor.execute_papi(api_data)
+ try:
+ papi_executor.papi_should_have_passed()
+ except AssertionError:
+ raise PapiError('Failed to select IPsec backend on host {host}'.
+ format(host=node['host']))
+ api_reply = papi_executor.get_papi_reply()
+
+ if api_reply is not None:
+ api_r = api_reply[0]['api_reply']['ipsec_select_backend_reply']
+ if api_r['retval'] == 0:
+ logger.trace('IPsec backend successfully selected on host '
+ '{host}'.format(host=node['host']))
+ else:
+ raise PapiError('Failed to select IPsec backend on host {host}'.
+ format(host=node['host']))
+ else:
+ raise PapiError('No reply received for ipsec_select_backend API '
+ 'command 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
+ """
+ # TODO: move composition of api data to separate method
+ api_data = list()
+ api = dict(api_name='ipsec_backend_dump')
+ api_args = dict()
+ api['api_args'] = api_args
+ api_data.append(api)
+
+ api_reply = None
+ with PapiExecutor(node) as papi_executor:
+ papi_executor.execute_papi(api_data)
+ try:
+ papi_executor.papi_should_have_passed()
+ except AssertionError:
+ raise PapiError('Failed to dump IPsec backends on host {host}'.
+ format(host=node['host']))
+ api_reply = papi_executor.get_papi_reply()
+
+ if api_reply is not None:
+ # api_r = api_reply[0]['api_reply']['ipsec_select_backend_reply']
+ # if api_r['retval'] == 0:
+ # logger.trace('IPsec backend successfully selected on host '
+ # '{host}'.format(host=node['host']))
+ # else:
+ # raise PapiError('Failed to select IPsec backend on host {host}'.
+ # format(host=node['host']))
+ logger.trace('IPsec backend dump\n{dump}'.format(dump=api_reply))
+ else:
+ raise PapiError('No reply received for ipsec_select_backend API '
+ 'command on host {host}'.format(host=node['host']))
+