2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
from vpp_interface import VppInterface
|
|
|
|
import socket
|
2019-04-16 07:15:35 +00:00
|
|
|
from vpp_papi import VppEnum
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VppGreInterface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP GRE interface
|
|
|
|
"""
|
|
|
|
|
2019-04-16 07:15:35 +00:00
|
|
|
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=None,
|
2018-02-13 17:15:23 -05:00
|
|
|
session=0):
|
2017-12-14 08:51:32 -08:00
|
|
|
""" Create VPP GRE interface """
|
2018-06-24 22:49:33 +02:00
|
|
|
super(VppGreInterface, self).__init__(test)
|
2016-11-15 09:46:51 +00:00
|
|
|
self.t_src = src_ip
|
|
|
|
self.t_dst = dst_ip
|
|
|
|
self.t_outer_fib = outer_fib_id
|
2018-02-13 17:15:23 -05:00
|
|
|
self.t_session = session
|
2019-04-16 07:15:35 +00:00
|
|
|
self.t_type = type
|
|
|
|
if not self.t_type:
|
|
|
|
self.t_type = (VppEnum.vl_api_gre_tunnel_type_t.
|
|
|
|
GRE_API_TUNNEL_TYPE_L3)
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
2019-04-16 07:15:35 +00:00
|
|
|
r = self.test.vapi.gre_tunnel_add_del(self.t_src,
|
|
|
|
self.t_dst,
|
2016-11-15 09:46:51 +00:00
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
session_id=self.t_session)
|
2018-06-24 22:49:33 +02:00
|
|
|
self.set_sw_if_index(r.sw_if_index)
|
2016-11-28 16:10:59 +00:00
|
|
|
self.generate_remote_hosts()
|
2018-05-23 20:22:20 +02:00
|
|
|
self.test.registry.register(self, self.test.logger)
|
2019-08-04 02:41:57 -07:00
|
|
|
return self
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
self.unconfig()
|
2019-04-16 07:15:35 +00:00
|
|
|
self.test.vapi.gre_tunnel_add_del(self.t_src,
|
|
|
|
self.t_dst,
|
2017-09-20 08:26:30 +02:00
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
session_id=self.t_session,
|
2017-09-20 08:26:30 +02:00
|
|
|
is_add=0)
|
|
|
|
|
|
|
|
def object_id(self):
|
2018-05-23 20:22:20 +02:00
|
|
|
return "gre-%d" % self.sw_if_index
|
2016-09-30 15:47:03 +01:00
|
|
|
|
2019-04-16 07:15:35 +00:00
|
|
|
def query_vpp_config(self):
|
|
|
|
return (self.test.vapi.gre_tunnel_dump(
|
|
|
|
sw_if_index=self._sw_if_index))
|