neutron-dynamic-routing/neutron_dynamic_routing/services/bgp/agent/l3/bgp_rpc_api.py

82 lines
3.5 KiB
Python

# Copyright 2021 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import rpc as n_rpc
import oslo_messaging
class BgpL3ExtPluginApi(object):
"""Agent side of the bgp l3 agent ext RPC API.
This class implements the client side of an rpc interface.
The server side of this interface can be found in
api.rpc.handlers.bgp_speaker_rpc.BgpSpeakerRpcCallback.
API version history:
1.0 - Initial version.
"""
def __init__(self, topic):
target = oslo_messaging.Target(topic=topic, version='1.0')
self.client = n_rpc.get_client(target)
def get_bgp_speaker_info(self, context, bgp_speaker_id):
"""Make a remote process call to retrieve a BGP speaker info."""
cctxt = self.client.prepare()
return cctxt.call(context, 'get_bgp_speaker_info',
bgp_speaker_id=bgp_speaker_id)
def get_bgp_peer_info(self, context, bgp_peer_id):
"""Make a remote process call to retrieve a BGP peer info."""
cctxt = self.client.prepare()
return cctxt.call(context, 'get_bgp_peer_info',
bgp_peer_id=bgp_peer_id)
def get_routes_to_advertise(self, context, bgp_speaker_id, router_id):
"""Make a remote process call to get routes that can be advertised."""
cctxt = self.client.prepare()
return cctxt.call(context, 'get_routes_to_advertise',
bgp_speaker_id=bgp_speaker_id,
router_id=router_id)
def get_routes_to_withdraw(self, context, bgp_speaker_id, router_id):
"""Make a remote process call to get routes that can be withdrawn."""
cctxt = self.client.prepare()
return cctxt.call(context, 'get_routes_to_withdraw',
bgp_speaker_id=bgp_speaker_id,
router_id=router_id)
def get_speaker_associated_to_router(self, context, router_id):
"""Make a remote process call to get BGP speakers to which a router is
associated
"""
cctxt = self.client.prepare()
return cctxt.call(context, 'get_speaker_associated_to_router',
router_id=router_id)
def update_speaker_router_association_status(self, context, assoc_id,
status):
"""Make a remote process call to update router association status"""
cctxt = self.client.prepare()
return cctxt.call(context, 'update_speaker_router_association_status',
assoc_id=assoc_id, status=status)
def update_speaker_peer_association_status(self, context, assoc_id,
status):
"""Make a remote process call to update peer association status"""
cctxt = self.client.prepare()
return cctxt.call(context, 'update_speaker_peer_association_status',
assoc_id=assoc_id, status=status)