1# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12# implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16""" 17 Defines data types and models required specifically for EVPN support. 18""" 19 20import logging 21 22from ryu.lib.packet.bgp import EvpnNLRI 23from ryu.lib.packet.bgp import RF_L2_EVPN 24 25from ryu.services.protocols.bgp.info_base.vpn import VpnDest 26from ryu.services.protocols.bgp.info_base.vpn import VpnPath 27from ryu.services.protocols.bgp.info_base.vpn import VpnTable 28 29LOG = logging.getLogger('bgpspeaker.info_base.evpn') 30 31 32class EvpnDest(VpnDest): 33 """EVPN Destination 34 35 Store EVPN Paths. 36 """ 37 ROUTE_FAMILY = RF_L2_EVPN 38 39 40class EvpnTable(VpnTable): 41 """Global table to store EVPN routing information. 42 43 Uses `EvpnDest` to store destination information for each known EVPN 44 paths. 45 """ 46 ROUTE_FAMILY = RF_L2_EVPN 47 VPN_DEST_CLASS = EvpnDest 48 49 50class EvpnPath(VpnPath): 51 """Represents a way of reaching an EVPN destination.""" 52 ROUTE_FAMILY = RF_L2_EVPN 53 VRF_PATH_CLASS = None # defined in init - anti cyclic import hack 54 NLRI_CLASS = EvpnNLRI 55 56 def __init__(self, *args, **kwargs): 57 super(EvpnPath, self).__init__(*args, **kwargs) 58 from ryu.services.protocols.bgp.info_base.vrfevpn import VrfEvpnPath 59 self.VRF_PATH_CLASS = VrfEvpnPath 60