Hello,

Is there some sort of documentation where I can get all VPP methods avaible
for API purpose.

For example, he you used two methods - api.show_version and connect :

> r = vpp.connect('papi-example')
> rv = vpp.api.show_version()

How can I be able to take a outlook of what methods are avaiable in order to
build my own API?

Best Regards

-----Mensagem original-----
De: Marcos - Mgiga <[email protected]> 
Enviada em: sexta-feira, 6 de novembro de 2020 12:56
Para: 'Ole Troan' <[email protected]>
Cc: 'vpp-dev' <[email protected]>
Assunto: RES: RES: [vpp-dev] VPP API

Thanks!

-----Mensagem original-----
De: [email protected] <[email protected]> Em nome de Ole Troan Enviada
em: sexta-feira, 6 de novembro de 2020 04:51
Para: Marcos - Mgiga <[email protected]>
Cc: vpp-dev <[email protected]>
Assunto: Re: RES: [vpp-dev] VPP API

Hi,

> It worked just fine, I decided to install a whole new OS and build VPP 
> once again and everything ran as expected.
> 
> If I update Python version that is installed on system is it possible 
> that I will have any problem?

I don't believe so. I use Python 3.8 on most systems.

Cheers,
Ole


> 
> Best Regards
> 
> -----Mensagem original-----
> De: Marcos - Mgiga <[email protected]> Enviada em: quarta-feira, 4 
> de novembro de 2020 10:23
> Para: '[email protected]' <[email protected]>
> Cc: 'vpp-dev' <[email protected]>
> Assunto: RES: [vpp-dev] VPP API
> 
> Hello ,
> 
> Thank you very much for help me out.
> 
> I don't know if I gonna say something wrong, but by default VPP 
> installs Python 2.7, so I thought I wansn't able to choose which 
> version I would work with.
> 
> About VPP I'm using V 20.09. 
> 
> Best Regards.
> Marcos
> 
> -----Mensagem original-----
> De: [email protected] <[email protected]> Enviada em: 
> quarta-feira, 4 de novembro de 2020 05:02
> Para: Marcos - Mgiga <[email protected]>
> Cc: vpp-dev <[email protected]>
> Assunto: Re: [vpp-dev] VPP API
> 
> Hi Marcos,
> 
> You can simplify the example a bit.
> E.g. JSON files should be found in the default install directory.
> 
> Which Python and VPP version are you using?
> 
> I have not seen the logger issue you see.
> Presumably you can work around it with import logging
> logging.basicConfig()
> 
> 
> If you have a source view, it should be possible to run the following 
> if you cd to src/vpp-api/python
> 
> #!/usr/bin/env python3
> from vpp_papi import VPP
> vpp = VPP()
> r = vpp.connect('papi-example')
> rv = vpp.api.show_version()
> print(f'VPP version = {rv}')
> for intf in vpp.api.sw_interface_dump():
>    print(intf.interface_name)
> r = vpp.disconnect()
> exit(r)
> 
> 
> Cheers,
> Ole
> 
> 
>> On 3 Nov 2020, at 21:22, Marcos - Mgiga <[email protected]> wrote:
>> 
>> Hello There,
>> 
>> I intend to start building a VPP API in order to make easier the 
>> processo
> of managing VPP. So in order to take my first step I tried this tutorial:
>> https://haryachyy.wordpress.com/2019/12/24/learning-vpp-python-api/
>> 
>> It shows the following script which was supposed to show vpp
> version,interfaces, etc:
>> 
>> #!/bin/env python
>> 
>> 
>> 
>> from __future__ import print_function
>> 
>> import os
>> 
>> import fnmatch
>> 
>> import time
>> 
>> from vpp_papi import VPP
>> 
>> 
>> 
>> def papi_event_handler(msgname, result):
>> 
>>    print(msgname)
>> 
>>    print(result)
>> 
>> vpp_json_dir = '/usr/share/vpp/api/'
>> 
>> jsonfiles = []
>> 
>> for root, dirnames, filenames in os.walk(vpp_json_dir):
>> 
>>    for filename in fnmatch.filter(filenames, '*.api.json'):
>> 
>>        jsonfiles.append(os.path.join(vpp_json_dir, filename))
>> 
>> if not jsonfiles:
>> 
>>    print('Error: no json api files found')
>> 
>>    exit(-1)
>> 
>> vpp = VPP(jsonfiles)
>> 
>> r = vpp.connect('papi-example')
>> 
>> 
>> 
>> rv = vpp.api.show_version()
>> 
>> print('VPP version =', rv.version.decode().rstrip('\0x00'))
>> 
>> 
>> 
>> for intf in vpp.api.sw_interface_dump():
>> 
>>    print(intf.interface_name.decode())
>> 
>> 
>> 
>> async=True
> 
>> 
>> r=vpp.register_event_callback(papi_event_handler)
>> 
>> pid=os.getpid()
>> 
>> sw_ifs = [2]
>> 
>> r = vpp.api.want_per_interface_simple_stats(enable_disable=True,
>> sw_ifs=sw_ifs, num=len(sw_ifs), pid=pid)
>> 
>> print(r)
>> 
>> 
> 
>> 
>> time.sleep(60)
>> 
>> r = vpp.api.want_per_interface_simple_stats(enable_disable=False)
>> 
>> r = vpp.disconnect()
>> 
>> exit(r)
>> 
>> But everytime I run it I only get the following error: 
>> No handlers could be found for logger "vpp_papi.vpp_papi.VPPApiClient"
>> Traceback (most recent call last):
>> 
>> Do you have any suggestion ?
>> 
>> Best Regards
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#17995): https://lists.fd.io/g/vpp-dev/message/17995
Mute This Topic: https://lists.fd.io/mt/78188543/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to