Exemple #1
0
 def setUp(self):
     print("Connecting API")
     r = vpp_papi.connect("test_papi")
     self.assertEqual(r, 0)
Exemple #2
0
 def __init__(self, log):
     self.LOG = log
     self.r = vpp_papi.connect("test_papi")
Exemple #3
0
 def setUp(self):
     r = vpp_papi.connect("test_papi")
     self.assertEqual(r, 0)
Exemple #4
0
from __future__ import print_function
import unittest
import vpp_papi
import pot, snat
print('Plugins:')
vpp_papi.plugin_show()
r = vpp_papi.connect('ole')

r = vpp_papi.show_version()
print('R:', r)

r = snat.snat_interface_add_del_feature(1, 1, 1)
print('R:', r)

list_name = 'foobar'
r = pot.pot_profile_add(0, 1, 123, 123, 0, 12, 0, 23, len(list_name),
                        list_name)
print('R:', r)
vpp_papi.disconnect()
Exemple #5
0
 def connect(self):
     """Connect the API to VPP"""
     vpp_papi.connect(self.name, self.shm_prefix)
Exemple #6
0
#!/bin/env python
from __future__ import print_function

import vpp_papi as vpp 

if_1_name = 'TenGigabitEthernet83/0/0'
if_2_name = 'TenGigabitEthernet83/0/1'
if_3_name = 'netmap-vale00:pm'

r = vpp.connect('papi')

if_1_sw_if_index = vpp.sw_interface_dump(1, if_1_name)[0].sw_if_index
if_2_sw_if_index = vpp.sw_interface_dump(1, if_2_name)[0].sw_if_index
if_3_sw_if_index = vpp.sw_interface_dump(1, if_3_name)[0].sw_if_index

# add flowtable as available classifier next nodes
r = vpp.add_node_next("l2-input-classify", "flowtable-process")
print(r)
ft_idx = r.node_index;

# add, table_index, nbuckets, memory_size, skip_n_vectors, match_n_vectors, next_table_index, miss_next_index, mask
cl0 = vpp.classify_add_del_table(1, 0xffffffff, 64, 1024*1024, 0, 1, 0xffffffff, ft_idx, '')
print(cl0)

# input -> 1, output -> 0
r = vpp.classify_set_interface_l2_tables(if_1_sw_if_index, cl0.new_table_index, 0xffffffff, 0xffffffff, 1)
print(r)

r = vpp.disconnect()
exit(r)
Exemple #7
0
 def __init__(self, log):
     self.LOG = log
     self.r = vpp_papi.connect("test_papi")
 def __init__(self):
     self.r = vpp_papi.connect("test_papi")
Exemple #9
0
    def __init__(self,
                 key,
                 vpp_uplink_interface_index,
                 uplink_ip,
                 uplink_subnet,
                 protocol='http',
                 host='127.0.0.1',
                 port=4001,
                 username=None,
                 password=None):

        # logging
        logging.basicConfig(filename='vpp-calico-routeagent.log',level=logging.DEBUG)

        # ConMan setup.
        self.conman = ConManEtcd(protocol=protocol,
                                 host=host,
                                 port=int(port),
                                 username=username,
                                 password=password,
                                 on_change=self.on_configuration_change,
                                 watch_timeout=200)

        # Need to know our hostname
        self.hostname = socket.gethostname()

        # This is the interface and IP this host's VPP uses for the outside world.
        # We'll publish this in ETCD to allow other VPP's to form adjacencys.
        self.vpp_uplink_interface_index = int(vpp_uplink_interface_index)
        self.uplink_ip = uplink_ip
        self.uplink_subnet = uplink_subnet

        # Publish our VPP uplink IP to /vpp-calico/hosts/<hostname>/peerip/ipv4/1
        self.etcd_cli = self.conman.client
        self.host_uplink_info_key = '/vpp-calico/hosts/' + self.hostname + '/peerip/ipv4/1'
        self.etcd_cli.write(self.host_uplink_info_key, value=uplink_ip)

        # Connect to VPP API
        self.r = vpp_papi.connect("vpp-calico")
        if self.r != 0:
            logging.critical("vppapi: could not connect to vpp")
            return
        logging.debug('Connected to VPP API %s', type(self.r))

        # Set VPP uplink interface to 'up'
        logging.debug('Configuring VPP Uplink interface.')
        flags_r = vpp_papi.sw_interface_set_flags(self.vpp_uplink_interface_index,1,1,0)
        if type(flags_r) == list or flags_r.retval != 0:
            logging.critical("Failed to bring up our UPLINK VPP interface. Failing.")
            return
        logging.debug("vppapi: VPP Uplink interface UP!")

        # Configure Uplink IP address based on agent configuration (uplink_ip, uplink_subnet)
        uplink_ip = uplink_ip.encode('utf-8', 'ignore')
        uplink_ip = socket.inet_pton(socket.AF_INET, uplink_ip)
        uplinkip_r = vpp_papi.sw_interface_add_del_address(self.vpp_uplink_interface_index,True,False,False,int(uplink_subnet),uplink_ip)
        if type(uplinkip_r) == list or uplinkip_r.retval != 0:
            logging.critical("Failed to add IPv4 address to uplink")
            return
        logging.debug("vppapi: VPP Uplink IPv4 Configured!")

        #ConMan Vars for watching IP blocks.
        self.key = key
        self.last_change = None
        self.run()