summaryrefslogtreecommitdiffstats
path: root/test/vpp_l2.py
AgeCommit message (Expand)AuthorFilesLines
2019-11-15tests: Remove the unrequired VPP IP address/prefix class wrappersNeale Ranns1-1/+0
2019-06-19l2: BD ARP termination entry API updateNeale Ranns1-21/+21
2019-04-24l2: Add support for arp unicast forwardingMohsin Kazmi1-2/+6
2019-03-29tests: test/vpp_l2.py fix missing name.Paul Vinciguerra1-0/+1
2019-03-29tests: refactor vpp_object.pyPaul Vinciguerra1-15/+0
2019-03-12GBP: L3 out fixesNeale Ranns1-0/+29
2019-03-11vpp_papi_provider: Remove more wrapper functions.Ole Troan1-17/+11
2019-03-06test framework: vpp_papi_provider.py - further cleanupOle Troan1-11/+7
2019-03-01Tests: Remove all wildcard imports.Paul Vinciguerra1-1/+1
2018-12-18PAPI: Add MACAddress object wrapper for vl_api_mac_address_tOle Troan1-13/+13
2018-12-10Test framework: StringIO fixes for Python3Ole Troan1-2/+1
2018-11-07GBP Endpoint LearningNeale Ranns1-0/+221
weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
from vpp_interface import VppInterface
from vpp_papi import VppEnum


INDEX_INVALID = 0xffffffff


def find_vxlan_gbp_tunnel(test, src, dst, vni):
    ts = test.vapi.vxlan_gbp_tunnel_dump(INDEX_INVALID)
    for t in ts:
        if src == str(t.tunnel.src) and \
           dst == str(t.tunnel.dst) and \
           t.tunnel.vni == vni:
            return t.tunnel.sw_if_index
    return INDEX_INVALID


class VppVxlanGbpTunnel(VppInterface):
    """
    VPP VXLAN GBP interface
    """

    def __init__(self, test, src, dst, vni, mcast_itf=None, mode=None,
                 is_ipv6=None, encap_table_id=None, instance=0xffffffff):
        """ Create VXLAN-GBP Tunnel interface """
        super(VppVxlanGbpTunnel, self).__init__(test)
        self.src = src
        self.dst = dst
        self.vni = vni
        self.mcast_itf = mcast_itf
        self.ipv6 = is_ipv6
        self.encap_table_id = encap_table_id
        self.instance = instance
        if not mode:
            self.mode = (VppEnum.vl_api_vxlan_gbp_api_tunnel_mode_t.
                         VXLAN_GBP_API_TUNNEL_MODE_L2)
        else:
            self.mode = mode

    def add_vpp_config(self):
        mcast_sw_if_index = INDEX_INVALID
        if (self.mcast_itf):
            mcast_sw_if_index = self.mcast_itf.sw_if_index
        reply = self.test.vapi.vxlan_gbp_tunnel_add_del(
            is_add=1,
            tunnel={
                'src': self.src,
                'dst': self.dst,
                'mode': self.mode,
                'vni': self.vni,
                'mcast_sw_if_index': mcast_sw_if_index,
                'encap_table_id': self.encap_table_id,
                'instance': self.instance
            })
        self.set_sw_if_index(reply.sw_if_index)
        self._test.registry.register(self, self._test.logger)

    def remove_vpp_config(self):
        mcast_sw_if_index = INDEX_INVALID
        if (self.mcast_itf):
            mcast_sw_if_index = self.mcast_itf.sw_if_index
        self.test.vapi.vxlan_gbp_tunnel_add_del(
            is_add=0,
            tunnel={
                'src': self.src,
                'dst': self.dst,
                'mode': self.mode,
                'vni': self.vni,
                'mcast_sw_if_index': mcast_sw_if_index,
                'encap_table_id': self.encap_table_id,
                'instance': self.instance,
            })

    def query_vpp_config(self):
        return (INDEX_INVALID != find_vxlan_gbp_tunnel(self._test,
                                                       self.src,
                                                       self.dst,
                                                       self.vni))

    def object_id(self):
        return "vxlan-gbp-%d-%d-%s-%s" % (self.sw_if_index, self.vni,
                                          self.src, self.dst)