backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / bgp / info_base / l2vpnfs.py
1 # Copyright (C) 2017 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
18  L2VPN Flow Specification support.
19 """
20
21 import logging
22
23 from ryu.lib.packet.bgp import FlowSpecL2VPNNLRI
24 from ryu.lib.packet.bgp import RF_L2VPN_FLOWSPEC
25
26 from ryu.services.protocols.bgp.info_base.vpn import VpnDest
27 from ryu.services.protocols.bgp.info_base.vpn import VpnPath
28 from ryu.services.protocols.bgp.info_base.vpn import VpnTable
29
30 LOG = logging.getLogger('bgpspeaker.info_base.l2vpnfs')
31
32
33 class L2VPNFlowSpecDest(VpnDest):
34     """L2VPN Flow Specification Destination
35
36     Store Flow Specification Paths.
37     """
38     ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
39
40
41 class L2VPNFlowSpecTable(VpnTable):
42     """Global table to store L2VPN Flow Specification routing information.
43
44     Uses `L2VPNFlowSpecDest` to store destination information for each known
45     Flow Specification paths.
46     """
47     ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
48     VPN_DEST_CLASS = L2VPNFlowSpecDest
49
50
51 class L2VPNFlowSpecPath(VpnPath):
52     """Represents a way of reaching an L2VPN Flow Specification destination."""
53     ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
54     VRF_PATH_CLASS = None  # defined in init - anti cyclic import hack
55     NLRI_CLASS = FlowSpecL2VPNNLRI
56
57     def __init__(self, *args, **kwargs):
58         # Set dummy IP address.
59         kwargs['nexthop'] = '0.0.0.0'
60         super(L2VPNFlowSpecPath, self).__init__(*args, **kwargs)
61         from ryu.services.protocols.bgp.info_base.vrfl2vpnfs import (
62             L2vpnFlowSpecPath)
63         self.VRF_PATH_CLASS = L2vpnFlowSpecPath
64         # Because the L2VPN Flow Specification does not require nexthop,
65         # initialize with None.
66         self._nexthop = None