Hi Jeff, Here is a sample code for python API. On Tue, Jun 26, 2018 at 4:39 AM, Jeff Bushman <jmbush...@gmail.com> wrote:
> Is there any documentation, examples or discussion of how to use the VPP > API Modules beyond the short documentation here? > https://docs.fd.io/vpp/18.07/vapi_doc.html > _._,_._,_ > ------------------------------ > Links: > > You receive all messages sent to this group. > > View/Reply Online (#9700) <https://lists.fd.io/g/vpp-dev/message/9700> | Reply > To Sender > <jmbush...@gmail.com?subject=Private:%20Re:%20%5Bvpp-dev%5D%20How%20to%20use%20VPP%20API%3F> > | Reply To Group > <vpp-dev@lists.fd.io?subject=Re:%20%5Bvpp-dev%5D%20How%20to%20use%20VPP%20API%3F> > | Mute This Topic <https://lists.fd.io/mt/22680782/675674> | New Topic > <https://lists.fd.io/g/vpp-dev/post> > > Your Subscription <https://lists.fd.io/g/vpp-dev/editsub/675674> | Contact > Group Owner <vpp-dev+ow...@lists.fd.io> | Unsubscribe > <https://lists.fd.io/g/vpp-dev/unsub> [holoogul...@gmail.com] > _._,_._,_ > >
#Be nam _e_ khoda #Program Description: #This program adds a new routing entry to IP FIB using VPP API from __future__ import print_function #Needed for adding entry to FIB #import socket import inspect import os import fnmatch import vpp_papi from vpp_papi import VPP 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) #print(dir(vpp)) r = vpp.connect("test_papi") print(r) #print(vpp.status()) #for entry in vpp.ip_fib_dump(): # print(entry.address) #print(dir(vpp)) #print(vpp.api) print("##################################################") print(" Before ") print("##################################################") fib = vpp.ip_fib_dump() print(fib) ################################# # add entry to fib # ################################# r = vpp.ip_add_del_route(is_add=1, dst_address="\x01\x01\x01\x01", dst_address_length=32, next_hop_address="\x02\x02\x02\x02") print(r) #print("Be nam _e_ khoda\n") #print(vpp.ip_address_dump.__doc__) #print("\n\nArguments : \n") #inspect.getargspec(vpp.ip_address_dump) print("#################################################") print(" After ") print("#################################################") fib = vpp.ip_fib_dump() print(fib) exit(vpp.disconnect())
#Be nam _e_ khoda #Program Description: #This program adds a new mpls entry to IP FIB using VPP API from __future__ import print_function #Needed for adding entry to FIB #import socket import inspect import os import fnmatch import vpp_papi from vpp_papi import VPP 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) #print(dir(vpp)) r = vpp.connect("test_papi") print(r) print("##################################################") print(" Before ") print("##################################################") #IP Fib fib = vpp.ip_fib_dump() print(fib) ################################# # add entry to fib # ################################# #In This API next_hop_weight must have a value, otherwise the entry added to IP FIB does not have MPLS label r = vpp.ip_add_del_route(is_add=0, is_ipv6=0, next_hop_weight=1, is_multipath=1, dst_address="\x0a\x00\x14\x02", dst_address_length=32, next_hop_sw_if_index=2, next_hop_n_out_labels=1, next_hop_out_label_stack=[78]) print("#################################################") print(" After ") print("#################################################") #IP Fib fib = vpp.ip_fib_dump() print(fib) exit(vpp.disconnect())
#Be nam _e_ khoda #Program Description: #This program adds a new mpls entry to MPLS FIB using VPP API from __future__ import print_function #Needed for adding entry to FIB #import socket import inspect import os import fnmatch import vpp_papi from vpp_papi import VPP 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) #print(dir(vpp)) r = vpp.connect("test_papi") print(r) #print(vpp.status()) print("##################################################") print(" Before ") print("##################################################") #MPLS Fib fib = vpp.mpls_fib_dump() print(fib) vpp.mpls_route_add_del(mr_is_add=1, mr_label=37, mr_eos=1, mr_next_hop_proto_is_ip4=1, mr_next_hop="\x01\x02\x03\x04", mr_next_hop_sw_if_index=1, mr_is_multicast=0, mr_is_multipath=0, mr_table_id=0, mr_is_interface_rx=1, mr_next_hop_n_out_labels=1, mr_next_hop_out_label_stack=[57]) print("#################################################") print(" After ") print("#################################################") fib = vpp.mpls_fib_dump() print(fib) exit(vpp.disconnect())
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#9710): https://lists.fd.io/g/vpp-dev/message/9710 Mute This Topic: https://lists.fd.io/mt/22680782/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-