| 1 |
# Copyright 2016 Huawei Technologies India Pvt. Ltd. |
| 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 |
from neutron_lib.api.definitions import bgp as bgp_ext |
| 17 |
from neutron_lib.plugins import directory |
| 18 |
import oslo_messaging |
| 19 |
|
| 20 |
|
| 21 |
class BgpSpeakerRpcCallback: |
| 22 |
"""BgpDrAgent RPC callback in plugin implementations. |
| 23 |
|
| 24 |
This class implements the server side of an RPC interface. |
| 25 |
The client side of this interface can be found in |
| 26 |
neutron_dynamic_routing.services.bgp.agent.bgp_dragent.BgpDrPluginApi. |
| 27 |
For more information about changing RPC interfaces, |
| 28 |
see https://docs.openstack.org/neutron/latest/ |
| 29 |
contributor/internals/rpc_api.html. |
| 30 |
""" |
| 31 |
|
| 32 |
# API version history: |
| 33 |
# 1.0 BGPDRPluginApi BASE_RPC_API_VERSION |
| 34 |
target = oslo_messaging.Target(version='1.0') |
| 35 |
|
| 36 |
@property |
| 37 |
def plugin(self): |
| 38 |
if not hasattr(self, '_plugin'): |
| 39 |
self._plugin = directory.get_plugin(bgp_ext.ALIAS) |
| 40 |
return self._plugin |
| 41 |
|
| 42 |
def get_bgp_speaker_info(self, context, bgp_speaker_id): |
| 43 |
"""Return BGP Speaker details such as peer list and local_as. |
| 44 |
|
| 45 |
Invoked by the BgpDrAgent to lookup the details of a BGP Speaker. |
| 46 |
""" |
| 47 |
return self.plugin.get_bgp_speaker_with_advertised_routes( |
| 48 |
context, bgp_speaker_id) |
| 49 |
|
| 50 |
def get_bgp_peer_info(self, context, bgp_peer_id): |
| 51 |
"""Return BgpPeer details such as IP, remote_as, and credentials. |
| 52 |
|
| 53 |
Invoked by the BgpDrAgent to lookup the details of a BGP peer. |
| 54 |
""" |
| 55 |
return self.plugin.get_bgp_peer(context, bgp_peer_id, |
| 56 |
['peer_ip', 'remote_as', |
| 57 |
'auth_type', 'password']) |
| 58 |
|
| 59 |
def get_bgp_speakers(self, context, host=None, **kwargs): |
| 60 |
"""Returns the list of all BgpSpeakers. |
| 61 |
|
| 62 |
Typically invoked by the BgpDrAgent as part of its bootstrap process. |
| 63 |
""" |
| 64 |
return self.plugin.get_bgp_speakers_for_agent_host(context, host) |