The underlying [c-code] vpp client API library supports one client connection. 
It’s not conceptually difficult to support multiple connections, but it would 
take a lot of typing and testing.

You can raise it as a feature request, but I wouldn’t plan on seeing it any 
time soon.

D.

From: Peter Mikus -X (pmikus - PANTHEON TECHNOLOGIES at Cisco)
Sent: Friday, May 11, 2018 6:44 AM
To: Justin Iurman <[email protected]>
Cc: Dave Barach (dbarach) <[email protected]>; Damjan Marion 
<[email protected]>; vpp-dev <[email protected]>
Subject: RE: [vpp-dev] vpp_api_test via socket file

Hello,

Thank you for the pointers. Seems to be working although with few notes:


  1.  It is not possible to keep both connection open:

vpp1 = VPP(jsonfiles)
r1 = vpp1.connect('vpp1', chroot_prefix='vpp1')
print('VPP1 version', vpp1.api.show_version().version.decode().rstrip('\0x00'))
vpp2 = VPP(jsonfiles)
r2 = vpp2.connect('vpp2', chroot_prefix='vpp2')
print('VPP2 version', vpp2.api.show_version().version.decode().rstrip('\0x00'))
vpp1.disconnect()
vpp2.disconnect()

>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_4eec6097
>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_reply_e8d4e804
>> ('VPP1 version', u'18.04-release')
>> WARNING:vpp_papi:VPP API client:: vac_connect:285: vl_client_api map rv -1
>>
>> WARNING:vpp_papi:VPP API client:: vac_connect:285: vl_client_api map rv -1
>>
>> Traceback (most recent call last):
>>   File "pythonAPI.py", line 18, in <module>
>>    r2 = vpp2.connect('vpp2', chroot_prefix='vpp')
>>   File "/usr/lib/python2.7/dist-packages/vpp_papi.py", line 690, in connect
>>     async)
>>   File "/usr/lib/python2.7/dist-packages/vpp_papi.py", line 661, in 
>> connect_internal
>>     raise IOError(2, 'Connect failed')
>> IOError: [Errno 2] Connect failed
>> DEBUG:vpp_papi:Cleaning up VPP on exit


On the other side this is possible:

vpp1 = VPP(jsonfiles)
r1 = vpp1.connect('vpp1', chroot_prefix='vpp1')
print('VPP1 version', vpp1.api.show_version().version.decode().rstrip('\0x00'))
vpp1.disconnect()
vpp2 = VPP(jsonfiles)
r2 = vpp2.connect('vpp2', chroot_prefix='vpp2')
print('VPP2 version', vpp2.api.show_version().version.decode().rstrip('\0x00'))
vpp2.disconnect()


>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_4eec6097
>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_reply_e8d4e804
>> ('VPP1 version', u'18.04-release')
>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_4eec6097
>> DEBUG:vpp_papi:No such message type or failed CRC checksum: 
>> cdp_enable_disable_reply_e8d4e804
>> ('VPP2 version', u'18.04-release')



  1.  print('VPP1', intf.interface_name.decode().rstrip('\0x00')) broke the 
output of interface 7/0/0

>> ('VPP1', u'TenGigabitEthernet7/0/')


  1.  DEBUG:vpp_papi:No such message type or failed CRC checksum: 
cdp_enable_disable_4eec6097

DEBUG:vpp_papi:No such message type or failed CRC checksum: 
cdp_enable_disable_reply_e8d4e804



Looks like some API’s need update



  1.  Connect() requires sudo, that means script needs to be running as root.



Peter Mikus
Engineer – Software
Cisco Systems Limited

From: Justin Iurman [mailto:[email protected]]
Sent: Friday, May 11, 2018 9:59 AM
To: Peter Mikus -X (pmikus - PANTHEON TECHNOLOGIES at Cisco) 
<[email protected]<mailto:[email protected]>>
Cc: Dave Barach (dbarach) <[email protected]<mailto:[email protected]>>; Damjan 
Marion <[email protected]<mailto:[email protected]>>; vpp-dev 
<[email protected]<mailto:[email protected]>>
Subject: Re: [vpp-dev] vpp_api_test via socket file

Peter,

…however, are there any other options to full control 2+ instances of VPP via 
API (not vppctl)? PythonAPI for example [1].

Ole’s answer to the same question:

r = vpp.connect('vpp1', chroot_prefix='name of shared address segment')

Cheers,

Justin

Reply via email to