os_ken.services.protocols.bgp.application

os_ken.services.protocols.bgp.application

This module provides a convenient application for using OSKen BGPSpeaker and for writing your BGP application.

It reads a configuration file which includes settings for neighbors, routes and some others. Please refer to os_ken/services/protocols/bgp/bgp_sample_conf.py for the sample configuration.

Usage Example:

$ osken-manager os_ken/services/protocols/bgp/application.py \
    --bgp-app-config-file os_ken/services/protocols/bgp/bgp_sample_conf.py

SSH Console

You can also use the SSH console and see the RIB and do some operations from this console. The SSH port and username/password can be configured by the configuration file. You can check the help by hitting '?' key in this interface.

Example:

$ ssh localhost -p 4990

Hello, this is OSKen BGP speaker (version 4.19).

bgpd> # Hit '?' key
 clear - allows to reset BGP connections
 help - show this help
 quit - exit this session
 set - set runtime settings
 show - shows runtime state information
bgpd>
bgpd> show rib all
Status codes: * valid, > best
Origin codes: i - IGP, e - EGP, ? - incomplete
     Network        Labels   Next Hop   Reason      Metric LocPrf Path
 *>  10.10.1.0/24   None     0.0.0.0    Only Path                 i
bgpd>

Integration with Other Applications

os_ken.services.protocols.bgp.application.OSKenBGPSpeaker will notifies the following events to other OSKen applications.

  • EventBestPathChanged
  • EventAdjRibInChanged
  • EventPeerDown
  • EventPeerUp

To catch these events, specify @set_ev_cls() decorator to the event handlers in the OSKen applications.

Example Application:

# my_bgp_app.py

from os_ken.base import app_manager
from os_ken.controller.handler import set_ev_cls
from os_ken.services.protocols.bgp import application as bgp_application


class MyBGPApp(app_manager.OSKenApp):
    _CONTEXTS = {
        'os_kenbgpspeaker': bgp_application.OSKenBGPSpeaker,
    }

    def __init__(self, *args, **kwargs):
        super(MyBGPApp, self).__init__(*args, **kwargs)

        # Stores "os_ken.services.protocols.bgp.application.OSKenBGPSpeaker"
        # instance in order to call the APIs of
        # "os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker" via
        # "self.app.speaker".
        # Please note at this time, "BGPSpeaker" is NOT instantiated yet.
        self.app = kwargs['os_kenbgpspeaker']

    @set_ev_cls(bgp_application.EventBestPathChanged)
    def _best_patch_changed_handler(self, ev):
        self.logger.info(
            'Best path changed: is_withdraw=%s, path=%s',
            ev.is_withdraw, ev.path)

Usage Example:

$ osken-manager my_bgp_app.py \
    --bgp-app-config-file os_ken/services/protocols/bgp/bgp_sample_conf.py

Note

For the APIs for os_ken.services.protocols.bgp.bgpspeaker.BGPSpeaker, please refer to BGP speaker library API Reference.

API Reference

exception os_ken.services.protocols.bgp.application.ApplicationException(desc=None)

Specific Base exception related to BSPSpeaker.

class os_ken.services.protocols.bgp.application.EventAdjRibInChanged(path, is_withdraw, peer_ip, peer_as)

Event called when any adj-RIB-in path is changed due to UPDATE messages or remote peer's down.

This event is the wrapper for adj_rib_in_change_handler of bgpspeaker.BGPSpeaker.

path attribute contains an instance of info_base.base.Path subclasses.

If is_withdraw attribute is True, path attribute has the information of the withdraw route.

peer_ip is the peer's IP address who sent this path.

peer_as is the peer's AS number who sent this path.

class os_ken.services.protocols.bgp.application.EventBestPathChanged(path, is_withdraw)

Event called when any best remote path is changed due to UPDATE messages or remote peer's down.

This event is the wrapper for best_path_change_handler of bgpspeaker.BGPSpeaker.

path attribute contains an instance of info_base.base.Path subclasses.

If is_withdraw attribute is True, path attribute has the information of the withdraw route.

class os_ken.services.protocols.bgp.application.EventPeerDown(remote_ip, remote_as)

Event called when the session to the remote peer goes down.

This event is the wrapper for peer_down_handler of bgpspeaker.BGPSpeaker.

remote_ip attribute is the IP address of the remote peer.

remote_as attribute is the AS number of the remote peer.

class os_ken.services.protocols.bgp.application.EventPeerUp(remote_ip, remote_as)

Event called when the session to the remote peer goes up.

This event is the wrapper for peer_up_handler of bgpspeaker.BGPSpeaker.

remote_ip attribute is the IP address of the remote peer.

remote_as attribute is the AS number of the remote peer.

class os_ken.services.protocols.bgp.application.OSKenBGPSpeaker(*args, **kwargs)

Base application for implementing BGP applications.

start()

Hook that is called after startup initialization is done.

os_ken.services.protocols.bgp.application.load_config(config_file)

Validates the given file for use as the settings file for BGPSpeaker and loads the configuration from the given file as a module instance.

os_ken.services.protocols.bgp.application.validate_rpc_host(ip)

Validates the given ip for use as RPC server address.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.