-# client name
-CLIENT_NAME = 'csit_papi'
-
-
-def papi_init():
- """Construct a VPP instance from VPP JSON API files.
-
- :param vpp_json_dir: Directory containing all the JSON API files. If VPP is
- installed in the system it will be in /usr/share/vpp/api/.
- :type vpp_json_dir: str
- :returns: VPP instance.
- :rtype: VPP object
- :raises PapiJsonFileError: If no api.json file found.
- :raises PapiInitError: If PAPI initialization failed.
- """
- try:
- vpp = VPP()
- return vpp
- except Exception as err:
- raise RuntimeError('PAPI init failed:\n{err}'.format(err=repr(err)))
-
-
-def papi_connect(vpp_client, name='vpp_api'):
- """Attach to VPP client.
-
- :param vpp_client: VPP instance to connect to.
- :param name: VPP client name.
- :type vpp_client: VPP object
- :type name: str
- :returns: Return code of VPP.connect() method.
- :rtype: int
- """
- return vpp_client.connect(name)
-
-
-def papi_disconnect(vpp_client):
- """Detach from VPP client.
-
- :param vpp_client: VPP instance to detach from.
- :type vpp_client: VPP object
- """
- vpp_client.disconnect()
-
-
-def papi_run(vpp_client, api_name, api_args):
- """Run PAPI.
-
- :param vpp_client: VPP instance.
- :param api_name: VPP API name.
- :param api_args: Input arguments of the API.
- :type vpp_client: VPP object
- :type api_name: str
- :type api_args: dict
- :returns: VPP API reply.
- :rtype: Vpp_serializer reply object
- """
- papi_fn = getattr(vpp_client.api, api_name)
- return papi_fn(**api_args)
-