1 # Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 Core Manager module dedicated for providing CORE_MANAGER singleton
19 from ryu.services.protocols.bgp.base import Activity
20 from ryu.services.protocols.bgp.base import ActivityException
21 from ryu.services.protocols.bgp.rtconf.neighbors import NeighborsConf
22 from ryu.services.protocols.bgp.rtconf.vrfs import VrfsConf
25 class _CoreManager(Activity):
26 """Core service manager.
30 self._common_conf = None
31 self._neighbors_conf = None
32 self._vrfs_conf = None
33 self._core_service = None
34 super(_CoreManager, self).__init__()
36 def _run(self, *args, **kwargs):
37 self._common_conf = kwargs.pop('common_conf')
38 self._neighbors_conf = NeighborsConf()
39 self._vrfs_conf = VrfsConf()
40 from ryu.services.protocols.bgp.core import CoreService
41 self._core_service = CoreService(self._common_conf,
44 waiter = kwargs.pop('waiter')
45 core_activity = self._spawn_activity(self._core_service, waiter=waiter)
48 def get_core_service(self):
50 return self._core_service
52 def _check_started(self):
54 raise ActivityException('Cannot access any property before '
55 'activity has started')
58 def common_conf(self):
60 return self._common_conf
63 def neighbors_conf(self):
65 return self._neighbors_conf
70 return self._vrfs_conf
73 # _CoreManager instance that manages core bgp service and configuration data.
74 CORE_MANAGER = _CoreManager()